rgl 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c15acc14278cf56aa4c7bb4de7e65944a7a12fb9
4
- data.tar.gz: 718389d3eb3cf3decb71fe37be4a33fdc17c42be
2
+ SHA256:
3
+ metadata.gz: 8756a57ea9c8151eadaa993efee20e2d41ddba102bee5d4106e00c94318d328e
4
+ data.tar.gz: c2400afcdcc2d5c8f22ed0da9e48cd843629f57747335265087a7e3e892d55d0
5
5
  SHA512:
6
- metadata.gz: ee20512b191bc19d6bf702884ac7edcd3522a71248373bb11c0ebe5821388c2245fd8fcbaecdf4c95cfb51df9ea52f6eece56e420a9b56345644f684449dd421
7
- data.tar.gz: 4f3e57edb2a8521713bf2171a12cd4683f02e16c5b01ed8b18db25a08d5e5fe54039580c648616f395a506e1919e722852ec648cc80d0c9f6feb0a80aece7fcd
6
+ metadata.gz: 83cebc1a0570644f5dc1a48c16a5a38e11d73b9baf095f2627ef91676139c473f8027b608748dfe5d7df1926b17759e07dab85722fa0ced05b1656880fade8da
7
+ data.tar.gz: ad2d7ee636584a077313323efacf8c274f25643cc78e85b4f4f0e01dfbbbb522e00b7e50c295ad1e2ff395300c8f4f0551e00bb7b2a514cc179f01b9d327487e
data/ChangeLog CHANGED
@@ -1,4 +1,15 @@
1
- 2016-05 Release 0.5.3
1
+ 2019-01 Release 0.5.4
2
+
3
+ Lia Skalkos
4
+ * Enable options to be passed to #write_to_graphic_file (4ca972). For details see PR #41
5
+ Horst Duchene
6
+ * Fix travis-ci errors
7
+ * Add new ruby versions
8
+ * Fix gemspec errors
9
+ * Fix lint warnings
10
+ * Use version stream 0.5.2
11
+
12
+ 2017-04 Release 0.5.3
2
13
 
3
14
  Horst Duchene
4
15
  * Issue #38: Add error handling or dot functions. (719e38, 5a3423)
data/README.md CHANGED
@@ -134,6 +134,10 @@ The result:
134
134
 
135
135
  ![Example](https://github.com/monora/rgl/raw/master/images/example.jpg)
136
136
 
137
+ You can control the graph layout by passing layout parameters to `write_to_graphic_file`. See
138
+ `TestDot::test_to_dot_digraph_with_options` for an example using a feature implemented by Lia
139
+ Skalkos (see [PR #41](https://github.com/monora/rgl/pull/41)).
140
+
137
141
  irb> dg.directed?
138
142
  true
139
143
  irb> dg.vertices
@@ -249,6 +253,6 @@ See also http://github.com/monora/rgl/contributors.
249
253
 
250
254
  ## Copying
251
255
 
252
- RGL is Copyright (c) 2002,2004,2005,2008,2013,2015 by Horst Duchene. It is
256
+ RGL is Copyright (c) 2002,2004,2005,2008,2013,2015,2019 by Horst Duchene. It is
253
257
  free software, and may be redistributed under the terms specified in the
254
258
  README file of the Ruby distribution.
@@ -77,7 +77,7 @@ module RGL
77
77
  # Complexity is O(1), because the vertices are kept in a Hash containing
78
78
  # as values the lists of adjacent vertices of _v_.
79
79
  #
80
- def has_vertex? (v)
80
+ def has_vertex?(v)
81
81
  @vertices_dict.has_key?(v)
82
82
  end
83
83
 
@@ -87,7 +87,7 @@ module RGL
87
87
  # ---
88
88
  # MutableGraph interface.
89
89
  #
90
- def has_edge? (u, v)
90
+ def has_edge?(u, v)
91
91
  has_vertex?(u) && @vertices_dict[u].include?(v)
92
92
  end
93
93
 
@@ -4,7 +4,7 @@
4
4
  # library. The main module is RGL::Graph which defines the abstract behavior of
5
5
  # all graphs in the library.
6
6
 
7
- RGL_VERSION = "0.5.3"
7
+ RGL_VERSION = "0.5.4"
8
8
 
9
9
  module RGL
10
10
  class NotDirectedError < RuntimeError; end
@@ -33,21 +33,29 @@ module RGL
33
33
  fontsize = params['fontsize'] ? params['fontsize'] : '8'
34
34
  graph = (directed? ? DOT::Digraph : DOT::Graph).new(params)
35
35
  edge_class = directed? ? DOT::DirectedEdge : DOT::Edge
36
+ vertex_options = params['vertex'] || {}
37
+ edge_options = params['edge'] || {}
36
38
 
37
39
  each_vertex do |v|
38
- graph << DOT::Node.new(
39
- 'name' => vertex_id(v),
40
- 'fontsize' => fontsize,
41
- 'label' => vertex_label(v)
42
- )
40
+ default_vertex_options = {
41
+ 'name' => vertex_id(v),
42
+ 'fontsize' => fontsize,
43
+ 'label' => vertex_label(v)
44
+ }
45
+ each_vertex_options = default_vertex_options.merge(vertex_options)
46
+ vertex_options.each{|option, val| each_vertex_options[option] = val.call(v) if val.is_a?(Proc)}
47
+ graph << DOT::Node.new(each_vertex_options)
43
48
  end
44
49
 
45
50
  each_edge do |u, v|
46
- graph << edge_class.new(
47
- 'from' => vertex_id(u),
48
- 'to' => vertex_id(v),
49
- 'fontsize' => fontsize
50
- )
51
+ default_edge_options = {
52
+ 'from' => vertex_id(u),
53
+ 'to' => vertex_id(v),
54
+ 'fontsize' => fontsize
55
+ }
56
+ each_edge_options = default_edge_options.merge(edge_options)
57
+ edge_options.each{|option, val| each_edge_options[option] = val.call(u, v) if val.is_a?(Proc)}
58
+ graph << edge_class.new(each_edge_options)
51
59
  end
52
60
 
53
61
  graph
@@ -75,12 +83,12 @@ module RGL
75
83
  # Use dot[http://www.graphviz.org] to create a graphical representation of
76
84
  # the graph. Returns the filename of the graphics file.
77
85
  #
78
- def write_to_graphic_file(fmt='png', dotfile="graph")
86
+ def write_to_graphic_file(fmt='png', dotfile="graph", options={})
79
87
  src = dotfile + ".dot"
80
88
  dot = dotfile + "." + fmt
81
89
 
82
90
  File.open(src, 'w') do |f|
83
- f << self.to_dot_graph.to_s << "\n"
91
+ f << self.to_dot_graph(options).to_s << "\n"
84
92
  end
85
93
 
86
94
  unless system("dot -T#{fmt} #{src} -o #{dot}")
@@ -29,6 +29,33 @@ class TestDot < Test::Unit::TestCase
29
29
  end
30
30
  end
31
31
 
32
+ def test_to_dot_digraph_with_options
33
+ graph = RGL::DirectedAdjacencyGraph["a", "b"]
34
+
35
+ begin
36
+ edge_labels = {}
37
+ graph.each_edge do |b, e|
38
+ key = "#{b}-#{e}"
39
+ edge_labels[key] = "#{b} to #{e}"
40
+ end
41
+
42
+ vertex_fontcolors = {'a' => 'green', 'b' => 'blue'}
43
+ vertex_fontcolor_setting = Proc.new{|v| vertex_fontcolors[v]}
44
+ vertex_settings = {'fontcolor' => vertex_fontcolor_setting, 'fontsize' => 12}
45
+
46
+ edge_label_setting = Proc.new{|b, e| edge_labels["#{b}-#{e}"]}
47
+ edge_settings = {'color' => 'red', 'label' => edge_label_setting}
48
+ dot_options = {'edge' => edge_settings,'vertex' => vertex_settings}
49
+ dot = graph.to_dot_graph(dot_options).to_s
50
+
51
+ assert_match(dot, /a \[\n\s*fontcolor = green,\n\s*fontsize = 12,\n\s*label = a\n\s*/)
52
+ assert_match(dot, /b \[\n\s*fontcolor = blue,\n\s*fontsize = 12,\n\s*label = b\n\s*/)
53
+ assert_match(dot, /a -> b \[\n\s*color = red,\n\s*fontsize = 8,\n\s*label = \"a to b\"\n/)
54
+ rescue
55
+ puts "Graphviz not installed?"
56
+ end
57
+ end
58
+
32
59
  def test_to_dot_graph
33
60
  graph = RGL::AdjacencyGraph["a", "b"]
34
61
  def graph.vertex_label(v)
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.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Horst Duchene
@@ -9,76 +9,76 @@ authors:
9
9
  autorequire: rgl/base
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-22 00:00:00.000000000 Z
12
+ date: 2019-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stream
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.5.0
20
+ version: 0.5.2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.5.0
27
+ version: 0.5.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: lazy_priority_queue
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: 0.1.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.1.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: yard
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: test-unit
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  description: RGL is a framework for graph data structures and algorithms
@@ -88,156 +88,154 @@ extensions: []
88
88
  extra_rdoc_files:
89
89
  - README.md
90
90
  files:
91
- - lib/rgl/dijkstra.rb
92
- - lib/rgl/edmonds_karp.rb
93
- - lib/rgl/graphxml.rb
94
- - lib/rgl/edge_properties_map.rb
95
- - lib/rgl/transitiv_closure.rb
96
- - lib/rgl/condensation.rb
97
- - lib/rgl/topsort.rb
98
- - lib/rgl/path_builder.rb
99
- - lib/rgl/bellman_ford.rb
100
- - lib/rgl/graph_visitor.rb
101
- - lib/rgl/bidirectional.rb
102
- - lib/rgl/rdot.rb
103
- - lib/rgl/prim.rb
104
- - lib/rgl/adjacency.rb
105
- - lib/rgl/implicit.rb
106
- - lib/rgl/traversal.rb
107
- - lib/rgl/base.rb
108
- - lib/rgl/dot.rb
109
- - lib/rgl/graph_iterator.rb
110
- - lib/rgl/dijkstra_visitor.rb
111
- - lib/rgl/mutable.rb
112
- - lib/rgl/connected_components.rb
113
- - lib/rgl/transitivity.rb
114
- - lib/rgl/graph_wrapper.rb
115
- - lib/rgl/bipartite.rb
116
91
  - ChangeLog
117
- - examples/insel_der_tausend_gefahren.rb
118
- - examples/rdep-rgl.rb
119
- - examples/north2.rb
92
+ - Gemfile
93
+ - README.md
94
+ - Rakefile
120
95
  - examples/canvas.rb
96
+ - examples/examples.rb
97
+ - examples/insel_der_tausend_gefahren.rb
121
98
  - examples/north.rb
122
- - examples/north/g.10.45.graphml
123
- - examples/north/g.10.6.graphml
124
- - examples/north/g.10.56.graphml
125
- - examples/north/g.10.8.graphml
126
- - examples/north/g.10.29.graphml
127
- - examples/north/g.10.30.graphml
128
- - examples/north/g.10.37.graphml
129
99
  - examples/north/Graph.log
130
- - examples/north/g.10.20.graphml
131
- - examples/north/g.10.9.graphml
132
- - examples/north/g.10.74.graphml
133
- - examples/north/g.10.61.graphml
134
- - examples/north/g.12.8.graphml
135
- - examples/north/g.10.71.graphml
136
- - examples/north/g.10.7.graphml
137
- - examples/north/g.10.38.graphml
100
+ - examples/north/g.10.0.graphml
101
+ - examples/north/g.10.1.graphml
102
+ - examples/north/g.10.11.graphml
103
+ - examples/north/g.10.12.graphml
104
+ - examples/north/g.10.13.graphml
105
+ - examples/north/g.10.14.graphml
138
106
  - examples/north/g.10.15.graphml
139
- - examples/north/g.10.50.graphml
107
+ - examples/north/g.10.16.graphml
108
+ - examples/north/g.10.17.graphml
140
109
  - examples/north/g.10.19.graphml
141
- - examples/north/g.10.62.graphml
110
+ - examples/north/g.10.2.graphml
111
+ - examples/north/g.10.20.graphml
112
+ - examples/north/g.10.22.graphml
113
+ - examples/north/g.10.24.graphml
114
+ - examples/north/g.10.25.graphml
115
+ - examples/north/g.10.27.graphml
116
+ - examples/north/g.10.28.graphml
117
+ - examples/north/g.10.29.graphml
118
+ - examples/north/g.10.3.graphml
119
+ - examples/north/g.10.30.graphml
142
120
  - examples/north/g.10.31.graphml
143
- - examples/north/g.10.92.graphml
144
- - examples/north/g.10.88.graphml
145
- - examples/north/g.10.91.graphml
146
- - examples/north/g.10.93.graphml
147
- - examples/north/g.10.16.graphml
148
- - examples/north/g.10.90.graphml
149
121
  - examples/north/g.10.34.graphml
150
- - examples/north/g.10.0.graphml
151
- - examples/north/g.10.27.graphml
152
- - examples/north/g.10.82.graphml
153
- - examples/north/g.10.5.graphml
154
- - examples/north/g.10.17.graphml
122
+ - examples/north/g.10.37.graphml
123
+ - examples/north/g.10.38.graphml
155
124
  - examples/north/g.10.39.graphml
156
- - examples/north/g.10.94.graphml
125
+ - examples/north/g.10.4.graphml
126
+ - examples/north/g.10.40.graphml
157
127
  - examples/north/g.10.41.graphml
158
- - examples/north/g.10.70.graphml
159
- - examples/north/g.10.68.graphml
160
- - examples/north/g.10.72.graphml
161
- - examples/north/g.10.86.graphml
162
- - examples/north/g.10.79.graphml
163
- - examples/north/g.10.85.graphml
164
128
  - examples/north/g.10.42.graphml
165
- - examples/north/g.10.83.graphml
166
- - examples/north/g.10.24.graphml
167
- - examples/north/g.10.13.graphml
168
- - examples/north/g.10.75.graphml
169
- - examples/north/g.10.22.graphml
170
- - examples/north/g.10.89.graphml
171
- - examples/north/g.10.12.graphml
129
+ - examples/north/g.10.45.graphml
172
130
  - examples/north/g.10.46.graphml
173
- - examples/north/g.10.40.graphml
174
- - examples/north/g.10.3.graphml
175
- - examples/north/g.10.80.graphml
176
- - examples/north/g.10.11.graphml
131
+ - examples/north/g.10.5.graphml
132
+ - examples/north/g.10.50.graphml
133
+ - examples/north/g.10.56.graphml
177
134
  - examples/north/g.10.57.graphml
135
+ - examples/north/g.10.58.graphml
136
+ - examples/north/g.10.6.graphml
137
+ - examples/north/g.10.60.graphml
138
+ - examples/north/g.10.61.graphml
139
+ - examples/north/g.10.62.graphml
140
+ - examples/north/g.10.68.graphml
178
141
  - examples/north/g.10.69.graphml
179
- - examples/north/g.10.4.graphml
142
+ - examples/north/g.10.7.graphml
143
+ - examples/north/g.10.70.graphml
144
+ - examples/north/g.10.71.graphml
145
+ - examples/north/g.10.72.graphml
146
+ - examples/north/g.10.74.graphml
147
+ - examples/north/g.10.75.graphml
180
148
  - examples/north/g.10.78.graphml
149
+ - examples/north/g.10.79.graphml
150
+ - examples/north/g.10.8.graphml
151
+ - examples/north/g.10.80.graphml
152
+ - examples/north/g.10.82.graphml
153
+ - examples/north/g.10.83.graphml
154
+ - examples/north/g.10.85.graphml
155
+ - examples/north/g.10.86.graphml
156
+ - examples/north/g.10.88.graphml
157
+ - examples/north/g.10.89.graphml
158
+ - examples/north/g.10.9.graphml
159
+ - examples/north/g.10.90.graphml
160
+ - examples/north/g.10.91.graphml
161
+ - examples/north/g.10.92.graphml
162
+ - examples/north/g.10.93.graphml
163
+ - examples/north/g.10.94.graphml
164
+ - examples/north/g.12.8.graphml
181
165
  - examples/north/g.14.9.graphml
182
- - examples/north/g.10.58.graphml
183
- - examples/north/g.10.60.graphml
184
- - examples/north/g.10.1.graphml
185
- - examples/north/g.10.25.graphml
186
- - examples/north/g.10.14.graphml
187
- - examples/north/g.10.28.graphml
188
- - examples/north/g.10.2.graphml
189
- - examples/examples.rb
190
- - Gemfile
191
- - README.md
192
- - Rakefile
166
+ - examples/north2.rb
167
+ - examples/rdep-rgl.rb
168
+ - lib/rgl/adjacency.rb
169
+ - lib/rgl/base.rb
170
+ - lib/rgl/bellman_ford.rb
171
+ - lib/rgl/bidirectional.rb
172
+ - lib/rgl/bipartite.rb
173
+ - lib/rgl/condensation.rb
174
+ - lib/rgl/connected_components.rb
175
+ - lib/rgl/dijkstra.rb
176
+ - lib/rgl/dijkstra_visitor.rb
177
+ - lib/rgl/dot.rb
178
+ - lib/rgl/edge_properties_map.rb
179
+ - lib/rgl/edmonds_karp.rb
180
+ - lib/rgl/graph_iterator.rb
181
+ - lib/rgl/graph_visitor.rb
182
+ - lib/rgl/graph_wrapper.rb
183
+ - lib/rgl/graphxml.rb
184
+ - lib/rgl/implicit.rb
185
+ - lib/rgl/mutable.rb
186
+ - lib/rgl/path_builder.rb
187
+ - lib/rgl/prim.rb
188
+ - lib/rgl/rdot.rb
189
+ - lib/rgl/topsort.rb
190
+ - lib/rgl/transitiv_closure.rb
191
+ - lib/rgl/transitivity.rb
192
+ - lib/rgl/traversal.rb
193
193
  - rakelib/dep_graph.rake
194
+ - test/bellman_ford_test.rb
195
+ - test/bipartite_test.rb
196
+ - test/components_test.rb
197
+ - test/cycles_test.rb
198
+ - test/dijkstra_issue24_test.rb
194
199
  - test/dijkstra_test.rb
195
- - test/prim_test.rb
200
+ - test/directed_graph_test.rb
196
201
  - test/dot_test.rb
197
- - test/graph_xml_test.rb
202
+ - test/edge_properties_map_test.rb
198
203
  - test/edge_test.rb
199
204
  - test/edmonds_karp_test.rb
200
- - test/traversal_test.rb
201
- - test/edge_properties_map_test.rb
202
205
  - test/graph_test.rb
203
- - test/undirected_graph_test.rb
204
- - test/components_test.rb
206
+ - test/graph_xml_test.rb
205
207
  - test/implicit_test.rb
206
- - test/directed_graph_test.rb
207
- - test/bellman_ford_test.rb
208
+ - test/prim_test.rb
208
209
  - test/rdot_test.rb
209
- - test/cycles_test.rb
210
- - test/dijkstra_issue24_test.rb
211
210
  - test/test_helper.rb
212
211
  - test/transitivity_test.rb
213
- - test/bipartite_test.rb
212
+ - test/traversal_test.rb
213
+ - test/undirected_graph_test.rb
214
214
  homepage: https://github.com/monora/rgl
215
215
  licenses: []
216
216
  metadata: {}
217
217
  post_install_message:
218
218
  rdoc_options:
219
- - --title
219
+ - "--title"
220
220
  - RGL - Ruby Graph Library
221
- - --main
221
+ - "--main"
222
222
  - README.md
223
- - --line-numbers
223
+ - "--line-numbers"
224
224
  require_paths:
225
225
  - lib
226
226
  required_ruby_version: !ruby/object:Gem::Requirement
227
227
  requirements:
228
- - - '>='
228
+ - - ">="
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0'
231
231
  required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  requirements:
233
- - - '>='
233
+ - - ">="
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  requirements: []
237
- rubyforge_project:
238
- rubygems_version: 2.0.14
237
+ rubygems_version: 3.0.2
239
238
  signing_key:
240
239
  specification_version: 4
241
240
  summary: Ruby Graph Library
242
241
  test_files: []
243
- has_rdoc: true