public void testZeroNodes() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(0, 0, 0.5); DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); assertEquals(0, g.vertexSet().size()); assertEquals(0, g.edgeSet().size()); }
public void testDirectedGraphGnp2() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(4, 4, 1.0, SEED); DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); assertEquals(4 + 4, g.vertexSet().size()); assertEquals(32, g.edgeSet().size()); }
public void testUndirectedGraphGnp3() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(4, 4, 0.0, SEED); UndirectedGraph<Integer, DefaultEdge> g = new SimpleGraph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); assertEquals(4 + 4, g.vertexSet().size()); assertEquals(0, g.edgeSet().size()); }
public void testDirectedGraphGnp3() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(4, 4, 0.1, SEED); DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); int[][] edges = {{5, 1}, {7, 3}, {3, 8}, {8, 4}}; assertEquals(4 + 4, g.vertexSet().size()); for (int[] e : edges) { assertTrue(g.containsEdge(e[0], e[1])); } assertEquals(edges.length, g.edgeSet().size()); }
public void testUndirectedGraphGnp1() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(4, 4, 0.5, SEED); UndirectedGraph<Integer, DefaultEdge> g = new SimpleGraph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); int[][] edges = {{1, 6}, {1, 7}, {1, 8}, {2, 5}, {2, 7}, {3, 5}, {3, 8}, {4, 6}, {4, 7}}; assertEquals(4 + 4, g.vertexSet().size()); for (int[] e : edges) { assertTrue(g.containsEdge(e[0], e[1])); } assertEquals(edges.length, g.edgeSet().size()); }