Skip to content

Commit 7c4492a

Browse files
Saatvik RaosaatvikraoIITGN
authored andcommitted
added edge test cases
1 parent 3ffbec1 commit 7c4492a

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

src/sage/graphs/orientations.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,52 @@ def acyclic_orientations(G):
8080
sage: len(list(it))
8181
54
8282
83+
Test for arbitary vertex labels::
84+
85+
sage: g_str = Graph([('abc', 'def'), ('ghi', 'def'), ('xyz', 'abc'), ('xyz', 'uvw'), ('uvw', 'abc'), ('uvw', 'ghi')])
86+
sage: it = g_str.acyclic_orientations()
87+
sage: len(list(it))
88+
42
89+
8390
TESTS:
8491
92+
To count the number of acyclic orientations for a graph with 0 vertices::
93+
94+
sage: list(Graph().acyclic_orientations())
95+
[Graph on 0 vertices]
96+
97+
To count the number of acyclic orientations for a graph with 1 vertex::
98+
99+
sage: list(Graph(1).acyclic_orientations())
100+
[Graph on 0 vertices]
101+
102+
To count the number of acyclic orientations for a graph with 2 vertices::
103+
104+
sage: list(Graph(2).acyclic_orientations())
105+
[Graph on 0 vertices]
106+
85107
Acyclic orientations of a complete graph::
86108
87109
sage: g = graphs.CompleteGraph(5)
88110
sage: it = g.acyclic_orientations()
89111
sage: len(list(it))
90112
120
91113
92-
Test for arbitary vertex labels::
114+
Graph with one edge::
115+
116+
sage: list(Graph([(0, 1)]).acyclic_orientations())
117+
[Graph on 2 vertices, Graph on 2 vertices]
118+
119+
Graph with two edges::
120+
121+
sage: len(list(Graph([(0, 1), (1, 2)]).acyclic_orientations()))
122+
4
123+
124+
Cycle graph::
125+
126+
sage: len(list(Graph([(0, 1), (1, 2), (2, 0)]).acyclic_orientations()))
127+
6
93128
94-
sage: g_str = Graph([('abc', 'def'), ('ghi', 'def'), ('xyz', 'abc'), ('xyz', 'uvw'), ('uvw', 'abc'), ('uvw', 'ghi')])
95-
sage: it = g_str.acyclic_orientations()
96-
sage: len(list(it))
97-
42
98129
"""
99130
from sage.rings.infinity import Infinity
100131
from sage.combinat.subset import Subsets

0 commit comments

Comments
 (0)