MCPcopy Index your code
hub / github.com/antlr/codebuff / oppositeNode

Method oppositeNode

output/java_guava/1.4.17/Graphs.java:60–74  ·  view source on GitHub ↗

Returns the node at the other end of edge from node. @throws UnsupportedOperationException if graph is a Hypergraph @throws IllegalArgumentException if edge is not incident to node

(Network<N, ?> graph, Object edge, Object node)

Source from the content-addressed store, hash-verified

58
59
60 public static <N> N oppositeNode(Network<N, ?> graph, Object edge, Object node) {
61 if (graph instanceof Hypergraph) {
62 throw new UnsupportedOperationException();
63 }
64 checkNotNull(node, "node");
65 Iterator<N> incidentNodesIterator = graph.incidentNodes(edge).iterator();
66 N node1 = incidentNodesIterator.next();
67 N node2 = incidentNodesIterator.hasNext() ? incidentNodesIterator.next() : node1;
68 if (node.equals(node1)) {
69 return node2;
70 } else {
71 checkArgument(node.equals(node2), "Edge %s is not incident to node %s", edge, node);
72 return node1;
73 }
74 }
75
76 /**
77 * Returns an unmodifiable view of edges that are parallel to {@code edge}, i.e. the set of edges

Callers 1

applyMethod · 0.95

Calls 7

iteratorMethod · 0.65
incidentNodesMethod · 0.65
nextMethod · 0.65
equalsMethod · 0.65
checkNotNullMethod · 0.45
hasNextMethod · 0.45
checkArgumentMethod · 0.45

Tested by

no test coverage detected