-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add test case for bfs_search_tree_from (fixes #99)
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'test/unit' | ||
|
||
# Do not require rgl/adjacency ! | ||
require 'rgl/traversal' | ||
require 'rgl/implicit' | ||
|
||
include RGL | ||
|
||
# Cyclic graph with _n_ vertices. Need a concrete graph, that is not an AdjacencyGraph | ||
def cycle(n) | ||
RGL::ImplicitGraph.new { |g| | ||
g.vertex_iterator { |b| 0.upto(n - 1, &b) } | ||
g.adjacent_iterator { |x, b| b.call((x + 1) % n) } | ||
g.directed = true | ||
} | ||
end | ||
|
||
class TestAdjacencyNotRequired < Test::Unit::TestCase | ||
|
||
def setup | ||
@dg = cycle(4) | ||
end | ||
|
||
def test_bfs_search_tree | ||
# bfs_search_tree_from requires rgl/adjacency if not yet loaded. | ||
assert_equal("(1-2)(2-3)(3-0)", @dg.bfs_search_tree_from(1).edges.sort.join) | ||
end | ||
|
||
end |