Returns an unmodifiable view of edges that are parallel to edge, i.e. the set of edges that connect the same nodes in the same direction (if any). An edge is not parallel to itself. @throws UnsupportedOperationException if graph is a Hypergraph @throws IllegalArgumentExcepti
(Network<N, E> graph, Object edge)
| 83 | |
| 84 | |
| 85 | public static <N, E> Set<E> parallelEdges(Network<N, E> graph, Object edge) { |
| 86 | if (graph instanceof Hypergraph) { |
| 87 | throw new UnsupportedOperationException(); |
| 88 | } |
| 89 | Set<N> incidentNodes = graph.incidentNodes(edge); // Verifies that edge is in graph |
| 90 | if (!graph.allowsParallelEdges()) { |
| 91 | return ImmutableSet.of(); |
| 92 | } |
| 93 | Iterator<N> incidentNodesIterator = incidentNodes.iterator(); |
| 94 | N node1 = incidentNodesIterator.next(); |
| 95 | N node2 = incidentNodesIterator.hasNext() ? incidentNodesIterator.next() : node1; |
| 96 | return Sets.difference(graph.edgesConnecting(node1, node2), ImmutableSet.of(edge)); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Adds {@code edge} to {@code graph} with the specified incident {@code nodes}, in the order |
nothing calls this directly
no test coverage detected