Skip to content

Commit 4423049

Browse files
Saatvik RaosaatvikraoIITGN
authored andcommitted
fixed relabelling of graph before return
1 parent 1873f5e commit 4423049

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/sage/graphs/orientations.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,13 @@ def helper(G, globO, m, k):
257257
# Create a mapping between original and new vertex labels
258258
reverse_vertex_labels = {label: vertex for vertex, label in vertex_labels.items()}
259259

260-
# Iterate over acyclic orientations and relabel the vertices
260+
# Iterate over acyclic orientations and create relabeled graphs
261+
from sage.graphs.graph import Graph
261262
for orientation in orientations:
262-
relabeled_orientation = {}
263-
for (u, v), label in orientation.items():
264-
relabeled_orientation[(reverse_vertex_labels[u], reverse_vertex_labels[v])] = label
265-
266-
yield relabeled_orientation
263+
relabeled_graph = Graph([(reverse_vertex_labels[u], reverse_vertex_labels[v], label) for (u, v), label in orientation.items()])
264+
yield relabeled_graph
267265

266+
# output the orientations
268267
return orientations
269268

270269

0 commit comments

Comments
 (0)