@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);
 }
 @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) {
   }
 }
 @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) {
   }
 }
 @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) {
   }
 }
 @Override
 public ImmutableUndirectedGraph<Integer, String> createGraph() {
   builder = ImmutableUndirectedGraph.builder(Graphs.config().noSelfLoops());
   return builder.build();
 }
 @Override
 final boolean addEdge(String e, Integer n1, Integer n2) {
   graph = immutableGraph = builder.addEdge(e, n1, n2).build();
   return true;
 }
 @Override
 final boolean addNode(Integer n) {
   graph = immutableGraph = builder.addNode(n).build();
   return true;
 }
 @Test
 public void addGraph() {
   UndirectedGraph<Integer, String> graph = Graphs.createUndirected(immutableGraph.config());
   populateInputGraph(graph);
   assertThat(builder.addGraph(graph).build()).isEqualTo(graph);
 }