Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 6cfcbb0

Browse files
committed
Avoid calling vertices() in graph_isom_equivalent_non_edge_labeled_graph()
1 parent 0cb4942 commit 6cfcbb0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/sage/graphs/generic_graph.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22811,20 +22811,25 @@ def graph_isom_equivalent_non_edge_labeled_graph(g, partition=None, standard_lab
2281122811
if inplace:
2281222812
g._backend = G._backend
2281322813
elif not inplace:
22814-
G = copy( g )
22814+
G = copy(g)
2281522815
else:
2281622816
G = g
2281722817

2281822818
G_order = G.order()
22819-
V = list(range(G_order))
22820-
if G.vertices() != V:
22821-
relabel_dict = G.relabel(return_map=True)
22819+
# Do not relabel if the set of vertices is equal to the set
22820+
# range(n). This helps to ensure that *equal* graphs on range(n)
22821+
# yield *equal* (not just isomorphic) canonical labelings. This
22822+
# is just a convenience, there is no mathematical meaning.
22823+
if set(G) != set(range(G_order)):
22824+
relabel_dict = G.relabel(return_map=True, inplace=True)
2282222825
else:
22823-
relabel_dict = dict( (i,i) for i in range(G_order) )
22826+
# Do not relabel but ensure that labels are Python ints
22827+
relabel_dict = {i: int(i) for i in G}
22828+
2282422829
if partition is None:
22825-
partition = [V]
22830+
partition = [G.vertices()]
2282622831
else:
22827-
partition = [ [ relabel_dict[i] for i in part ] for part in partition ]
22832+
partition = [[relabel_dict[i] for i in part] for part in partition]
2282822833

2282922834
if G._directed:
2283022835
edge_iter = G._backend.iterator_in_edges(G,True)

0 commit comments

Comments
 (0)