-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraph.java
51 lines (42 loc) · 1.19 KB
/
Graph.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Stack;
public class Graph {
private double [][] matrix;
public Graph(int numVert)
{
this.matrix = new double [numVert][numVert];
}
public void setEdgeWeight(double weight , int vertex1 , int vertex2)
{
matrix[vertex1][vertex2] = weight;
}
public double getWeight(int vertex1 , int vertex2)
{
return matrix[vertex1][vertex2];
}
public double[][] getMatrix()
{
return this.matrix;
}
public void setEdge( int city, int connection , Double weight)
{
this.matrix[city][connection] = weight;
}
// public void printGraph(List<City> database)
// {
// for(int i = 0 ; i < database.size() ; i++ )
// {
// System.out.printf("The distances between %s the other Cities is: \n"
// , database.get(i));
// for (int j = 0 ; j < database.size() ; j++)
// {
// if (matrix[i][j] != 0)
// {
// System.out.printf("-%s" , database.get(j));
// }
// }
// }
// }
}