Skip to content

Commit fb15280

Browse files
committed
#39821: use it in orientations.py
1 parent 1504dfc commit fb15280

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

src/sage/graphs/orientations.py

+3-16
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,9 @@ def _initialize_digraph(G, edges, name=None, weighted=None, sparse=None,
186186
name=name,
187187
hash_labels=hash_labels)
188188

189-
D.set_vertices(G.get_vertices())
190-
191-
attributes_to_copy = ('_assoc', '_embedding')
192-
for attr in attributes_to_copy:
193-
if hasattr(G, attr):
194-
copy_attr = {}
195-
old_attr = getattr(G, attr)
196-
if isinstance(old_attr, dict):
197-
for v, value in old_attr.items():
198-
try:
199-
copy_attr[v] = value.copy()
200-
except AttributeError:
201-
copy_attr[v] = copy(value)
202-
setattr(D, attr, copy_attr)
203-
else:
204-
setattr(D, attr, copy(old_attr))
189+
# Copy attributes '_assoc' and '_embedding' if set
190+
D._copy_attribute_from(G, '_assoc')
191+
D._copy_attribute_from(G, '_embedding')
205192

206193
return D
207194

0 commit comments

Comments
 (0)