diff --git a/test/reducer_test.exs b/test/reducer_test.exs index 3de669e..fbcf820 100644 --- a/test/reducer_test.exs +++ b/test/reducer_test.exs @@ -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])