Skip to content

Commit

Permalink
graph test added
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkaspa committed Mar 14, 2016
1 parent e4bdd1e commit 846b088
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/exstreme/graph.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ defmodule Exstreme.Graph do
@spec count_connections(t) :: non_neg_integer
def count_connections(%Graph{connections: connections}) do
connections
|> Map.keys
|> Map.values
|> List.flatten
|> Enum.count
end

Expand Down
12 changes: 12 additions & 0 deletions test/exstreme/graph_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@ defmodule Exstreme.GraphTest do
alias Exstreme.Graph
doctest Exstreme.Graph

test "graph with many nodes has 7 nodes and 7 connections" do
assert Graph.count_nodes(graph_many_nodes) == 7
assert Graph.count_connections(graph_many_nodes) == 7
end

test "connection stats for graph with many nodes" do
assert Graph.connections_stats(graph_many_nodes) == %{begin: 1, connected: 5, end: 1}
end

test "the start node is n1" do
assert Graph.find_start_node(graph_many_nodes) == [:n1]
end
end

0 comments on commit 846b088

Please sign in to comment.