abstract_graph 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/lib/abstract_graph/composition/uniquenamecollection/dup.rb +1 -1
- data/lib/abstract_graph/composition/uniquenamecollection/rename.rb +28 -0
- data/lib/abstract_graph/composition/uniquenamecollection.rb +1 -0
- data/lib/abstract_graph/graph/add_edge.rb +2 -2
- data/lib/abstract_graph/graph/adjacency_list.rb +28 -0
- data/lib/abstract_graph/graph/change_edge_name.rb +15 -0
- data/lib/abstract_graph/graph/change_vertex_name.rb +15 -0
- data/lib/abstract_graph/graph/dup.rb +9 -2
- data/lib/abstract_graph/graph/get_edge_name.rb +24 -0
- data/lib/abstract_graph/graph/is_adjacent.rb +20 -0
- data/lib/abstract_graph/graph/merge_vertices.rb +84 -0
- data/lib/abstract_graph/graph/split_vertex.rb +40 -0
- data/lib/abstract_graph/graph/templates/complete_bipartite_graph.rb +40 -0
- data/lib/abstract_graph/graph/templates/complete_graph.rb +25 -0
- data/lib/abstract_graph/graph/templates/cycle_graph.rb +34 -0
- data/lib/abstract_graph/graph/templates/path_graph.rb +28 -0
- data/lib/abstract_graph/graph/templates/petersen_graph.rb +36 -0
- data/lib/abstract_graph/graph/templates.rb +15 -0
- data/lib/abstract_graph/graph.rb +8 -0
- data/lib/abstract_graph/version.rb +1 -1
- data/spec/abstract_graph/composition/uniquenamecollection/rename_spec.rb +42 -0
- data/spec/abstract_graph/graph/adjacency_list_spec.rb +44 -0
- data/spec/abstract_graph/graph/change_edge_name_spec.rb +42 -0
- data/spec/abstract_graph/graph/change_vertex_name_spec.rb +40 -0
- data/spec/abstract_graph/graph/dup_spec.rb +27 -22
- data/spec/abstract_graph/graph/get_edge_name_spec.rb +38 -0
- data/spec/abstract_graph/graph/has_edge_spec.rb +17 -19
- data/spec/abstract_graph/graph/has_vertex_spec.rb +13 -15
- data/spec/abstract_graph/graph/is_adjacent_spec.rb +36 -0
- data/spec/abstract_graph/graph/merge_vertices_spec.rb +199 -0
- data/spec/abstract_graph/graph/split_vertex_spec.rb +104 -0
- data/spec/abstract_graph/graph/templates/complete_bipartite_graph_spec.rb +63 -0
- data/spec/abstract_graph/graph/templates/complete_graph_spec.rb +36 -0
- data/spec/abstract_graph/graph/templates/cycle_graph_spec.rb +36 -0
- data/spec/abstract_graph/graph/templates/path_graph_spec.rb +52 -0
- data/spec/abstract_graph/graph/templates/petersen_graph_spec.rb +34 -0
- metadata +50 -13
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module AbstractGraph
|
4
|
+
describe Graph do
|
5
|
+
|
6
|
+
describe ".cycle_graph(Integer)" do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@n = 6
|
10
|
+
@graphncycle = Graph.cycle_graph @n
|
11
|
+
@graph10cycle = Graph.cycle_graph 10
|
12
|
+
end
|
13
|
+
|
14
|
+
it "retuns an object of class Graph" do
|
15
|
+
Graph.complete_graph(1).should be_an_instance_of(Graph)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates as many vertices as the integer, named with powers of two" do
|
19
|
+
@n.times do |i|
|
20
|
+
@graphncycle.has_vertex?("v#{2**i}").should be_true
|
21
|
+
end
|
22
|
+
@graph10cycle.has_vertex?("v#{2**9}").should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "ensures each vertex is adjacent to two other vertices" do
|
26
|
+
@n.times do |i|
|
27
|
+
@graphncycle.adjacency_list("v#{2**i}").size.should eql(2)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
#TODO: Write some path specific tests
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module AbstractGraph
|
4
|
+
describe Graph do
|
5
|
+
|
6
|
+
describe ".path_graph(Integer)" do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@n = 4
|
10
|
+
@graphnpath = Graph.path_graph @n
|
11
|
+
@graph10path = Graph.path_graph 10
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns an object of class Graph" do
|
15
|
+
Graph.path_graph(1).should be_an_instance_of(Graph)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates as many vertices as the integer, named with powers of two" do
|
19
|
+
@n.times do |i|
|
20
|
+
@graphnpath.has_vertex?("v#{2**i}").should be_true
|
21
|
+
end
|
22
|
+
@graph10path.has_vertex?("v#{2**9}").should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "creates the same number as edges as integer - 1" do
|
26
|
+
adjacencies = 0
|
27
|
+
@n.times do |i|
|
28
|
+
adjacencies += @graphnpath.adjacency_list("v#{2**i}").size
|
29
|
+
end
|
30
|
+
adjacencies.should eql((@n - 1)*2)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "ensures there are two 'end' vertices" do
|
34
|
+
endVertices = 0
|
35
|
+
@n.times do |i|
|
36
|
+
endVertices += 1 if @graphnpath.adjacency_list("v#{2**i}").size == 1
|
37
|
+
end
|
38
|
+
endVertices.should eql(2)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "ensures there are integer - 2 vertices with adjacency two" do
|
42
|
+
connectorVertices = 0
|
43
|
+
@n.times do |i|
|
44
|
+
connectorVertices += 1 if @graphnpath.adjacency_list("v#{2**i}").size == 2
|
45
|
+
end
|
46
|
+
connectorVertices.should eql(@n - 2)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module AbstractGraph
|
4
|
+
describe Graph do
|
5
|
+
|
6
|
+
describe ".petersen_graph" do
|
7
|
+
|
8
|
+
before :all do
|
9
|
+
@graphpetersen = Graph.petersen_graph
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns an object of class Graph" do
|
13
|
+
@graphpetersen.should be_an_instance_of(Graph)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "contains 10 vertices and 15 edges" do
|
17
|
+
adjacencies = 0
|
18
|
+
(0..9).each do |i|
|
19
|
+
@graphpetersen.has_vertex?("v#{2**i}").should be_true
|
20
|
+
adjacencies += @graphpetersen.adjacency_list("v#{2**i}").size
|
21
|
+
end
|
22
|
+
adjacencies.should eql(15 * 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "ensures each vertex has degree 3" do
|
26
|
+
(0..9).each do |i|
|
27
|
+
@graphpetersen.adjacency_list("v#{2**i}").size.should eql(3)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstract_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Austin Lee ~D4L
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-07-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,13 +20,13 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '2.5'
|
30
|
-
description:
|
31
|
-
|
27
|
+
description: |-
|
28
|
+
Abstract Graph is a graphing library that can create
|
29
|
+
mathematical graphs and perform operatations on them.
|
32
30
|
email:
|
33
31
|
- Austin.Lee.D4L@gmail.com
|
34
32
|
executables: []
|
@@ -52,18 +50,32 @@ files:
|
|
52
50
|
- lib/abstract_graph/composition/uniquenamecollection/initialize.rb
|
53
51
|
- lib/abstract_graph/composition/uniquenamecollection/link.rb
|
54
52
|
- lib/abstract_graph/composition/uniquenamecollection/method_missing.rb
|
53
|
+
- lib/abstract_graph/composition/uniquenamecollection/rename.rb
|
55
54
|
- lib/abstract_graph/composition/vertex.rb
|
56
55
|
- lib/abstract_graph/composition/vertex/delete.rb
|
57
56
|
- lib/abstract_graph/composition/vertex/initialize.rb
|
58
57
|
- lib/abstract_graph/graph.rb
|
59
58
|
- lib/abstract_graph/graph/add_edge.rb
|
60
59
|
- lib/abstract_graph/graph/add_vertex.rb
|
60
|
+
- lib/abstract_graph/graph/adjacency_list.rb
|
61
|
+
- lib/abstract_graph/graph/change_edge_name.rb
|
62
|
+
- lib/abstract_graph/graph/change_vertex_name.rb
|
61
63
|
- lib/abstract_graph/graph/delete_edge.rb
|
62
64
|
- lib/abstract_graph/graph/delete_vertex.rb
|
63
65
|
- lib/abstract_graph/graph/dup.rb
|
66
|
+
- lib/abstract_graph/graph/get_edge_name.rb
|
64
67
|
- lib/abstract_graph/graph/has_edge.rb
|
65
68
|
- lib/abstract_graph/graph/has_vertex.rb
|
66
69
|
- lib/abstract_graph/graph/initialize.rb
|
70
|
+
- lib/abstract_graph/graph/is_adjacent.rb
|
71
|
+
- lib/abstract_graph/graph/merge_vertices.rb
|
72
|
+
- lib/abstract_graph/graph/split_vertex.rb
|
73
|
+
- lib/abstract_graph/graph/templates.rb
|
74
|
+
- lib/abstract_graph/graph/templates/complete_bipartite_graph.rb
|
75
|
+
- lib/abstract_graph/graph/templates/complete_graph.rb
|
76
|
+
- lib/abstract_graph/graph/templates/cycle_graph.rb
|
77
|
+
- lib/abstract_graph/graph/templates/path_graph.rb
|
78
|
+
- lib/abstract_graph/graph/templates/petersen_graph.rb
|
67
79
|
- lib/abstract_graph/version.rb
|
68
80
|
- spec/abstract_graph/composition/edge/initialize_spec.rb
|
69
81
|
- spec/abstract_graph/composition/edge/is_coincident_spec.rb
|
@@ -75,6 +87,7 @@ files:
|
|
75
87
|
- spec/abstract_graph/composition/uniquenamecollection/initialize_spec.rb
|
76
88
|
- spec/abstract_graph/composition/uniquenamecollection/link_spec.rb
|
77
89
|
- spec/abstract_graph/composition/uniquenamecollection/method_missing_spec.rb
|
90
|
+
- spec/abstract_graph/composition/uniquenamecollection/rename_spec.rb
|
78
91
|
- spec/abstract_graph/composition/uniquenamecollection_spec.rb
|
79
92
|
- spec/abstract_graph/composition/vertex/delete_spec.rb
|
80
93
|
- spec/abstract_graph/composition/vertex/initialize_spec.rb
|
@@ -83,12 +96,24 @@ files:
|
|
83
96
|
- spec/abstract_graph/composition/vertex_spec.rb
|
84
97
|
- spec/abstract_graph/graph/add_edge_spec.rb
|
85
98
|
- spec/abstract_graph/graph/add_vertex_spec.rb
|
99
|
+
- spec/abstract_graph/graph/adjacency_list_spec.rb
|
100
|
+
- spec/abstract_graph/graph/change_edge_name_spec.rb
|
101
|
+
- spec/abstract_graph/graph/change_vertex_name_spec.rb
|
86
102
|
- spec/abstract_graph/graph/delete_edge_spec.rb
|
87
103
|
- spec/abstract_graph/graph/delete_vertex_spec.rb
|
88
104
|
- spec/abstract_graph/graph/dup_spec.rb
|
105
|
+
- spec/abstract_graph/graph/get_edge_name_spec.rb
|
89
106
|
- spec/abstract_graph/graph/has_edge_spec.rb
|
90
107
|
- spec/abstract_graph/graph/has_vertex_spec.rb
|
91
108
|
- spec/abstract_graph/graph/intialize_spec.rb
|
109
|
+
- spec/abstract_graph/graph/is_adjacent_spec.rb
|
110
|
+
- spec/abstract_graph/graph/merge_vertices_spec.rb
|
111
|
+
- spec/abstract_graph/graph/split_vertex_spec.rb
|
112
|
+
- spec/abstract_graph/graph/templates/complete_bipartite_graph_spec.rb
|
113
|
+
- spec/abstract_graph/graph/templates/complete_graph_spec.rb
|
114
|
+
- spec/abstract_graph/graph/templates/cycle_graph_spec.rb
|
115
|
+
- spec/abstract_graph/graph/templates/path_graph_spec.rb
|
116
|
+
- spec/abstract_graph/graph/templates/petersen_graph_spec.rb
|
92
117
|
- spec/abstract_graph/graph_spec.rb
|
93
118
|
- spec/abstract_graph_spec.rb
|
94
119
|
- spec/dummy_helper.rb
|
@@ -96,27 +121,26 @@ files:
|
|
96
121
|
homepage: https://github.com/D4L/abstractGraph
|
97
122
|
licenses:
|
98
123
|
- MIT
|
124
|
+
metadata: {}
|
99
125
|
post_install_message:
|
100
126
|
rdoc_options: []
|
101
127
|
require_paths:
|
102
128
|
- lib
|
103
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
130
|
requirements:
|
106
|
-
- -
|
131
|
+
- - '>='
|
107
132
|
- !ruby/object:Gem::Version
|
108
133
|
version: '0'
|
109
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
135
|
requirements:
|
112
|
-
- -
|
136
|
+
- - '>='
|
113
137
|
- !ruby/object:Gem::Version
|
114
138
|
version: '0'
|
115
139
|
requirements: []
|
116
140
|
rubyforge_project:
|
117
|
-
rubygems_version:
|
141
|
+
rubygems_version: 2.0.3
|
118
142
|
signing_key:
|
119
|
-
specification_version:
|
143
|
+
specification_version: 4
|
120
144
|
summary: Mathmatical graph analysis software.
|
121
145
|
test_files:
|
122
146
|
- spec/abstract_graph/composition/edge/initialize_spec.rb
|
@@ -129,6 +153,7 @@ test_files:
|
|
129
153
|
- spec/abstract_graph/composition/uniquenamecollection/initialize_spec.rb
|
130
154
|
- spec/abstract_graph/composition/uniquenamecollection/link_spec.rb
|
131
155
|
- spec/abstract_graph/composition/uniquenamecollection/method_missing_spec.rb
|
156
|
+
- spec/abstract_graph/composition/uniquenamecollection/rename_spec.rb
|
132
157
|
- spec/abstract_graph/composition/uniquenamecollection_spec.rb
|
133
158
|
- spec/abstract_graph/composition/vertex/delete_spec.rb
|
134
159
|
- spec/abstract_graph/composition/vertex/initialize_spec.rb
|
@@ -137,12 +162,24 @@ test_files:
|
|
137
162
|
- spec/abstract_graph/composition/vertex_spec.rb
|
138
163
|
- spec/abstract_graph/graph/add_edge_spec.rb
|
139
164
|
- spec/abstract_graph/graph/add_vertex_spec.rb
|
165
|
+
- spec/abstract_graph/graph/adjacency_list_spec.rb
|
166
|
+
- spec/abstract_graph/graph/change_edge_name_spec.rb
|
167
|
+
- spec/abstract_graph/graph/change_vertex_name_spec.rb
|
140
168
|
- spec/abstract_graph/graph/delete_edge_spec.rb
|
141
169
|
- spec/abstract_graph/graph/delete_vertex_spec.rb
|
142
170
|
- spec/abstract_graph/graph/dup_spec.rb
|
171
|
+
- spec/abstract_graph/graph/get_edge_name_spec.rb
|
143
172
|
- spec/abstract_graph/graph/has_edge_spec.rb
|
144
173
|
- spec/abstract_graph/graph/has_vertex_spec.rb
|
145
174
|
- spec/abstract_graph/graph/intialize_spec.rb
|
175
|
+
- spec/abstract_graph/graph/is_adjacent_spec.rb
|
176
|
+
- spec/abstract_graph/graph/merge_vertices_spec.rb
|
177
|
+
- spec/abstract_graph/graph/split_vertex_spec.rb
|
178
|
+
- spec/abstract_graph/graph/templates/complete_bipartite_graph_spec.rb
|
179
|
+
- spec/abstract_graph/graph/templates/complete_graph_spec.rb
|
180
|
+
- spec/abstract_graph/graph/templates/cycle_graph_spec.rb
|
181
|
+
- spec/abstract_graph/graph/templates/path_graph_spec.rb
|
182
|
+
- spec/abstract_graph/graph/templates/petersen_graph_spec.rb
|
146
183
|
- spec/abstract_graph/graph_spec.rb
|
147
184
|
- spec/abstract_graph_spec.rb
|
148
185
|
- spec/dummy_helper.rb
|