コード例 #1
0
 @Test
 public void addGraph_overlap() {
   UndirectedGraph<Integer, String> graph = Graphs.createUndirected(immutableGraph.config());
   populateInputGraph(graph);
   // Add an edge that is in 'graph' (overlap)
   builder.addEdge(E12, N1, N2);
   builder.addGraph(graph);
   assertThat(builder.build()).isEqualTo(graph);
 }
コード例 #2
0
 @Test
 public void addGraph_incompatibleSelfLoopConfig() {
   try {
     UndirectedGraph graph = Graphs.createUndirected(Graphs.config().noSelfLoops());
     ImmutableUndirectedGraph.Builder immutableGraphBuilder = ImmutableUndirectedGraph.builder();
     immutableGraphBuilder.addGraph(graph);
     fail("Should have rejected a graph with an incompatible self-loop configuration");
   } catch (IllegalArgumentException expected) {
   }
 }
コード例 #3
0
 @Test
 public void addGraph_incompatibleMultigraphConfig() {
   try {
     UndirectedGraph multigraph = Graphs.createUndirected(Graphs.MULTIGRAPH);
     ImmutableUndirectedGraph.Builder immutableGraphBuilder = ImmutableUndirectedGraph.builder();
     immutableGraphBuilder.addGraph(multigraph);
     fail("Should have rejected a graph with an incompatible multigraph configuration");
   } catch (IllegalArgumentException expected) {
   }
 }
コード例 #4
0
 @Test
 public void addGraph_inconsistentEdges() {
   UndirectedGraph<Integer, String> graph = Graphs.createUndirected(immutableGraph.config());
   populateInputGraph(graph);
   builder.addEdge(E12, N5, N1);
   try {
     builder.addGraph(graph);
     fail(
         "Should have rejected a graph whose edge definitions were inconsistent with existing"
             + "builder state");
   } catch (IllegalArgumentException expected) {
   }
 }
コード例 #5
0
 @Override
 public ImmutableUndirectedGraph<Integer, String> createGraph() {
   builder = ImmutableUndirectedGraph.builder(Graphs.config().noSelfLoops());
   return builder.build();
 }
コード例 #6
0
 @Override
 final boolean addEdge(String e, Integer n1, Integer n2) {
   graph = immutableGraph = builder.addEdge(e, n1, n2).build();
   return true;
 }
コード例 #7
0
 @Override
 final boolean addNode(Integer n) {
   graph = immutableGraph = builder.addNode(n).build();
   return true;
 }
コード例 #8
0
 @Test
 public void addGraph() {
   UndirectedGraph<Integer, String> graph = Graphs.createUndirected(immutableGraph.config());
   populateInputGraph(graph);
   assertThat(builder.addGraph(graph).build()).isEqualTo(graph);
 }