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

Method addEdge

output/java_guava/1.4.19/Graphs.java:104–124  ·  view source on GitHub ↗

Adds edge to graph with the specified incident nodes, in the order returned by nodes' iterator.

(MutableNetwork<N, E> graph, E edge, Iterable<N> nodes)

Source from the content-addressed store, hash-verified

102 */
103
104 @CanIgnoreReturnValue
105 public static <N, E> boolean addEdge(MutableNetwork<N, E> graph, E edge, Iterable<N> nodes) {
106 checkNotNull(graph, "graph");
107 checkNotNull(edge, "edge");
108 checkNotNull(nodes, "nodes");
109 if (graph instanceof Hypergraph) {
110 return ((Hypergraph<N, E>) graph).addEdge(edge, nodes);
111 }
112 Iterator<N> nodesIterator = nodes.iterator();
113 checkArgument(
114 nodesIterator.hasNext(),
115 "'graph' is not a Hypergraph, and 'nodes' has < 1 elements: %s",
116 nodes);
117 N node1 = nodesIterator.next();
118 N node2 = nodesIterator.hasNext() ? nodesIterator.next() : node1;
119 checkArgument(
120 !nodesIterator.hasNext(),
121 "'graph' is not a Hypergraph, and 'nodes' has > 2 elements: %s",
122 nodes);
123 return graph.addEdge(edge, node1, node2);
124 }
125
126 /**
127 * Creates a mutable copy of {@code graph}, using the same nodes.

Callers 2

copyOfMethod · 0.95
mergeEdgesFromMethod · 0.95

Calls 6

addEdgeMethod · 0.65
iteratorMethod · 0.65
nextMethod · 0.65
checkNotNullMethod · 0.45
checkArgumentMethod · 0.45
hasNextMethod · 0.45

Tested by

no test coverage detected