From acc93fc716deb2c93823a04b11ef0cb4a08d5171 Mon Sep 17 00:00:00 2001 From: Jean-Luc Geering Date: Mon, 16 Oct 2017 08:15:14 +0200 Subject: [PATCH 1/2] failing test case for preorder dft with int vertices --- test/reducer_test.exs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/reducer_test.exs b/test/reducer_test.exs index 3de669e..c9c6b95 100644 --- a/test/reducer_test.exs +++ b/test/reducer_test.exs @@ -17,6 +17,16 @@ defmodule Graph.Reducer.Test do assert ^expected = Graph.Reducers.Dfs.map(g, fn v -> v end) 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) + + assert 1 = Graph.Reducers.Dfs.map(g, fn v -> v end) |> List.first() + # NB the same applies to the preorder function + # assert 1 = Graph.preorder(g) |> List.first() + end + test "can walk a graph breadth-first" do g = Graph.new |> Graph.add_vertices([:a, :b, :c, :d, :e, :f, :g]) From 47c190b06d3a400280f46e7e8543d4f4b2d0934d Mon Sep 17 00:00:00 2001 From: Jean-Luc Geering Date: Mon, 16 Oct 2017 08:26:32 +0200 Subject: [PATCH 2/2] same issue with atoms --- test/reducer_test.exs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/reducer_test.exs b/test/reducer_test.exs index c9c6b95..fbcf820 100644 --- a/test/reducer_test.exs +++ b/test/reducer_test.exs @@ -17,14 +17,26 @@ 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) - assert 1 = Graph.Reducers.Dfs.map(g, fn v -> v end) |> List.first() + expected = [1, 8000] + assert ^expected = Graph.Reducers.Dfs.map(g, fn v -> v end) # NB the same applies to the preorder function - # assert 1 = Graph.preorder(g) |> List.first() + # assert ^expected = Graph.preorder(g) end test "can walk a graph breadth-first" do