16468 | 16468 | (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5}) |
16469 | 16469 | sage: D.is_isomorphic(D,edge_labels=True, certify = True) |
16470 | 16470 | (True, {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5}) |
16474 | 16474 | sage: G1 = DiGraph([(0, 0, 'c'), (0, 4, 'b'), (0, 5, 'c'), |
16475 | 16475 | ... (0, 5, 't'), (1, 1, 'c'), (1, 3,'c'), (1, 3, 't'), (1, 5, 'b'), |
16476 | 16476 | ... (2, 2, 'c'), (2, 3, 'b'), (2, 4, 'c'),(2, 4, 't'), (3, 1, 't'), |
16485 | | |
| 16485 | |
| 16486 | Ensure that :trac:`13114` is fixed :: |
| 16487 | |
| 16488 | sage: g = Graph([(0, 0, 0), (0, 2, 0), (1, 1, 0), (1, 2, 0), (1, 2, 1), (2, 2, 0)]) |
| 16489 | sage: gg = Graph([(0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 2, 0), (2, 2, 0), (2, 2, 1)]) |
| 16490 | sage: g.is_isomorphic(gg) |
| 16491 | False |
16913 | | edge_partition = [sum(edge_partition,[])] |
| 16920 | |
| 16921 | # If there are no multiple edges, we can just say that all edges are |
| 16922 | # equivalent to each other without any further consideration. |
| 16923 | if not g_has_multiple_edges: |
| 16924 | edge_partition = [el[1] for el in sorted(edge_partition)] |
| 16925 | edge_partition = [sum(edge_partition,[])] |
| 16926 | |
| 16927 | # An edge between u and v with label l and multiplicity k being encoded |
| 16928 | # as an uv edge with label [l,k], we must not assume that an edge with |
| 16929 | # multiplicity 2 is equivalent to a simple edge ! |
| 16930 | # Hence, we still distinguish edges with different multiplicity |
| 16931 | if g_has_multiple_edges: |
| 16932 | |
| 16933 | # Compute the multiplicity the label |
| 16934 | multiplicity = lambda x : sum(map(lambda y:y[1],x)) |
| 16935 | |
| 16936 | # Sort the edge according to their multiplicity |
| 16937 | edge_partition = sorted([[multiplicity(el),part] for el, part in sorted(edge_partition)]) |
| 16938 | |
| 16939 | # Gather together the edges with same multiplicity |
| 16940 | i = 1 |
| 16941 | while i < len(edge_partition): |
| 16942 | if edge_partition[i][0] == edge_partition[i-1][0]: |
| 16943 | edge_partition[i-1][1].extend(edge_partition[i][1]) |
| 16944 | edge_partition.pop(i) |
| 16945 | else: |
| 16946 | i += 1 |
| 16947 | |
| 16948 | # now edge_partition has shape [[multiplicity, list_of_edges], |
| 16949 | # [multiplicity, liste of edges], ...], and we can flatted it to |
| 16950 | # [list of edges, list of edges, ...] |
| 16951 | edge_partition = [el[1] for el in sorted(edge_partition)] |
| 16952 | |
| 16953 | # Now the edges are partitionned according to the multiplicity they |
| 16954 | # represent, and edge labels are forgotten. |
| 16955 | |
| 16956 | else: |
| 16957 | edge_partition = [el[1] for el in sorted(edge_partition)] |
| 16958 | |