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

Method equal

output/java_guava/1.4.17/Graphs.java:280–311  ·  view source on GitHub ↗

Returns true iff graph1 and graph2 have the same node connections. Note: Network instances can only be equal to other Network instances. In particular, Graphs that are not also Networks cannot be equal to Networks. @see Network#equals(Obje

(@Nullable Graph<?> graph1, @Nullable Graph<?> graph2)

Source from the content-addressed store, hash-verified

278
279
280 public static boolean equal(@Nullable Graph<?> graph1, @Nullable Graph<?> graph2) {
281 // If both graphs are Network instances, use equal(Network, Network) instead
282 if (graph1 instanceof Network && graph2 instanceof Network) {
283 return equal((Network<?, ?>) graph1, (Network<?, ?>) graph2);
284 }
285
286 // Otherwise, if either graph is a Network (but not both), they can't be equal.
287 if (graph1 instanceof Network || graph2 instanceof Network) {
288 return false;
289 }
290 if (graph1 == graph2) {
291 return true;
292 }
293 if (graph1 == null || graph2 == null) {
294 return false;
295 }
296 if (!graph1.nodes().equals(graph2.nodes())) {
297 return false;
298 }
299 for (Object node : graph1.nodes()) {
300 if (!graph1.successors(node).equals(graph2.successors(node))) {
301 return false;
302 }
303
304 boolean bothUndirected = !graph1.isDirected() && !graph2.isDirected();
305 if (!bothUndirected
306 && !graph1.predecessors(node).equals(graph2.predecessors(node))) {
307 return false;
308 }
309 }
310 return true;
311 }
312
313 /**
314 * Returns true iff {@code graph1} and {@code graph2} have the same node/edge relationships.

Callers 2

equalsMethod · 0.95
equalsMethod · 0.95

Calls 9

equalsMethod · 0.65
nodesMethod · 0.65
successorsMethod · 0.65
isDirectedMethod · 0.65
predecessorsMethod · 0.65
sizeMethod · 0.65
edgesMethod · 0.65
inEdgesMethod · 0.65
outEdgesMethod · 0.65

Tested by

no test coverage detected