-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientProgram.java
More file actions
33 lines (22 loc) · 808 Bytes
/
Copy pathclientProgram.java
File metadata and controls
33 lines (22 loc) · 808 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
32
33
package graphPrograms;
public class clientProgram {
public static void main(String[] args) {
Graph graph = new Graph(); // New graph created
// Adding all the neighbors
graph.addEdge("B","A");
graph.addEdge("B","C");
graph.addEdge("C","F");
graph.addEdge("D","A");
graph.addEdge("E","A");
graph.addEdge("E","B");
graph.addEdge("F","E");
graph.addEdge("F","I");
graph.addEdge("G","D");
graph.addEdge("H","G");
graph.addEdge("H","E");
graph.addEdge("H","F");
graph.addEdge("I","H");
String[] neighborsE = graph.getNeighbors("E"); // Using getNeighbor method to move copy of all the neighbors of node E to an array
System.out.println("Neighbors of vertex E: "+neighborsE[0] + ", "+ neighborsE[1]); // Output
}
}