Skip to content

Instantly share code, notes, and snippets.

@ibogun
Created April 20, 2016 14:58
Show Gist options
  • Save ibogun/ead180a1369d4fb527f5e56588bfb591 to your computer and use it in GitHub Desktop.
Save ibogun/ead180a1369d4fb527f5e56588bfb591 to your computer and use it in GitHub Desktop.
package graphs;
public class WeightedGraph extends Graph {
private double[][] weights;
public WeightedGraph(int V) {
super(V);
weights = new double[V][V];
}
public double getWeight(int from, int to) {
return weights[from][to];
}
public void addWeightedDirectedEdge(int from, int to, double weight) {
weights[from][to] = weight;
super.addDirectedEdge(from, to);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment