Skip to content

Commit ccb4737

Browse files
committed
add spec for connected components
1 parent b89941d commit ccb4737

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

‎connected_components/spec.rb‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require'minitest/autorun'
2+
3+
require_relative'graph'
4+
require_relative'node'
5+
require_relative'connected_components'
6+
7+
describeConnectedComponentdo
8+
beforedo
9+
@node1=Node.new("Node #1")
10+
@node2=Node.new("Node #2")
11+
@node3=Node.new("Node #3")
12+
@node4=Node.new("Node #4")
13+
@node5=Node.new("Node #5")
14+
15+
@graph=Graph.new
16+
17+
@graph.nodes=[@node1,@node2,@node3,@node4,@node5]
18+
end
19+
20+
it'finds the connected components'do
21+
@graph.add_edge(@node1,@node2)
22+
@graph.add_edge(@node3,@node4)
23+
24+
connected_components=ConnectedComponent.new(@graph).connected_components.values
25+
connected_components.must_include[@node1,@node2]
26+
connected_components.must_include[@node3,@node4]
27+
connected_components.must_include[@node5]
28+
end
29+
end

‎connected_components/test.rb‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
(0)