Skip to content

Commit

Permalink
improve doctest - PR #38757
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoudert committed Oct 3, 2024
1 parent 79db26b commit 434f152
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/sage/graphs/orientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ def acyclic_orientations(G):
.. NOTE::
The function assumes that the input graph is undirected and the edges are unlabelled.
The function assumes that the input graph is undirected and the edges
are unlabelled.
EXAMPLES:
To count number acyclic orientations for a graph::
To count the number of acyclic orientations for a graph::
sage: g = Graph([(0, 3), (0, 4), (3, 4), (1, 3), (1, 2), (2, 3), (2, 4)])
sage: it = g.acyclic_orientations()
Expand All @@ -80,16 +81,20 @@ def acyclic_orientations(G):
Test for arbitrary vertex labels::
sage: g_str = Graph([('abc', 'def'), ('ghi', 'def'), ('xyz', 'abc'), ('xyz', 'uvw'), ('uvw', 'abc'), ('uvw', 'ghi')])
sage: g_str = Graph([('abc', 'def'), ('ghi', 'def'), ('xyz', 'abc'),
....: ('xyz', 'uvw'), ('uvw', 'abc'), ('uvw', 'ghi')])
sage: it = g_str.acyclic_orientations()
sage: len(list(it))
42
Check the orientation of edges::
Check that the method returns properly relabeled acyclic digraphs::
sage: g = Graph([(0, 1), (1, 2), (2, 3), (3, 0), (0, 2)])
sage: len(set([frozenset(d.edges(labels=false)) for d in g.acyclic_orientations()]))
sage: orientations = set([frozenset(d.edges(labels=false)) for d in g.acyclic_orientations()])
sage: len(orientations)
18
sage: all(d.is_directed_acyclic() for d in g.acyclic_orientations())
True
TESTS:
Expand Down

0 comments on commit 434f152

Please sign in to comment.