• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.common.graph;
18 
19 import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
20 import static com.google.common.truth.Truth.assertThat;
21 import static com.google.common.truth.TruthJUnit.assume;
22 import static org.junit.Assert.assertThrows;
23 import static org.junit.Assert.assertTrue;
24 import static org.junit.Assert.fail;
25 
26 import com.google.common.collect.ImmutableSet;
27 import com.google.common.testing.EqualsTester;
28 import java.util.Set;
29 import org.junit.After;
30 import org.junit.Test;
31 
32 /**
33  * Abstract base class for testing undirected {@link Network} implementations defined in this
34  * package.
35  */
36 public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetworkTest {
37   private static final EndpointPair<Integer> ENDPOINTS_N1N2 = EndpointPair.ordered(N1, N2);
38   private static final EndpointPair<Integer> ENDPOINTS_N2N1 = EndpointPair.ordered(N2, N1);
39 
40   @After
validateUndirectedEdges()41   public void validateUndirectedEdges() {
42     for (Integer node : network.nodes()) {
43       new EqualsTester()
44           .addEqualityGroup(
45               network.inEdges(node), network.outEdges(node), network.incidentEdges(node))
46           .testEquals();
47       new EqualsTester()
48           .addEqualityGroup(
49               network.predecessors(node), network.successors(node), network.adjacentNodes(node))
50           .testEquals();
51 
52       for (Integer adjacentNode : network.adjacentNodes(node)) {
53         assertThat(network.edgesConnecting(node, adjacentNode))
54             .containsExactlyElementsIn(network.edgesConnecting(adjacentNode, node));
55       }
56     }
57   }
58 
59   @Override
60   @Test
nodes_checkReturnedSetMutability()61   public void nodes_checkReturnedSetMutability() {
62     Set<Integer> nodes = network.nodes();
63     assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
64     addNode(N1);
65     assertThat(network.nodes()).containsExactlyElementsIn(nodes);
66   }
67 
68   @Override
69   @Test
edges_checkReturnedSetMutability()70   public void edges_checkReturnedSetMutability() {
71     Set<String> edges = network.edges();
72     assertThrows(UnsupportedOperationException.class, () -> edges.add(E12));
73     addEdge(N1, N2, E12);
74     assertThat(network.edges()).containsExactlyElementsIn(edges);
75   }
76 
77   @Override
78   @Test
incidentEdges_checkReturnedSetMutability()79   public void incidentEdges_checkReturnedSetMutability() {
80     addNode(N1);
81     Set<String> incidentEdges = network.incidentEdges(N1);
82     assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12));
83     addEdge(N1, N2, E12);
84     assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
85   }
86 
87   @Override
88   @Test
adjacentNodes_checkReturnedSetMutability()89   public void adjacentNodes_checkReturnedSetMutability() {
90     addNode(N1);
91     Set<Integer> adjacentNodes = network.adjacentNodes(N1);
92     assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
93     addEdge(N1, N2, E12);
94     assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
95   }
96 
97   @Override
adjacentEdges_checkReturnedSetMutability()98   public void adjacentEdges_checkReturnedSetMutability() {
99     addEdge(N1, N2, E12);
100     Set<String> adjacentEdges = network.adjacentEdges(E12);
101     try {
102       adjacentEdges.add(E23);
103       fail(ERROR_MODIFIABLE_COLLECTION);
104     } catch (UnsupportedOperationException e) {
105       addEdge(N2, N3, E23);
106       assertThat(network.adjacentEdges(E12)).containsExactlyElementsIn(adjacentEdges);
107     }
108   }
109 
110   @Override
111   @Test
edgesConnecting_checkReturnedSetMutability()112   public void edgesConnecting_checkReturnedSetMutability() {
113     addNode(N1);
114     addNode(N2);
115     Set<String> edgesConnecting = network.edgesConnecting(N1, N2);
116     assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23));
117     addEdge(N1, N2, E12);
118     assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
119   }
120 
121   @Override
122   @Test
inEdges_checkReturnedSetMutability()123   public void inEdges_checkReturnedSetMutability() {
124     addNode(N2);
125     Set<String> inEdges = network.inEdges(N2);
126     assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12));
127     addEdge(N1, N2, E12);
128     assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
129   }
130 
131   @Override
132   @Test
outEdges_checkReturnedSetMutability()133   public void outEdges_checkReturnedSetMutability() {
134     addNode(N1);
135     Set<String> outEdges = network.outEdges(N1);
136     assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12));
137     addEdge(N1, N2, E12);
138     assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
139   }
140 
141   @Override
142   @Test
predecessors_checkReturnedSetMutability()143   public void predecessors_checkReturnedSetMutability() {
144     addNode(N2);
145     Set<Integer> predecessors = network.predecessors(N2);
146     assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
147     addEdge(N1, N2, E12);
148     assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
149   }
150 
151   @Override
152   @Test
successors_checkReturnedSetMutability()153   public void successors_checkReturnedSetMutability() {
154     addNode(N1);
155     Set<Integer> successors = network.successors(N1);
156     assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
157     addEdge(N1, N2, E12);
158     assertThat(network.successors(N1)).containsExactlyElementsIn(successors);
159   }
160 
161   @Test
edges_containsOrderMismatch()162   public void edges_containsOrderMismatch() {
163     addEdge(N1, N2, E12);
164     assertThat(network.asGraph().edges()).doesNotContain(ENDPOINTS_N2N1);
165     assertThat(network.asGraph().edges()).doesNotContain(ENDPOINTS_N1N2);
166   }
167 
168   @Test
edgesConnecting_orderMismatch()169   public void edgesConnecting_orderMismatch() {
170     addEdge(N1, N2, E12);
171     IllegalArgumentException e =
172         assertThrows(
173             IllegalArgumentException.class,
174             () -> {
175               Set<String> unused = network.edgesConnecting(ENDPOINTS_N1N2);
176             });
177     assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
178   }
179 
180   @Test
edgeConnectingOrNull_orderMismatch()181   public void edgeConnectingOrNull_orderMismatch() {
182     addEdge(N1, N2, E12);
183     IllegalArgumentException e =
184         assertThrows(
185             IllegalArgumentException.class,
186             () -> {
187               String unused = network.edgeConnectingOrNull(ENDPOINTS_N1N2);
188             });
189     assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
190   }
191 
192   @Test
edgesConnecting_oneEdge()193   public void edgesConnecting_oneEdge() {
194     addEdge(N1, N2, E12);
195     assertThat(network.edgesConnecting(N1, N2)).containsExactly(E12);
196     assertThat(network.edgesConnecting(N2, N1)).containsExactly(E12);
197   }
198 
199   @Test
inEdges_oneEdge()200   public void inEdges_oneEdge() {
201     addEdge(N1, N2, E12);
202     assertThat(network.inEdges(N2)).containsExactly(E12);
203     assertThat(network.inEdges(N1)).containsExactly(E12);
204   }
205 
206   @Test
outEdges_oneEdge()207   public void outEdges_oneEdge() {
208     addEdge(N1, N2, E12);
209     assertThat(network.outEdges(N2)).containsExactly(E12);
210     assertThat(network.outEdges(N1)).containsExactly(E12);
211   }
212 
213   @Test
predecessors_oneEdge()214   public void predecessors_oneEdge() {
215     addEdge(N1, N2, E12);
216     assertThat(network.predecessors(N2)).containsExactly(N1);
217     assertThat(network.predecessors(N1)).containsExactly(N2);
218   }
219 
220   @Test
successors_oneEdge()221   public void successors_oneEdge() {
222     addEdge(N1, N2, E12);
223     assertThat(network.successors(N1)).containsExactly(N2);
224     assertThat(network.successors(N2)).containsExactly(N1);
225   }
226 
227   @Test
inDegree_oneEdge()228   public void inDegree_oneEdge() {
229     addEdge(N1, N2, E12);
230     assertThat(network.inDegree(N2)).isEqualTo(1);
231     assertThat(network.inDegree(N1)).isEqualTo(1);
232   }
233 
234   @Test
outDegree_oneEdge()235   public void outDegree_oneEdge() {
236     addEdge(N1, N2, E12);
237     assertThat(network.outDegree(N1)).isEqualTo(1);
238     assertThat(network.outDegree(N2)).isEqualTo(1);
239   }
240 
241   @Test
edges_selfLoop()242   public void edges_selfLoop() {
243     assume().that(network.allowsSelfLoops()).isTrue();
244 
245     addEdge(N1, N1, E11);
246     assertThat(network.edges()).containsExactly(E11);
247   }
248 
249   @Test
incidentEdges_selfLoop()250   public void incidentEdges_selfLoop() {
251     assume().that(network.allowsSelfLoops()).isTrue();
252 
253     addEdge(N1, N1, E11);
254     assertThat(network.incidentEdges(N1)).containsExactly(E11);
255   }
256 
257   @Test
incidentNodes_selfLoop()258   public void incidentNodes_selfLoop() {
259     assume().that(network.allowsSelfLoops()).isTrue();
260 
261     addEdge(N1, N1, E11);
262     assertThat(network.incidentNodes(E11).nodeU()).isEqualTo(N1);
263     assertThat(network.incidentNodes(E11).nodeV()).isEqualTo(N1);
264   }
265 
266   @Test
adjacentNodes_selfLoop()267   public void adjacentNodes_selfLoop() {
268     assume().that(network.allowsSelfLoops()).isTrue();
269 
270     addEdge(N1, N1, E11);
271     addEdge(N1, N2, E12);
272     assertThat(network.adjacentNodes(N1)).containsExactly(N1, N2);
273   }
274 
275   @Test
adjacentEdges_selfLoop()276   public void adjacentEdges_selfLoop() {
277     assume().that(network.allowsSelfLoops()).isTrue();
278 
279     addEdge(N1, N1, E11);
280     addEdge(N1, N2, E12);
281     assertThat(network.adjacentEdges(E11)).containsExactly(E12);
282   }
283 
284   @Test
edgesConnecting_selfLoop()285   public void edgesConnecting_selfLoop() {
286     assume().that(network.allowsSelfLoops()).isTrue();
287 
288     addEdge(N1, N1, E11);
289     assertThat(network.edgesConnecting(N1, N1)).containsExactly(E11);
290     addEdge(N1, N2, E12);
291     assertThat(network.edgesConnecting(N1, N2)).containsExactly(E12);
292     assertThat(network.edgesConnecting(N2, N1)).containsExactly(E12);
293     assertThat(network.edgesConnecting(N1, N1)).containsExactly(E11);
294   }
295 
296   @Test
inEdges_selfLoop()297   public void inEdges_selfLoop() {
298     assume().that(network.allowsSelfLoops()).isTrue();
299 
300     addEdge(N1, N1, E11);
301     assertThat(network.inEdges(N1)).containsExactly(E11);
302     addEdge(N1, N2, E12);
303     assertThat(network.inEdges(N1)).containsExactly(E11, E12);
304   }
305 
306   @Test
outEdges_selfLoop()307   public void outEdges_selfLoop() {
308     assume().that(network.allowsSelfLoops()).isTrue();
309 
310     addEdge(N1, N1, E11);
311     assertThat(network.outEdges(N1)).containsExactly(E11);
312     addEdge(N2, N1, E12);
313     assertThat(network.outEdges(N1)).containsExactly(E11, E12);
314   }
315 
316   @Test
predecessors_selfLoop()317   public void predecessors_selfLoop() {
318     assume().that(network.allowsSelfLoops()).isTrue();
319 
320     addEdge(N1, N1, E11);
321     assertThat(network.predecessors(N1)).containsExactly(N1);
322     addEdge(N1, N2, E12);
323     assertThat(network.predecessors(N1)).containsExactly(N1, N2);
324   }
325 
326   @Test
successors_selfLoop()327   public void successors_selfLoop() {
328     assume().that(network.allowsSelfLoops()).isTrue();
329 
330     addEdge(N1, N1, E11);
331     assertThat(network.successors(N1)).containsExactly(N1);
332     addEdge(N2, N1, E12);
333     assertThat(network.successors(N1)).containsExactly(N1, N2);
334   }
335 
336   @Test
degree_selfLoop()337   public void degree_selfLoop() {
338     assume().that(network.allowsSelfLoops()).isTrue();
339 
340     addEdge(N1, N1, E11);
341     assertThat(network.degree(N1)).isEqualTo(2);
342     addEdge(N1, N2, E12);
343     assertThat(network.degree(N1)).isEqualTo(3);
344   }
345 
346   @Test
inDegree_selfLoop()347   public void inDegree_selfLoop() {
348     assume().that(network.allowsSelfLoops()).isTrue();
349 
350     addEdge(N1, N1, E11);
351     assertThat(network.inDegree(N1)).isEqualTo(2);
352     addEdge(N1, N2, E12);
353     assertThat(network.inDegree(N1)).isEqualTo(3);
354   }
355 
356   @Test
outDegree_selfLoop()357   public void outDegree_selfLoop() {
358     assume().that(network.allowsSelfLoops()).isTrue();
359 
360     addEdge(N1, N1, E11);
361     assertThat(network.outDegree(N1)).isEqualTo(2);
362     addEdge(N2, N1, E12);
363     assertThat(network.outDegree(N1)).isEqualTo(3);
364   }
365 
366   // Element Mutation
367 
368   @Test
addEdge_existingNodes()369   public void addEdge_existingNodes() {
370     assume().that(graphIsMutable()).isTrue();
371 
372     // Adding nodes initially for safety (insulating from possible future
373     // modifications to proxy methods)
374     addNode(N1);
375     addNode(N2);
376     assertThat(networkAsMutableNetwork.addEdge(N1, N2, E12)).isTrue();
377     assertThat(network.edges()).contains(E12);
378     assertThat(network.edgesConnecting(N1, N2)).containsExactly(E12);
379     assertThat(network.edgesConnecting(N2, N1)).containsExactly(E12);
380   }
381 
382   @Test
addEdge_existingEdgeBetweenSameNodes()383   public void addEdge_existingEdgeBetweenSameNodes() {
384     assume().that(graphIsMutable()).isTrue();
385 
386     assertThat(networkAsMutableNetwork.addEdge(N1, N2, E12)).isTrue();
387     ImmutableSet<String> edges = ImmutableSet.copyOf(network.edges());
388     assertThat(networkAsMutableNetwork.addEdge(N1, N2, E12)).isFalse();
389     assertThat(network.edges()).containsExactlyElementsIn(edges);
390     assertThat(networkAsMutableNetwork.addEdge(N2, N1, E12)).isFalse();
391     assertThat(network.edges()).containsExactlyElementsIn(edges);
392   }
393 
394   @Test
addEdge_existingEdgeBetweenDifferentNodes()395   public void addEdge_existingEdgeBetweenDifferentNodes() {
396     assume().that(graphIsMutable()).isTrue();
397 
398     addEdge(N1, N2, E12);
399     IllegalArgumentException e =
400         assertThrows(
401             IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N4, N5, E12));
402     assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
403   }
404 
405   @Test
addEdge_parallelEdge_notAllowed()406   public void addEdge_parallelEdge_notAllowed() {
407     assume().that(graphIsMutable()).isTrue();
408     assume().that(network.allowsParallelEdges()).isFalse();
409 
410     addEdge(N1, N2, E12);
411     IllegalArgumentException e =
412         assertThrows(
413             IllegalArgumentException.class,
414             () -> networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH));
415     assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
416     e =
417         assertThrows(
418             IllegalArgumentException.class,
419             () -> networkAsMutableNetwork.addEdge(N2, N1, EDGE_NOT_IN_GRAPH));
420     assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
421   }
422 
423   @Test
addEdge_parallelEdge_allowsParallelEdges()424   public void addEdge_parallelEdge_allowsParallelEdges() {
425     assume().that(graphIsMutable()).isTrue();
426     assume().that(network.allowsParallelEdges()).isTrue();
427 
428     assertTrue(networkAsMutableNetwork.addEdge(N1, N2, E12));
429     assertTrue(networkAsMutableNetwork.addEdge(N2, N1, E21));
430     assertTrue(networkAsMutableNetwork.addEdge(N1, N2, E12_A));
431     assertThat(network.edgesConnecting(N1, N2)).containsExactly(E12, E12_A, E21);
432   }
433 
434   @Test
addEdge_orderMismatch()435   public void addEdge_orderMismatch() {
436     assume().that(graphIsMutable()).isTrue();
437 
438     EndpointPair<Integer> endpoints = EndpointPair.ordered(N1, N2);
439     IllegalArgumentException e =
440         assertThrows(
441             IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(endpoints, E12));
442     assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
443   }
444 
445   @Test
addEdge_selfLoop_notAllowed()446   public void addEdge_selfLoop_notAllowed() {
447     assume().that(graphIsMutable()).isTrue();
448     assume().that(network.allowsSelfLoops()).isFalse();
449 
450     IllegalArgumentException e =
451         assertThrows(
452             IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E11));
453     assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
454   }
455 
456   /**
457    * This test checks an implementation dependent feature. It tests that the method {@code addEdge}
458    * will silently add the missing nodes to the graph, then add the edge connecting them. We are not
459    * using the proxy methods here as we want to test {@code addEdge} when the end-points are not
460    * elements of the graph.
461    */
462   @Test
addEdge_nodesNotInGraph()463   public void addEdge_nodesNotInGraph() {
464     assume().that(graphIsMutable()).isTrue();
465 
466     networkAsMutableNetwork.addNode(N1);
467     assertTrue(networkAsMutableNetwork.addEdge(N1, N5, E15));
468     assertTrue(networkAsMutableNetwork.addEdge(N4, N1, E41));
469     assertTrue(networkAsMutableNetwork.addEdge(N2, N3, E23));
470     assertThat(network.nodes()).containsExactly(N1, N5, N4, N2, N3);
471     assertThat(network.edges()).containsExactly(E15, E41, E23);
472     assertThat(network.edgesConnecting(N1, N5)).containsExactly(E15);
473     assertThat(network.edgesConnecting(N4, N1)).containsExactly(E41);
474     assertThat(network.edgesConnecting(N2, N3)).containsExactly(E23);
475     assertThat(network.edgesConnecting(N3, N2)).containsExactly(E23);
476   }
477 
478   @Test
addEdge_selfLoop()479   public void addEdge_selfLoop() {
480     assume().that(graphIsMutable()).isTrue();
481     assume().that(network.allowsSelfLoops()).isTrue();
482 
483     assertThat(networkAsMutableNetwork.addEdge(N1, N1, E11)).isTrue();
484     assertThat(network.edges()).contains(E11);
485     assertThat(network.edgesConnecting(N1, N1)).containsExactly(E11);
486   }
487 
488   @Test
addEdge_existingSelfLoopEdgeBetweenSameNodes()489   public void addEdge_existingSelfLoopEdgeBetweenSameNodes() {
490     assume().that(graphIsMutable()).isTrue();
491     assume().that(network.allowsSelfLoops()).isTrue();
492 
493     addEdge(N1, N1, E11);
494     ImmutableSet<String> edges = ImmutableSet.copyOf(network.edges());
495     assertThat(networkAsMutableNetwork.addEdge(N1, N1, E11)).isFalse();
496     assertThat(network.edges()).containsExactlyElementsIn(edges);
497   }
498 
499   @Test
addEdge_existingEdgeBetweenDifferentNodes_selfLoops()500   public void addEdge_existingEdgeBetweenDifferentNodes_selfLoops() {
501     assume().that(graphIsMutable()).isTrue();
502     assume().that(network.allowsSelfLoops()).isTrue();
503 
504     addEdge(N1, N1, E11);
505     IllegalArgumentException e =
506         assertThrows(
507             IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N2, E11));
508     assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
509     e =
510         assertThrows(
511             IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N2, N2, E11));
512     assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
513     addEdge(N1, N2, E12);
514     e =
515         assertThrows(
516             IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E12));
517     assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
518   }
519 
520   @Test
addEdge_parallelSelfLoopEdge_notAllowed()521   public void addEdge_parallelSelfLoopEdge_notAllowed() {
522     assume().that(graphIsMutable()).isTrue();
523     assume().that(network.allowsSelfLoops()).isTrue();
524     assume().that(network.allowsParallelEdges()).isFalse();
525 
526     addEdge(N1, N1, E11);
527     IllegalArgumentException e =
528         assertThrows(
529             IllegalArgumentException.class,
530             () -> networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH));
531     assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
532   }
533 
534   @Test
addEdge_parallelSelfLoopEdge_allowsParallelEdges()535   public void addEdge_parallelSelfLoopEdge_allowsParallelEdges() {
536     assume().that(graphIsMutable()).isTrue();
537     assume().that(network.allowsSelfLoops()).isTrue();
538     assume().that(network.allowsParallelEdges()).isTrue();
539 
540     assertTrue(networkAsMutableNetwork.addEdge(N1, N1, E11));
541     assertTrue(networkAsMutableNetwork.addEdge(N1, N1, E11_A));
542     assertThat(network.edgesConnecting(N1, N1)).containsExactly(E11, E11_A);
543   }
544 
545   @Test
removeNode_existingNodeWithSelfLoopEdge()546   public void removeNode_existingNodeWithSelfLoopEdge() {
547     assume().that(graphIsMutable()).isTrue();
548     assume().that(network.allowsSelfLoops()).isTrue();
549 
550     addNode(N1);
551     addEdge(N1, N1, E11);
552     assertThat(networkAsMutableNetwork.removeNode(N1)).isTrue();
553     assertThat(network.nodes()).isEmpty();
554     assertThat(network.edges()).doesNotContain(E11);
555   }
556 
557   @Test
removeEdge_existingSelfLoopEdge()558   public void removeEdge_existingSelfLoopEdge() {
559     assume().that(graphIsMutable()).isTrue();
560     assume().that(network.allowsSelfLoops()).isTrue();
561 
562     addEdge(N1, N1, E11);
563     assertThat(networkAsMutableNetwork.removeEdge(E11)).isTrue();
564     assertThat(network.edges()).doesNotContain(E11);
565     assertThat(network.edgesConnecting(N1, N1)).isEmpty();
566   }
567 }
568