Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/reducer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ defmodule Graph.Reducer.Test do
assert ^expected = Graph.Reducers.Dfs.map(g, fn v -> v end)
end

test "depth-first (preorder) with edge {:b, :a}" do
g = Graph.new
|> Graph.add_vertices([:b, :a])
|> Graph.add_edge(:b, :a)

expected = [:b, :a]
assert ^expected = Graph.Reducers.Dfs.map(g, fn v -> v end)
# NB the same applies to the preorder function
# assert ^expected = Graph.preorder(g)
end

test "first node of depth-first (preorder) with edge {1, 8000}" do
g = Graph.new
|> Graph.add_vertices([1, 8000])
|> Graph.add_edge(1, 8000)

expected = [1, 8000]
assert ^expected = Graph.Reducers.Dfs.map(g, fn v -> v end)
# NB the same applies to the preorder function
# assert ^expected = Graph.preorder(g)
end

test "can walk a graph breadth-first" do
g = Graph.new
|> Graph.add_vertices([:a, :b, :c, :d, :e, :f, :g])
Expand Down