rgl 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +24 -15
- data/Gemfile +4 -1
- data/README.md +5 -3
- data/Rakefile +1 -2
- data/lib/rgl/base.rb +1 -3
- data/lib/rgl/bipartite.rb +2 -2
- data/lib/rgl/dot.rb +9 -2
- data/lib/rgl/edmonds_karp.rb +4 -4
- data/lib/rgl/graph_iterator.rb +4 -0
- data/test/components_test.rb +2 -2
- data/test/dot_test.rb +19 -10
- data/test/graph_xml_test.rb +1 -7
- data/test/test_helper.rb +2 -2
- metadata +3 -4
- data/lib/rgl/enumerable_ext.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c15acc14278cf56aa4c7bb4de7e65944a7a12fb9
|
4
|
+
data.tar.gz: 718389d3eb3cf3decb71fe37be4a33fdc17c42be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee20512b191bc19d6bf702884ac7edcd3522a71248373bb11c0ebe5821388c2245fd8fcbaecdf4c95cfb51df9ea52f6eece56e420a9b56345644f684449dd421
|
7
|
+
data.tar.gz: 4f3e57edb2a8521713bf2171a12cd4683f02e16c5b01ed8b18db25a08d5e5fe54039580c648616f395a506e1919e722852ec648cc80d0c9f6feb0a80aece7fcd
|
data/ChangeLog
CHANGED
@@ -1,50 +1,59 @@
|
|
1
|
+
2016-05 Release 0.5.3
|
2
|
+
|
3
|
+
Horst Duchene
|
4
|
+
* Issue #38: Add error handling or dot functions. (719e38, 5a3423)
|
5
|
+
Thomas Orozco
|
6
|
+
* Remove Enumerable Extension (fde8a5)
|
7
|
+
* Update to codeclimate-test-reporter 1.x (25fdb5)
|
8
|
+
Mario Daskalov
|
9
|
+
* Clarify that you need graphviz in the README (35a4b4)
|
10
|
+
|
1
11
|
2016-05 Release 0.5.2
|
2
12
|
|
3
|
-
Horst Duchene
|
13
|
+
Horst Duchene
|
4
14
|
* Issue #21: Use new method vertex_id instead of object_id to identify vertices in dot export. (fa7592)
|
5
15
|
* Integrate Code Climate's test coverage reporting (0ab722)
|
6
16
|
* Clarify traversal order of DFS search (see #20). (afa788)
|
7
|
-
Chase Gilliam
|
17
|
+
Chase Gilliam
|
8
18
|
* drop 1.9.3 add newer jruby and rubinius (fad333)
|
9
|
-
Matías Battocchia
|
19
|
+
Matías Battocchia
|
10
20
|
* Switched to a different heap implementation. (bd7c13)
|
11
|
-
gorn
|
21
|
+
gorn
|
12
22
|
* Adding failing test for issue #24 (1f6204)
|
13
23
|
|
14
24
|
2015-12 Release 0.5.1
|
15
25
|
|
16
|
-
Horst Duchene
|
26
|
+
Horst Duchene
|
17
27
|
* Changed edge sequence to match example picture (daa88e)
|
18
28
|
|
19
|
-
Chase
|
29
|
+
Chase
|
20
30
|
* updated algorithms to 6.1 and added test unit to support newer rubies (fbd874)
|
21
31
|
|
22
|
-
Louis Rose
|
32
|
+
Louis Rose
|
23
33
|
* Fix #15. Use object IDs rather than labels to identify vertexs in DOT graph
|
24
34
|
to ensure that distinct nodes that share a label are shown. (33206f, 4fc455)
|
25
35
|
|
26
36
|
2014-12 Release 0.5.0
|
27
37
|
|
28
|
-
Horst Duchene
|
38
|
+
Horst Duchene
|
29
39
|
* Changed edge sequence to match example picture (daa88e)
|
30
40
|
* Fixed comment (6a6c93)
|
31
41
|
* Fixed spelling (7ca281)
|
32
|
-
Horst Duchêne
|
33
|
-
Chase
|
42
|
+
Horst Duchêne
|
43
|
+
Chase
|
34
44
|
* updated algorithms to 6.1 and added test unit to support newer rubies (fbd874)
|
35
|
-
Louis Rose
|
45
|
+
Louis Rose
|
36
46
|
* Fix #15. Use object IDs rather than labels to identify vertexs in DOT graph to ensure that distinct nodes that share a label are shown. (33206f)
|
37
47
|
* Issue #15. Fix tests. (4fc455)
|
38
48
|
|
39
|
-
|
40
49
|
2014-12 Release 0.5.0
|
41
|
-
Horst Duchene
|
50
|
+
Horst Duchene
|
42
51
|
* Changed edge sequence to match example picture (daa88e)
|
43
52
|
* Fixed comment (6a6c93)
|
44
53
|
* Fixed spelling (7ca281)
|
45
|
-
Chase
|
54
|
+
Chase
|
46
55
|
* updated algorithms to 6.1 and added test unit to support newer rubies (fbd874)
|
47
|
-
Louis Rose
|
56
|
+
Louis Rose
|
48
57
|
* Fix #15. Use object IDs rather than labels to identify vertexs
|
49
58
|
in DOT graph to ensure that distinct nodes that share a label are
|
50
59
|
shown. (33206f)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Ruby Graph Library (RGL) [<img src="https://secure.travis-ci.org/monora/rgl.png?branch=master" alt="Build Status" />](https://travis-ci.org/monora/rgl) [<img src="https://codeclimate.com/github/monora/rgl/badges/coverage.svg" />](https://codeclimate.com/github/monora/rgl/coverage)
|
1
|
+
# Ruby Graph Library (RGL) [<img src="https://secure.travis-ci.org/monora/rgl.png?branch=master" alt="Build Status" />](https://travis-ci.org/monora/rgl) [<img src="https://codeclimate.com/github/monora/rgl/badges/coverage.svg" />](https://codeclimate.com/github/monora/rgl/coverage) [<img src="https://badge.fury.io/rb/rgl.svg" alt="Version"/>](https://badge.fury.io/rb/rgl)
|
2
2
|
|
3
3
|
RGL is a framework for graph data structures and algorithms.
|
4
4
|
|
@@ -108,6 +108,8 @@ the base module Graph. The complexity guarantees can not necessarily provided.
|
|
108
108
|
or download the latest sources from the git repository
|
109
109
|
http://github.com/monora/rgl.
|
110
110
|
|
111
|
+
If you are going to use the drawing functionalities install [Graphviz](http://www.graphviz.org/).
|
112
|
+
|
111
113
|
## Running tests
|
112
114
|
|
113
115
|
Checkout RGL git repository and go to the project directory. First, install
|
@@ -225,8 +227,8 @@ graph resources.
|
|
225
227
|
|
226
228
|
Robert kindly allowed to integrate his work on graphr, which I did not yet
|
227
229
|
succeed. Especially his work to output graphs for
|
228
|
-
[GraphViz](http://www.
|
229
|
-
|
230
|
+
[GraphViz](http://www.graphviz.org) is much more elaborated than the minimal
|
231
|
+
support in dot.rb.
|
230
232
|
|
231
233
|
Jeremy Siek one of the authors of the nice book [The Boost Graph
|
232
234
|
Library](http://www.boost.org/libs/graph/doc) kindly allowed to use the BGL
|
data/Rakefile
CHANGED
@@ -100,9 +100,8 @@ task :changelog, :since_c, :until_c do |t,args|
|
|
100
100
|
changelog_content = String.new
|
101
101
|
|
102
102
|
cmd.split("\n").each do |entry|
|
103
|
-
|
103
|
+
_, author, subject, hash = entry.chomp.split("::")
|
104
104
|
entries[author] = Array.new unless entries[author]
|
105
|
-
day = date.split(" ").first
|
106
105
|
entries[author] << "#{subject} (#{hash[0..5]})" unless subject =~ /Merge/
|
107
106
|
end
|
108
107
|
|
data/lib/rgl/base.rb
CHANGED
data/lib/rgl/bipartite.rb
CHANGED
@@ -22,7 +22,7 @@ module RGL
|
|
22
22
|
next if bfs.finished_vertex?(u)
|
23
23
|
|
24
24
|
bfs.reset_start(u)
|
25
|
-
bfs.move_forward_until {
|
25
|
+
bfs.move_forward_until { bfs.found_odd_cycle }
|
26
26
|
|
27
27
|
return if bfs.found_odd_cycle
|
28
28
|
end
|
@@ -84,4 +84,4 @@ module RGL
|
|
84
84
|
|
85
85
|
end # class BipartiteBFSIterator
|
86
86
|
|
87
|
-
end # module RGL
|
87
|
+
end # module RGL
|
data/lib/rgl/dot.rb
CHANGED
@@ -5,6 +5,9 @@
|
|
5
5
|
# Minimal Dot support, based on Dave Thomas's dot module (included in rdoc).
|
6
6
|
# rdot.rb is a modified version which also contains support for undirected
|
7
7
|
# graphs.
|
8
|
+
#
|
9
|
+
# You need to have [GraphViz](http://www.graphviz.org) installed, because the
|
10
|
+
# functions in this modul execute the GraphViz executables _dot_ or _dotty_.
|
8
11
|
|
9
12
|
require 'rgl/rdot'
|
10
13
|
|
@@ -64,7 +67,9 @@ module RGL
|
|
64
67
|
File.open(dotfile, "w") do |f|
|
65
68
|
print_dotted_on(params, f)
|
66
69
|
end
|
67
|
-
system("dotty", dotfile)
|
70
|
+
unless system("dotty", dotfile)
|
71
|
+
raise "Error executing dotty. Did you install GraphViz?"
|
72
|
+
end
|
68
73
|
end
|
69
74
|
|
70
75
|
# Use dot[http://www.graphviz.org] to create a graphical representation of
|
@@ -78,7 +83,9 @@ module RGL
|
|
78
83
|
f << self.to_dot_graph.to_s << "\n"
|
79
84
|
end
|
80
85
|
|
81
|
-
system("dot -T#{fmt} #{src} -o #{dot}")
|
86
|
+
unless system("dot -T#{fmt} #{src} -o #{dot}")
|
87
|
+
raise "Error executing dot. Did you install GraphViz?"
|
88
|
+
end
|
82
89
|
dot
|
83
90
|
end
|
84
91
|
|
data/lib/rgl/edmonds_karp.rb
CHANGED
@@ -46,9 +46,9 @@ module RGL
|
|
46
46
|
min_residual_capacity = [min_residual_capacity, @residual_capacity_map[u, v]].min
|
47
47
|
end
|
48
48
|
|
49
|
-
augmenting_path.each_cons(2) do |(
|
50
|
-
@flow_map[[
|
51
|
-
@flow_map[[
|
49
|
+
augmenting_path.each_cons(2) do |(uu, vv)|
|
50
|
+
@flow_map[[uu, vv]] += min_residual_capacity
|
51
|
+
@flow_map[[vv, uu]] -= min_residual_capacity
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -133,4 +133,4 @@ module RGL
|
|
133
133
|
|
134
134
|
end # module Graph
|
135
135
|
|
136
|
-
end
|
136
|
+
end
|
data/lib/rgl/graph_iterator.rb
CHANGED
data/test/components_test.rb
CHANGED
@@ -61,7 +61,7 @@ i -> h j e c
|
|
61
61
|
|
62
62
|
assert_equal(4, vis.num_comp)
|
63
63
|
|
64
|
-
|
64
|
+
result = vis.comp_map.to_a.sort.reduce({}) { |res, a|
|
65
65
|
if res.key?(a[1])
|
66
66
|
res[a[1]] << a[0]
|
67
67
|
else
|
@@ -70,7 +70,7 @@ i -> h j e c
|
|
70
70
|
res
|
71
71
|
}
|
72
72
|
|
73
|
-
std_res =
|
73
|
+
std_res = result.to_a.map {
|
74
74
|
|a|
|
75
75
|
[a[1][0], a[1]]
|
76
76
|
}.sort
|
data/test/dot_test.rb
CHANGED
@@ -11,17 +11,22 @@ class TestDot < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
def test_to_dot_digraph
|
13
13
|
graph = RGL::DirectedAdjacencyGraph["a", "b"]
|
14
|
-
dot = graph.to_dot_graph.to_s
|
15
14
|
|
16
|
-
|
17
|
-
|
15
|
+
begin
|
16
|
+
dot = graph.to_dot_graph.to_s
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
first_vertex_id = "a"
|
19
|
+
second_vertex_id = "b"
|
20
|
+
|
21
|
+
assert_match(dot, /\{[^}]*\}/) # {...}
|
22
|
+
assert_match(dot, /#{first_vertex_id}\s*\[/) # node 1
|
23
|
+
assert_match(dot, /label\s*=\s*a/) # node 1 label
|
24
|
+
assert_match(dot, /#{second_vertex_id}\s*\[/) # node 2
|
25
|
+
assert_match(dot, /label\s*=\s*b/) # node 2 label
|
26
|
+
assert_match(dot, /#{first_vertex_id}\s*->\s*#{second_vertex_id}/) # edge
|
27
|
+
rescue
|
28
|
+
puts "Graphviz not installed?"
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
def test_to_dot_graph
|
@@ -33,6 +38,10 @@ class TestDot < Test::Unit::TestCase
|
|
33
38
|
def graph.vertex_id(v)
|
34
39
|
"id-"+v.to_s
|
35
40
|
end
|
36
|
-
|
41
|
+
begin
|
42
|
+
graph.write_to_graphic_file
|
43
|
+
rescue
|
44
|
+
puts "Graphviz not installed?"
|
45
|
+
end
|
37
46
|
end
|
38
47
|
end
|
data/test/graph_xml_test.rb
CHANGED
@@ -31,7 +31,7 @@ class TestGraphXML < Test::Unit::TestCase
|
|
31
31
|
name, nnodes, nedges = $1, $2.to_i, $3.to_i
|
32
32
|
end
|
33
33
|
if name && /directed: (\w+).*acyclic: (\w+).*connected: (\w+).*biconnected: (\w+)\s+/ =~ line
|
34
|
-
directed, acyclic, connected
|
34
|
+
directed, acyclic, connected = $1, $2, $3
|
35
35
|
File.open(NORTH_DIR + name + '.graphml') {
|
36
36
|
|file|
|
37
37
|
print '.'; $stdout.flush
|
@@ -44,12 +44,6 @@ class TestGraphXML < Test::Unit::TestCase
|
|
44
44
|
num_comp = 0
|
45
45
|
graph.to_undirected.each_connected_component { |x| num_comp += 1 }
|
46
46
|
assert_equal(connected, (num_comp == 1).to_s)
|
47
|
-
|
48
|
-
# if graph.directed?
|
49
|
-
# num_comp = graph.strongly_connected_components.num_comp
|
50
|
-
# #puts num_comp
|
51
|
-
# assert_equal(biconnected, (num_comp == 1).to_s)
|
52
|
-
# end
|
53
47
|
}
|
54
48
|
end
|
55
49
|
}
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Horst Duchene
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire: rgl/base
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stream
|
@@ -107,7 +107,6 @@ files:
|
|
107
107
|
- lib/rgl/base.rb
|
108
108
|
- lib/rgl/dot.rb
|
109
109
|
- lib/rgl/graph_iterator.rb
|
110
|
-
- lib/rgl/enumerable_ext.rb
|
111
110
|
- lib/rgl/dijkstra_visitor.rb
|
112
111
|
- lib/rgl/mutable.rb
|
113
112
|
- lib/rgl/connected_components.rb
|
@@ -189,6 +188,7 @@ files:
|
|
189
188
|
- examples/north/g.10.2.graphml
|
190
189
|
- examples/examples.rb
|
191
190
|
- Gemfile
|
191
|
+
- README.md
|
192
192
|
- Rakefile
|
193
193
|
- rakelib/dep_graph.rake
|
194
194
|
- test/dijkstra_test.rb
|
@@ -211,7 +211,6 @@ files:
|
|
211
211
|
- test/test_helper.rb
|
212
212
|
- test/transitivity_test.rb
|
213
213
|
- test/bipartite_test.rb
|
214
|
-
- README.md
|
215
214
|
homepage: https://github.com/monora/rgl
|
216
215
|
licenses: []
|
217
216
|
metadata: {}
|
data/lib/rgl/enumerable_ext.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Enumerable
|
2
|
-
|
3
|
-
# Fixnum()
|
4
|
-
#
|
5
|
-
# Return the number of elements of the Enumerable. Same as _size_ but not all
|
6
|
-
# Enumerables implement size.
|
7
|
-
#--
|
8
|
-
# Should we call the methods _size_?
|
9
|
-
#
|
10
|
-
def length
|
11
|
-
inject(0) do |sum, v|
|
12
|
-
sum + 1
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|