-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGraphDriver.java
More file actions
46 lines (36 loc) · 1.36 KB
/
GraphDriver.java
File metadata and controls
46 lines (36 loc) · 1.36 KB
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
/**
* Graph ADT
* Coded by Amir El Bawab
* Date: 22 December 2014
* License: MIT License ~ Please read License.txt for more information about the usage of this software
* */
import graph.Graph;
import graph.Vertex;
import java.io.FileNotFoundException;
public class GraphDriver {
public static void main(String[] args) {
try {
Graph<String,String> graph = Graph.inParser("MIT.txt", true);
System.out.println("Print graph state\n");
System.out.println(graph);
System.out.println("BFS:");
for(Vertex<String,String> v : graph.BFS())
System.out.print(v + " ");
System.out.println("\n\nDFS");
for(Vertex<String,String> v : graph.DFS())
System.out.print(v + " ");
System.out.println("\n\nIs connected: "+graph.isConnected());
System.out.println("Is directed: "+graph.isDirected());
System.out.println("Is cyclic: "+graph.isCyclic());
System.out.println("Number of Connected components: "+graph.connectedComponents());
System.out.println("\nClone graph ... ");
Graph<String,String> cloned = graph.clone();
System.out.println("Apply Transitive closure to the cloned graph");
cloned.transitiveClosure();
System.out.println("Print state of the new graph\n");
System.out.println(cloned);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}