/** . */ public void testIsGraphConnected() { Pseudograph<String, DefaultEdge> g = create(); ConnectivityInspector<String, DefaultEdge> inspector = new ConnectivityInspector<String, DefaultEdge>(g); assertEquals(false, inspector.isGraphConnected()); g.removeVertex(V4); inspector = new ConnectivityInspector<String, DefaultEdge>(g); assertEquals(true, inspector.isGraphConnected()); g.removeVertex(V1); assertEquals(1, g.edgeSet().size()); g.removeEdge(e2); g.addEdge(V2, V2); assertEquals(1, g.edgeSet().size()); inspector = new ConnectivityInspector<String, DefaultEdge>(g); assertEquals(false, inspector.isGraphConnected()); }
/** * . * * @return a graph */ public Pseudograph<String, DefaultEdge> create() { Pseudograph<String, DefaultEdge> g = new Pseudograph<String, DefaultEdge>(DefaultEdge.class); assertEquals(0, g.vertexSet().size()); g.addVertex(V1); assertEquals(1, g.vertexSet().size()); g.addVertex(V2); assertEquals(2, g.vertexSet().size()); g.addVertex(V3); assertEquals(3, g.vertexSet().size()); g.addVertex(V4); assertEquals(4, g.vertexSet().size()); assertEquals(0, g.edgeSet().size()); e1 = g.addEdge(V1, V2); assertEquals(1, g.edgeSet().size()); e2 = g.addEdge(V2, V3); assertEquals(2, g.edgeSet().size()); e3 = g.addEdge(V3, V1); assertEquals(3, g.edgeSet().size()); e3_b = g.addEdge(V3, V1); assertEquals(4, g.edgeSet().size()); assertNotNull(e3_b); u = g.addEdge(V1, V1); assertEquals(5, g.edgeSet().size()); u = g.addEdge(V1, V1); assertEquals(6, g.edgeSet().size()); return g; }