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

Method addEdge

corpus/java/training/guava/graph/Graphs.java:104–121  ·  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 * returned by {@code nodes}' iterator.
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
113 Iterator<N> nodesIterator = nodes.iterator();
114 checkArgument(nodesIterator.hasNext(),
115 "'graph' is not a Hypergraph, and 'nodes' has < 1 elements: %s", nodes);
116 N node1 = nodesIterator.next();
117 N node2 = nodesIterator.hasNext() ? nodesIterator.next() : node1;
118 checkArgument(!nodesIterator.hasNext(),
119 "'graph' is not a Hypergraph, and 'nodes' has > 2 elements: %s", nodes);
120 return graph.addEdge(edge, node1, node2);
121 }
122
123 /**
124 * 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