spec/undirected_graph_spec.rb in graphshaper-0.0.2 vs spec/undirected_graph_spec.rb in graphshaper-0.1
- old
+ new
@@ -15,10 +15,18 @@
graph.add_edge 1,3
graph.add_edge 2,3
edge_creation_logger.string.should ==("1,3\n2,3\n")
end
+ it "should create a graph with a logger for vertex creation" do
+ vertex_creation_logger = StringIO.new
+ graph = Graphshaper::UndirectedGraph.new 5, vertex_creation_logger: vertex_creation_logger
+
+ graph.add_vertex
+ vertex_creation_logger.string.should ==("0\n1\n2\n3\n4\n5\n")
+ end
+
describe "initialized graph" do
before :each do
@graph = Graphshaper::UndirectedGraph.new 5
end
@@ -99,18 +107,18 @@
@graph = Graphshaper::UndirectedGraph.new 5
end
it "should calculate the degree of 0 for every vertex in a graph without edges" do
5.times do |vertex_id|
- @graph.calculate_vertex_degree_for(vertex_id).should ==0
+ @graph.vertex_degree_for(vertex_id).should ==0
end
end
it "should calculate the degree for a vertex with two edges" do
@graph.add_edge 0,1
@graph.add_edge 1,2
- @graph.calculate_vertex_degree_for(1).should ==2
+ @graph.vertex_degree_for(1).should ==2
end
it "should calculate the sum of all degrees" do
@graph.add_edge 0,1
@graph.add_edge 1,2
@@ -145,15 +153,15 @@
end
it "should add a vertex to the graph with edges according to preferential attachment" do
@graph.add_edge 0,1
- # Two nodes with preferential_attachment of 0.5, all others with 0
+ # Two vertices with preferential_attachment of 0.5, all others with 0
@graph.add_vertex do |preferential_attachment|
preferential_attachment > 0.4
end
- # One more node
+ # One more vertex
@graph.order.should ==(6)
# Two additional edges
@graph.size.should ==(3)
end
\ No newline at end of file