MCPcopy
hub / github.com/networkx/networkx / edges_equal

Function edges_equal

networkx/utils/misc.py:542–620  ·  view source on GitHub ↗

Return whether edgelists are equal. Equality here means equal as Python objects. Edge data must match if included. Ordering of edges in an edgelist is not relevant; ordering of nodes in an edge is only relevant if ``directed == True``. Parameters ---------- edges1, edges2 :

(edges1, edges2, *, directed=False)

Source from the content-addressed store, hash-verified

540
541
542def edges_equal(edges1, edges2, *, directed=False):
543 """Return whether edgelists are equal.
544
545 Equality here means equal as Python objects. Edge data must match
546 if included. Ordering of edges in an edgelist is not relevant;
547 ordering of nodes in an edge is only relevant if ``directed == True``.
548
549 Parameters
550 ----------
551 edges1, edges2 : iterables of tuples
552 Each tuple can be
553 an edge tuple ``(u, v)``, or
554 an edge tuple with data `dict` s ``(u, v, d)``, or
555 an edge tuple with keys and data `dict` s ``(u, v, k, d)``.
556
557 directed : bool, optional (default=False)
558 If `True`, edgelists are treated as coming from directed
559 graphs.
560
561 Returns
562 -------
563 bool
564 `True` if edgelists are equal, `False` otherwise.
565
566 Examples
567 --------
568 >>> G1 = nx.complete_graph(3)
569 >>> G2 = nx.cycle_graph(3)
570 >>> edges_equal(G1.edges, G2.edges)
571 True
572
573 Edge order is not taken into account:
574
575 >>> G1 = nx.Graph([(0, 1), (1, 2)])
576 >>> G2 = nx.Graph([(1, 2), (0, 1)])
577 >>> edges_equal(G1.edges, G2.edges)
578 True
579
580 The `directed` parameter controls whether edges are treated as
581 coming from directed graphs.
582
583 >>> DG1 = nx.DiGraph([(0, 1)])
584 >>> DG2 = nx.DiGraph([(1, 0)])
585 >>> edges_equal(DG1.edges, DG2.edges, directed=False) # Not recommended.
586 True
587 >>> edges_equal(DG1.edges, DG2.edges, directed=True)
588 False
589
590 This function is meant to be used on edgelists (i.e. the output of a
591 ``G.edges()`` call), and can give unexpected results on unprocessed
592 lists of edges:
593
594 >>> l1 = [(0, 1)]
595 >>> l2 = [(0, 1), (1, 0)]
596 >>> edges_equal(l1, l2) # Not recommended.
597 False
598 >>> G1 = nx.Graph(l1)
599 >>> G2 = nx.Graph(l2)

Callers 15

test_edges_equalFunction · 0.90
test_edges_equal_dataFunction · 0.90
test_edge_lookupMethod · 0.90
test_edge_attrMethod · 0.90
test_edge_attr4Method · 0.90
test_edgesMethod · 0.90
test_degreeMethod · 0.90

Calls 1

appendMethod · 0.80

Tested by 15

test_edges_equalFunction · 0.72
test_edges_equal_dataFunction · 0.72
test_edge_lookupMethod · 0.72
test_edge_attrMethod · 0.72
test_edge_attr4Method · 0.72
test_edgesMethod · 0.72
test_degreeMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…