Skip to content

Commit

Permalink
fix^N
Browse files Browse the repository at this point in the history
  • Loading branch information
thchr committed Jun 30, 2023
1 parent fed450f commit c562fa3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/traversals/eulerian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# a tour (different start/end)
g1 = SimpleGraph([Edge(1,2), Edge(2,3), Edge(3,4)])
@test eulerian(g1, 1) == [1,2,3,4]
@test_throws ErrorException("starting vertex has even degree but there are other vertices with odd degree") eulerian(g1, 2)
@test_throws ErrorException("starting vertex has even degree but there are other vertices with odd degree: a eulerian cycle does not exist") eulerian(g1, 2)

# a cycle with a node (vertex 2) with multiple neighbors
g2 = SimpleGraph([Edge(1,2), Edge(2,3), Edge(3,4), Edge(4,1), Edge(2,5), Edge(5,6),
Expand All @@ -16,20 +16,20 @@

# graph with odd-degree vertices
g3 = SimpleGraph([Edge(1,2), Edge(2,3), Edge(3,4), Edge(2,4), Edge(4,1), Edge(4,2)])
@test_throws ErrorException("starting vertex has even degree but there are other vertices with odd degree") eulerian(g3, 1)
@test_throws ErrorException("starting vertex has even degree but there are other vertices with odd degree: a eulerian cycle does not exist") eulerian(g3, 1)

# start/end point not in graph
@test_throws ErrorException("starting vertex is not in the graph") eulerian(g3, 5)

# disconnected components
g4 = SimpleGraph([Edge(1,2), Edge(2,3), Edge(3,1), # component 1
Edge(4,5), Edge(5,6), Edge(6,4)]) # component 2
@test_throws ErrorException("graph is not connected") eulerian(g4)
@test_throws ErrorException("graph is not connected: a eulerian cycle/trail does not exist") eulerian(g4)

# zero-degree nodes
g5 = SimpleGraph(4)
add_edge!(g5, Edge(1,2)); add_edge!(g5, Edge(2,3)); add_edge!(g5, Edge(3,1))
@test_throws ErrorException("some vertices have degree zero") eulerian(g5)
@test_throws ErrorException("some vertices have degree zero (are isolated) and cannot be reached") eulerian(g5)

# not yet implemented for directed graphs
@test_broken eulerian(SimpleDiGraph([Edge(1,2), Edge(2,3), Edge(3,1)]))
Expand Down

0 comments on commit c562fa3

Please sign in to comment.