private SimpleGraph<String, DefaultEdge> buildCliqueGraph(int size) { SimpleGraph<String, DefaultEdge> clique = new SimpleGraph<>(DefaultEdge.class); CompleteGraphGenerator<String, DefaultEdge> graphGenerator = new CompleteGraphGenerator<>(size); graphGenerator.generateGraph( clique, new VertexFactory<String>() { private int index = 0; @Override public String createVertex() { return String.valueOf(index++); } }, null); return clique; }
private SimpleGraph<Integer, DefaultEdge> buildGraphForTestDisconnected(int size) { SimpleGraph<Integer, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class); VertexFactory<Integer> vertexFactory = new IntegerVertexFactory(); CompleteGraphGenerator<Integer, DefaultEdge> completeGraphGenerator = new CompleteGraphGenerator<>(size); // two complete graphs SimpleGraph<Integer, DefaultEdge> east = new SimpleGraph<>(DefaultEdge.class); completeGraphGenerator.generateGraph(east, vertexFactory, null); SimpleGraph<Integer, DefaultEdge> west = new SimpleGraph<>(DefaultEdge.class); completeGraphGenerator.generateGraph(west, vertexFactory, null); Graphs.addGraph(graph, east); Graphs.addGraph(graph, west); // connected by single edge graph.addEdge(size - 1, size); return graph; }