diff --git a/lib/exstreme/stream_graph.ex b/lib/exstreme/stream_graph.ex index 31211d7..14fb9b4 100644 --- a/lib/exstreme/stream_graph.ex +++ b/lib/exstreme/stream_graph.ex @@ -2,7 +2,7 @@ defmodule Exstreme.StreamGraph do @moduledoc """ """ defmodule Graph do - defstruct params: [], nodes: %{}, connections: [] + defstruct params: [], nodes: %{}, connections: %{} end @doc """ @@ -49,7 +49,7 @@ defmodule Exstreme.StreamGraph do defp store_connection_fn(start, finish) do fn(connections) -> add_connection = fn(keywords, start, finish) -> - Keyword.update(keywords, start, finish, fn(value)-> + Map.update(keywords, start, finish, fn(value)-> if is_list(value) do [finish | value] else @@ -107,7 +107,7 @@ defmodule Exstreme.StreamGraph do defp validate_position_start(connections, node, msg) do exist = connections - |> Keyword.has_key?(node) + |> Map.has_key?(node) if exist do raise ArgumentError, message: msg else @@ -118,7 +118,7 @@ defmodule Exstreme.StreamGraph do defp validate_position_end(connections, node, msg) do exist = connections - |> Keyword.values + |> Map.values |> Enum.member?(node) if exist do raise ArgumentError, message: msg diff --git a/test/exstreme/stream_graph_test.exs b/test/exstreme/stream_graph_test.exs index ddeaf9b..e7f7526 100644 --- a/test/exstreme/stream_graph_test.exs +++ b/test/exstreme/stream_graph_test.exs @@ -18,7 +18,7 @@ defmodule Exstreme.StreamGraphTest do test "creates a valid graph struct" do compare_graph = %Graph{ nodes: %{n1: [], n2: []}, - connections: [{:n1, :n2}] + connections: %{n1: :n2} } assert create_graph == compare_graph end @@ -47,7 +47,7 @@ defmodule Exstreme.StreamGraphTest do test "can create n3 and add a relation between n2 and n3" do compare_graph = %Graph{ nodes: %{n1: [], n2: [], n3: []}, - connections: [{:n1, :n2}, {:n2, :n3}] + connections: %{n1: :n2, n2: :n3} } new_graph = @@ -62,7 +62,7 @@ defmodule Exstreme.StreamGraphTest do test "can add a broadcast an many nodes to the broadcast" do compare_graph = %Graph{ nodes: %{n1: [], n2: [], b1: [], n3: [], n4: []}, - connections: [{:n1, :n2}, {:n2, :b1}, {:b1, [:n4, :n3]}] + connections: %{n1: :n2, n2: :b1, b1: [:n4, :n3]} } new_graph = @@ -83,7 +83,7 @@ defmodule Exstreme.StreamGraphTest do test "can add a funnel" do compare_graph = %Graph{ nodes: %{n1: [], n2: [], b1: [], n3: [], n4: [], f1: [], n5: []}, - connections: [{:n1, :n2}, {:n2, :b1}, {:b1, [:n4, :n3]}, {:n3, :f1}, {:n4, :f1}, {:f1, :n5}] + connections: %{n1: :n2, n2: :b1, b1: [:n4, :n3], n3: :f1, n4: :f1, f1: :n5} } new_graph =