|
5 | 5 | @test last(eulerian(g0, 1)) == 1 # a cycle
|
6 | 6 |
|
7 | 7 | # a tour (different start/end)
|
8 |
| - g1 = GenericGraph(SimpleGraph([Edge(1, 2), Edge(2, 3), Edge(3, 4)])) |
9 |
| - @test eulerian(g1, 1) == [1, 2, 3, 4] |
| 8 | + g1_3 = GenericGraph(SimpleGraph([Edge(1, 2), Edge(2, 3)])) |
| 9 | + @test eulerian(g1_3, 3) == [3, 2, 1] |
| 10 | + g1_4 = GenericGraph(SimpleGraph([Edge(1, 2), Edge(2, 3), Edge(3, 4)])) |
| 11 | + @test eulerian(g1_4, 1) == [1, 2, 3, 4] |
| 12 | + # in a graph with an Eulerian trail but not cycle, you have to start at an odd degree vertex |
10 | 13 | @test_throws ErrorException(
|
11 | 14 | "starting vertex has even degree but there are other vertices with odd degree: a eulerian cycle does not exist",
|
12 |
| - ) eulerian(g1, 2) |
| 15 | + ) eulerian(g1_3, 2) |
| 16 | + # too many odd degree vertices; Eulerian cycle does not exist |
| 17 | + # 3-pointed star with vertex 1 at the center |
| 18 | + g_star = GenericGraph(SimpleGraph([Edge(1, 2), Edge(1, 3), Edge(1, 4)])) |
| 19 | + @test_throws ErrorException( |
| 20 | + "starting vertex has odd degree but the total number of vertices of odd degree is not equal to 2: a eulerian trail does not exist", |
| 21 | + ) eulerian(g_star, 1) |
13 | 22 |
|
14 | 23 | # a cycle with a node (vertex 2) with multiple neighbors
|
15 | 24 | g2 = GenericGraph(
|
|
0 commit comments