check whether a path exists between two nodes in jgrapht 06-16-2015d1105
2015-06-16check whether a path exists between two nodes in jgrapht 06-16-2015d1105
link
example code
String network = useful_tools.storeTextFiletoString("C:\\Users\\Kurt\\Downloads\\read highland tribe alliance edgelist.txt");
UndirectedGraph<String, DefaultEdge> graph = gm.createStringGraph(network);
ConnectivityInspector ce = new ConnectivityInspector(graph);
Object[] vertices = graph.vertexSet().toArray();
useful_tools.createTextFile("C:\\Users\\Kurt\\Desktop\\temp", "all_vertices.txt", Arrays.toString(vertices));
String existence = String.valueOf(ce.pathExists(vertices[1], vertices[8])).toString();
System.out.println("State of path from " + vertices[1]+" to "+ vertices[8]+": " + existence);
useful_tools.createTextFile("C:\\Users\\Kurt\\Desktop\\temp", "temp.txt", graph.toString());