1 require File
.expand_path(File
.dirname(__FILE__
) + '/../spec_helper')
12 let (:g) { Graph
.new
}
13 describe
"#initialize" do
14 it
"creates an empty graph" do
16 g
.edges
.should be_empty
17 g
.vertices
.should be_empty
21 describe
"adds attribues" do
22 it
"adds then reports arbitrary attributes" do
29 it
"adds a set of vertices" do
30 g
.vertices
.should be_empty
34 g
.should
have(2).vertices
35 g
.vertices
.should
include(v1
)
36 g
.vertices
.should
include(v2
)
39 it
"adds a set of edges" do
40 g
.edges
.should be_empty
44 g
.should
have(2).edges
45 g
.edges
.should
include(e1
)
46 g
.edges
.should
include(e2
)
49 it
"adds a mixed set of vertices and edges" do
50 g
.vertices
.should be_empty
51 g
.edges
.should be_empty
56 g
<< v1
<< e1
<< v2
<< e2
57 g
.should
have(2).vertices
58 g
.vertices
.should
include(v1
)
59 g
.vertices
.should
include(v2
)
60 g
.should
have(2).edges
61 g
.edges
.should
include(e1
)
62 g
.edges
.should
include(e2
)
65 it
"adds a subclass of Vertex" do
66 g
.vertices
.should be_empty
70 g
.should
have(2).vertices
71 g
.vertices
.should
include(v1
)
72 g
.vertices
.should
include(v2
)
77 it
"adds and records an edge between vertices" do