- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.java
More file actions
Latest commit
31 lines (23 loc) · 525 Bytes
/
Copy pathGraph.java
File metadata and controls
31 lines (23 loc) · 525 Bytes
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
publicclassGraph {
intnumNodes;
Node[] nodes;
publicvoidaddEdge(inti, intj) {
if(i<nodes.length && j<nodes.length) {
nodes[i].edges.add(nodes[j]);
nodes[j].edges.add(nodes[i]);
}
else {
}
}
publicGraph(intnum) {
numNodes = num;
nodes = newNode[numNodes];
for(inti = 0; i < numNodes; i++) {
nodes[i] = newNode(i);
}
// you might also want to do other things here
}
publicbooleanedgeExists(Nodei, Nodej) {
returni.edges.contains(j);
}
}