rgl 0.5.8 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +7 -2
- data/README.md +30 -39
- data/examples/canvas.rb +1 -1
- data/examples/graph.dot +971 -0
- data/examples/insel_der_tausend_gefahren.rb +1 -1
- data/examples/north/g.10.0.graphml +1 -1
- data/examples/north/g.10.1.graphml +1 -1
- data/examples/north/g.10.11.graphml +1 -1
- data/examples/north/g.10.12.graphml +1 -1
- data/examples/north/g.10.13.graphml +1 -1
- data/examples/north/g.10.14.graphml +1 -1
- data/examples/north/g.10.15.graphml +1 -1
- data/examples/north/g.10.16.graphml +1 -1
- data/examples/north/g.10.17.graphml +1 -1
- data/examples/north/g.10.19.graphml +1 -1
- data/examples/north/g.10.2.graphml +1 -1
- data/examples/north/g.10.20.graphml +1 -1
- data/examples/north/g.10.22.graphml +1 -1
- data/examples/north/g.10.24.graphml +1 -1
- data/examples/north/g.10.25.graphml +1 -1
- data/examples/north/g.10.27.graphml +1 -1
- data/examples/north/g.10.28.graphml +1 -1
- data/examples/north/g.10.29.graphml +1 -1
- data/examples/north/g.10.3.graphml +1 -1
- data/examples/north/g.10.30.graphml +1 -1
- data/examples/north/g.10.31.graphml +1 -1
- data/examples/north/g.10.34.graphml +1 -1
- data/examples/north/g.10.37.graphml +1 -1
- data/examples/north/g.10.38.graphml +1 -1
- data/examples/north/g.10.39.graphml +1 -1
- data/examples/north/g.10.4.graphml +1 -1
- data/examples/north/g.10.40.graphml +1 -1
- data/examples/north/g.10.41.graphml +1 -1
- data/examples/north/g.10.42.graphml +1 -1
- data/examples/north/g.10.45.graphml +1 -1
- data/examples/north/g.10.46.graphml +1 -1
- data/examples/north/g.10.5.graphml +1 -1
- data/examples/north/g.10.50.graphml +1 -1
- data/examples/north/g.10.56.graphml +1 -1
- data/examples/north/g.10.57.graphml +1 -1
- data/examples/north/g.10.58.graphml +1 -1
- data/examples/north/g.10.6.graphml +1 -1
- data/examples/north/g.10.60.graphml +1 -1
- data/examples/north/g.10.61.graphml +1 -1
- data/examples/north/g.10.62.graphml +1 -1
- data/examples/north/g.10.68.graphml +1 -1
- data/examples/north/g.10.69.graphml +1 -1
- data/examples/north/g.10.7.graphml +1 -1
- data/examples/north/g.10.70.graphml +1 -1
- data/examples/north/g.10.71.graphml +1 -1
- data/examples/north/g.10.72.graphml +1 -1
- data/examples/north/g.10.74.graphml +1 -1
- data/examples/north/g.10.75.graphml +1 -1
- data/examples/north/g.10.78.graphml +1 -1
- data/examples/north/g.10.79.graphml +1 -1
- data/examples/north/g.10.8.graphml +1 -1
- data/examples/north/g.10.80.graphml +1 -1
- data/examples/north/g.10.82.graphml +1 -1
- data/examples/north/g.10.83.graphml +1 -1
- data/examples/north/g.10.85.graphml +1 -1
- data/examples/north/g.10.86.graphml +1 -1
- data/examples/north/g.10.88.graphml +1 -1
- data/examples/north/g.10.89.graphml +1 -1
- data/examples/north/g.10.9.graphml +1 -1
- data/examples/north/g.10.90.graphml +1 -1
- data/examples/north/g.10.91.graphml +1 -1
- data/examples/north/g.10.92.graphml +1 -1
- data/examples/north/g.10.93.graphml +1 -1
- data/examples/north/g.10.94.graphml +1 -1
- data/examples/north/g.12.8.graphml +1 -1
- data/examples/north/g.14.9.graphml +1 -1
- data/examples/north.rb +1 -1
- data/examples/rdep-rgl.rb +3 -3
- data/lib/rgl/adjacency.rb +43 -51
- data/lib/rgl/base.rb +71 -60
- data/lib/rgl/bellman_ford.rb +4 -5
- data/lib/rgl/bidirectional.rb +2 -2
- data/lib/rgl/bipartite.rb +1 -1
- data/lib/rgl/condensation.rb +3 -3
- data/lib/rgl/connected_components.rb +6 -6
- data/lib/rgl/dijkstra.rb +2 -2
- data/lib/rgl/dot.rb +5 -7
- data/lib/rgl/edmonds_karp.rb +7 -2
- data/lib/rgl/graph_iterator.rb +4 -2
- data/lib/rgl/graph_visitor.rb +16 -14
- data/lib/rgl/graph_wrapper.rb +3 -2
- data/lib/rgl/graphxml.rb +4 -4
- data/lib/rgl/implicit.rb +35 -35
- data/lib/rgl/mutable.rb +7 -7
- data/lib/rgl/path_builder.rb +3 -2
- data/lib/rgl/prim.rb +3 -1
- data/lib/rgl/rdot.rb +7 -7
- data/lib/rgl/topsort.rb +8 -7
- data/lib/rgl/transitivity.rb +6 -6
- data/lib/rgl/traversal.rb +47 -47
- data/test/traversal_test.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc32ab84139b87296c8e71d490843c6d90c83257e7876f42f25b23d0ae852cd8
|
4
|
+
data.tar.gz: 44177136283480e8ba77c431343d7a6361d3ac79e58b1d5864d8a74556ca4bd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51c96d180f5d570bfcaeaf5653749bf432fbcb3a82e75336f7883c0e45bc48de0d20e2ce6b26238fc9678bc0449e8564d7c1902f1dbd7101f6680d4481847850
|
7
|
+
data.tar.gz: eb9dcbd3b6ee1d870c2a2afeaab045bc29107ef5b9fc1b9fa2dc356ca5961a87c0bcf8d7d32dca2fb5add0e466598bc167128a4fbebc6f4428970439adfcd02d
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
2022-08 Release 0.5.9
|
2
|
+
|
3
|
+
Dan Čermák
|
4
|
+
* Drop lazy priority queue (#64) (3b1db1)
|
5
|
+
|
1
6
|
2022-06 Release 0.5.8
|
2
7
|
|
3
8
|
Horst Duchene
|
@@ -232,8 +237,8 @@ This release mainly contains the contributions of Kirill, who added many algorit
|
|
232
237
|
tests/TestRdot.rb: All IDs for DOT objects, including names,
|
233
238
|
options, and values, are now automatically quoted as necessary
|
234
239
|
according to the rules documented at
|
235
|
-
|
236
|
-
|
240
|
+
https://www.graphviz.org/doc/info/lang.html and
|
241
|
+
https://www.graphviz.org/Documentation/dotguide.pdf.
|
237
242
|
|
238
243
|
Labels are handled specially in order to account for \l, \r, and
|
239
244
|
\n sequences but are otherwise treated the same as other options.
|
data/README.md
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
# Ruby Graph Library (RGL)
|
1
|
+
# Ruby Graph Library (RGL)[![Test](https://github.com/monora/rgl/actions/workflows/test.yml/badge.svg)](https://github.com/monora/rgl/actions/workflows/test.yml) [![Doc](https://github.com/monora/rgl/actions/workflows/doc.yml/badge.svg)](https://github.com/monora/rgl/actions/workflows/doc.yml) [<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) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/monora/rgl)
|
2
2
|
|
3
3
|
RGL is a framework for graph data structures and algorithms.
|
4
4
|
|
5
5
|
The design of the library is much influenced by the Boost Graph Library (BGL)
|
6
|
-
which is written in C++. Refer to
|
6
|
+
which is written in C++. Refer to https://www.boost.org/libs/graph/doc for
|
7
7
|
further links and documentation on graph data structures and algorithms and
|
8
8
|
the design rationales of BGL.
|
9
9
|
|
10
10
|
A comprehensive summary of graph terminology can be found in the graph section
|
11
11
|
of the *Dictionary of Algorithms and Data Structures* at
|
12
|
-
|
12
|
+
https://www.nist.gov/dads/HTML/graph.html or
|
13
13
|
[Wikipedia](https://en.wikipedia.org/wiki/Graph_%28discrete_mathematics%29).
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
*
|
18
|
-
|
19
|
-
|
15
|
+
* [GitHub Repository](https://github.com/monora/rgl)
|
16
|
+
* [API Reference](https://monora.github.io/rgl/) generated from master branch
|
17
|
+
* [API Reference](https://www.rubydoc.info/github/monora/rgl) at
|
18
|
+
https://rubydoc.info for the latest release
|
20
19
|
|
21
20
|
## Design principles
|
22
21
|
|
@@ -31,7 +30,6 @@ Ruby. The main design goals directly taken from the BGL design are:
|
|
31
30
|
* A standardized generic interface for traversing graphs
|
32
31
|
{RGL::GraphIterator}
|
33
32
|
|
34
|
-
|
35
33
|
RGL provides some general purpose graph classes that conform to this
|
36
34
|
interface, but they are not meant to be the **only** graph classes. As in BGL
|
37
35
|
I believe that the main contribution of the RGL is the formulation of this
|
@@ -48,11 +46,10 @@ achieve genericity:
|
|
48
46
|
* Element Type Parameterization
|
49
47
|
* Vertex and Edge Property Multi-Parameterization
|
50
48
|
|
51
|
-
|
52
49
|
The first is easily achieved in RGL using mixins, which of course is not as
|
53
50
|
efficient than C++ templates (but much more readable :-). The second one is
|
54
51
|
even more easily implemented using standard iterators with blocks or using the
|
55
|
-
[stream](
|
52
|
+
[stream](https://www.rubydoc.info/github/monora/stream) module. The third one
|
56
53
|
is no issue since Ruby is dynamically typed: Each object can be a graph
|
57
54
|
vertex. There is no need for a vertex (or even edge type). In the current
|
58
55
|
version of RGL properties of vertices are simply attached using hashes. At
|
@@ -65,7 +62,6 @@ RGL current contains a core set of algorithm patterns:
|
|
65
62
|
* Breadth First Search {RGL::BFSIterator}
|
66
63
|
* Depth First Search {RGL::DFSIterator}
|
67
64
|
|
68
|
-
|
69
65
|
The algorithm patterns by themselves do not compute any meaningful quantities
|
70
66
|
over graphs, they are merely building blocks for constructing graph
|
71
67
|
algorithms. The graph algorithms in RGL currently include:
|
@@ -77,7 +73,6 @@ algorithms. The graph algorithms in RGL currently include:
|
|
77
73
|
* Dijkstras Shortest Path Algorithm {RGL::DijkstraAlgorithm}
|
78
74
|
* Bellman Ford Algorithm {RGL::BellmanFordAlgorithm}
|
79
75
|
|
80
|
-
|
81
76
|
### Data Structures
|
82
77
|
|
83
78
|
RGL currently provides two graph classes that implement a generalized
|
@@ -86,7 +81,6 @@ adjacency list and an edge list adaptor.
|
|
86
81
|
* {RGL::AdjacencyGraph}
|
87
82
|
* {RGL::ImplicitGraph}
|
88
83
|
|
89
|
-
|
90
84
|
The AdjacencyGraph class is the general purpose _swiss army knife_ of graph
|
91
85
|
classes. It is highly parameterized so that it can be optimized for different
|
92
86
|
situations: the graph is directed or undirected, allow or disallow parallel
|
@@ -95,20 +89,20 @@ removal at the cost of extra space overhead, etc.
|
|
95
89
|
|
96
90
|
### Differences to BGL
|
97
91
|
|
98
|
-
The concepts of IncidenceGraph, AdjacencyGraph and VertexListGraph
|
99
|
-
|
100
|
-
|
101
|
-
the base module Graph. The complexity guarantees
|
102
|
-
|
92
|
+
The concepts of IncidenceGraph, AdjacencyGraph and VertexListGraph
|
93
|
+
(see [IncidenceGraph](https://www.boost.org/libs/graph/doc/IncidenceGraph.html)) are
|
94
|
+
bundled in RGL's base graph module. Most methods of IncidenceGraph
|
95
|
+
should be standard in the base module Graph. The complexity guarantees
|
96
|
+
can not necessarily provided (see [BGL's Graph Concepts](https://www.boost.org/libs/graph/doc/graph_concepts.html)).
|
103
97
|
|
104
98
|
## Installation
|
105
99
|
|
106
100
|
% gem install rgl
|
107
101
|
|
108
|
-
or download the latest sources from the git
|
109
|
-
|
102
|
+
or download the latest sources from the [git
|
103
|
+
repository](https://github.com/monora/rgl).
|
110
104
|
|
111
|
-
If you are going to use the drawing functionalities install [Graphviz](
|
105
|
+
If you are going to use the drawing functionalities install [Graphviz](https://www.graphviz.org/).
|
112
106
|
|
113
107
|
## Running tests
|
114
108
|
|
@@ -134,7 +128,7 @@ After that you can run the tests:
|
|
134
128
|
|
135
129
|
The result:
|
136
130
|
|
137
|
-
![Example](
|
131
|
+
![Example](images/example.jpg)
|
138
132
|
|
139
133
|
You can control the graph layout by passing layout parameters to `write_to_graphic_file`. See
|
140
134
|
`TestDot::test_to_dot_digraph_with_options` for an example using a feature implemented by Lia
|
@@ -220,48 +214,45 @@ subgraph of the original graph, using a filtered graph:
|
|
220
214
|
|
221
215
|
creates the following graph image with DOT:
|
222
216
|
|
223
|
-
![Module graph](
|
217
|
+
![Module graph](images/module_graph.jpg)
|
224
218
|
|
225
219
|
This graph shows all loaded RGL modules:
|
226
220
|
|
227
|
-
![RGL Modules](
|
221
|
+
![RGL Modules](images/rgl_modules.png)
|
228
222
|
|
229
223
|
Look for more in
|
230
224
|
[examples](https://github.com/monora/rgl/tree/master/examples) directory.
|
231
225
|
|
232
|
-
I collect some links to stuff around RGL at http://del.icio.us/monora/rgl.
|
233
|
-
|
234
226
|
## Credits
|
235
227
|
|
236
228
|
Many thanks to Robert Feldt which also worked on a graph library
|
237
|
-
(
|
229
|
+
(https://rockit.sf.net/subprojects/graphr) who pointed me to BGL and many other
|
238
230
|
graph resources.
|
239
231
|
|
240
232
|
Robert kindly allowed to integrate his work on graphr, which I did not yet
|
241
233
|
succeed. Especially his work to output graphs for
|
242
|
-
[GraphViz](
|
234
|
+
[GraphViz](https://www.graphviz.org) is much more elaborated than the minimal
|
243
235
|
support in dot.rb.
|
244
236
|
|
245
237
|
Jeremy Siek one of the authors of the nice book [The Boost Graph
|
246
|
-
Library](
|
238
|
+
Library](https://www.boost.org/libs/graph/doc) kindly allowed to use the BGL
|
247
239
|
documentation as a *cheap* reference for RGL. He and Robert also gave feedback
|
248
240
|
and many ideas for RGL.
|
249
241
|
|
250
|
-
Dave Thomas for [RDoc](
|
242
|
+
Dave Thomas for [RDoc](https://rdoc.sourceforge.net) which generated what you
|
251
243
|
read and matz for Ruby. Dave included in the latest version of RDoc (alpha9)
|
252
|
-
the module
|
253
|
-
graphs
|
254
|
-
|
255
|
-
Jeremy Bopp, John Carter, Sascha Doerdelmann, Shawn Garbett, Andreas Schörk
|
256
|
-
and Kirill Lashuk for contributing additions, test cases and bugfixes.
|
244
|
+
the module {RGL::DOT} which is used instead of Roberts module to visualize
|
245
|
+
graphs.
|
257
246
|
|
258
|
-
|
247
|
+
Jeremy Bopp, John Carter, Sascha Doerdelmann, Shawn Garbett, Andreas
|
248
|
+
Schörk, Dan Čermák and Kirill Lashuk for contributing additions, test
|
249
|
+
cases and bugfixes.
|
259
250
|
|
260
|
-
See also
|
251
|
+
See also: https://github.com/monora/rgl/contributors
|
261
252
|
|
262
253
|
## Copying
|
263
254
|
|
264
|
-
RGL is Copyright (c) 2002,2004,2005,2008,2013,2015,2019,2020 by Horst
|
255
|
+
RGL is Copyright (c) 2002,2004,2005,2008,2013,2015,2019,2020,2022 by Horst
|
265
256
|
Duchene. It is free software, and may be redistributed under the [Ruby
|
266
257
|
license](https://en.wikipedia.org/wiki/Ruby_License) and terms specified in
|
267
258
|
the LICENSE file.
|
data/examples/canvas.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# From c.l.r SNIP IT: bond TkCanvas with RubyGraphLibrary
|
2
2
|
# author: Phlip (see also
|
3
|
-
#
|
3
|
+
# https://www.rubygarden.org/ruby?RubyAlgorithmPackage/TkCanvasSample)
|
4
4
|
#
|
5
5
|
# put a GraphViz graph into a TkCanvas, and make nodes
|
6
6
|
# selectable. Illustrates a bug in GraphViz
|