silicium 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +3 -3
- data/.gitignore +13 -13
- data/.rakeTasks +8 -0
- data/.travis.yml +28 -25
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +8 -8
- data/LICENSE.txt +21 -21
- data/Makefile +269 -269
- data/README.md +588 -46
- data/Rakefile +16 -16
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/docs/Object.html +117 -117
- data/docs/README_md.html +142 -142
- data/docs/Silicium/Combinatorics.html +270 -270
- data/docs/Silicium/Dice/Polyhedron.html +315 -315
- data/docs/Silicium/Dice/PolyhedronSet.html +321 -321
- data/docs/Silicium/Dice.html +99 -99
- data/docs/Silicium/Error.html +106 -106
- data/docs/Silicium/Geometry/Line2dCanon.html +243 -243
- data/docs/Silicium/Geometry/VariablesOrderException.html +106 -106
- data/docs/Silicium/Geometry.html +940 -940
- data/docs/Silicium/GraphVisualizer.html +226 -0
- data/docs/Silicium/Graphs/GraphError.html +106 -106
- data/docs/Silicium/Graphs/OrientedGraph.html +901 -775
- data/docs/Silicium/Graphs/UnorientedGraph.html +237 -284
- data/docs/Silicium/Graphs.html +374 -164
- data/docs/Silicium/IntegralDoesntExistError.html +106 -106
- data/docs/Silicium/NumericalIntegration.html +521 -521
- data/docs/Silicium/Optimization.html +629 -639
- data/docs/Silicium/Plotter/Image.html +297 -297
- data/docs/Silicium/Plotter.html +186 -186
- data/docs/Silicium.html +101 -101
- data/docs/created.rid +9 -9
- data/docs/css/fonts.css +167 -167
- data/docs/css/rdoc.css +619 -619
- data/docs/index.html +134 -132
- data/docs/js/darkfish.js +84 -84
- data/docs/js/navigation.js +105 -105
- data/docs/js/search.js +110 -110
- data/docs/js/search_index.js +1 -1
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -229
- data/docs/table_of_contents.html +697 -608
- data/lib/algebra.rb +452 -0
- data/lib/algebra_diff.rb +258 -0
- data/lib/geometry/figure.rb +62 -0
- data/lib/geometry.rb +290 -236
- data/lib/geometry3d.rb +270 -0
- data/lib/graph/dfs.rb +42 -0
- data/lib/graph/kruskal.rb +36 -0
- data/lib/graph/scc.rb +97 -0
- data/lib/graph.rb +350 -164
- data/lib/graph_visualizer.rb +287 -0
- data/lib/ml_algorithms.rb +181 -0
- data/lib/numerical_integration.rb +184 -147
- data/lib/optimization.rb +209 -144
- data/lib/plotter.rb +256 -96
- data/lib/polynomial_division.rb +132 -0
- data/lib/polynomial_interpolation.rb +94 -0
- data/lib/regression.rb +120 -0
- data/lib/silicium/adding.rb +37 -0
- data/lib/silicium/conversions.rb +23 -0
- data/lib/silicium/multi.rb +82 -0
- data/lib/silicium/sparse.rb +76 -0
- data/lib/silicium/sugar.rb +37 -0
- data/lib/silicium/trans.rb +26 -0
- data/lib/silicium/version.rb +3 -3
- data/lib/silicium.rb +5 -5
- data/lib/theory_of_probability.rb +240 -226
- data/lib/topological_sort.rb +50 -0
- data/oriented_graph.png +0 -0
- data/plot.png +0 -0
- data/silicium.gemspec +38 -39
- metadata +38 -16
@@ -0,0 +1,226 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module Silicium::GraphVisualizer - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="module">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="../index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<!-- Method Quickref -->
|
66
|
+
<div id="method-list-section" class="nav-section">
|
67
|
+
<h3>Methods</h3>
|
68
|
+
|
69
|
+
<ul class="link-list" role="directory">
|
70
|
+
|
71
|
+
<li ><a href="#change_window_size">#change_window_size</a>
|
72
|
+
<li ><a href="#change_edge_width">#change_edge_width</a>
|
73
|
+
<li ><a href="#change_vertices_radius">#change_vertices_radius</a>
|
74
|
+
<li ><a href="#change_label_size">#change_label_size</a>
|
75
|
+
<li ><a href="#change_label_color">#change_label_color</a>
|
76
|
+
<li ><a href="#change_vertex_color">#change_vertex_color</a>
|
77
|
+
<li ><a href="#set_graph">#set_graph</a>
|
78
|
+
<li ><a href="#clear_window">#clear_window</a>
|
79
|
+
<li ><a href="#close_window">#close_window</a>
|
80
|
+
<li ><a href="#show_window">#show_window</a>
|
81
|
+
</ul>
|
82
|
+
</div>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
</nav>
|
86
|
+
|
87
|
+
<main role="main" aria-labelledby="module-Silicium::GraphVisualizer">
|
88
|
+
<h1 id="module-Silicium::GraphVisualizer" class="module">
|
89
|
+
module Silicium::GraphVisualizer
|
90
|
+
</h1>
|
91
|
+
|
92
|
+
<section class="description">
|
93
|
+
|
94
|
+
</section>
|
95
|
+
|
96
|
+
|
97
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
98
|
+
|
99
|
+
|
100
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
101
|
+
<header>
|
102
|
+
<h3>Public Instance Methods</h3>
|
103
|
+
</header>
|
104
|
+
|
105
|
+
|
106
|
+
<div id="change_window_size" class="method-detail ">
|
107
|
+
|
108
|
+
<div class="method-heading">
|
109
|
+
<span class="method-name">change_window_size</span>
|
110
|
+
<span class="method-args">(width, height)</span>
|
111
|
+
</div>
|
112
|
+
<div class="method-description">
|
113
|
+
<p>Changes window size</p>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div id="change_edge_width" class="method-detail ">
|
118
|
+
<div class="method-heading">
|
119
|
+
<span class="method-name">change_edge_width</span>
|
120
|
+
<span class="method-args">(width)</span>
|
121
|
+
</div>
|
122
|
+
<div class="method-description">
|
123
|
+
<p>Changes width of edges</p>
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
<div id="change_vertices_radius" class="method-detail ">
|
128
|
+
|
129
|
+
<div class="method-heading">
|
130
|
+
<span class="method-name">change_vertices_radius</span>
|
131
|
+
<span class="method-args">(radius)</span>
|
132
|
+
</div>
|
133
|
+
<div class="method-description">
|
134
|
+
<p>Changes radius of vertices</p>
|
135
|
+
</div>
|
136
|
+
</div>
|
137
|
+
|
138
|
+
<div id="change_label_size" class="method-detail ">
|
139
|
+
|
140
|
+
<div class="method-heading">
|
141
|
+
<span class="method-name">change_label_size</span>
|
142
|
+
<span class="method-args">(size)</span>
|
143
|
+
</div>
|
144
|
+
<div class="method-description">
|
145
|
+
<p>Changes labels size</p>
|
146
|
+
</div>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<div id="change_label_color" class="method-detail ">
|
150
|
+
|
151
|
+
<div class="method-heading">
|
152
|
+
<span class="method-name">change_label_color</span>
|
153
|
+
<span class="method-args">(color)</span>
|
154
|
+
</div>
|
155
|
+
<div class="method-description">
|
156
|
+
<p>Changes labels color</p>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div id="change_vertex_color" class="method-detail ">
|
161
|
+
|
162
|
+
<div class="method-heading">
|
163
|
+
<span class="method-name">change_vertex_color</span>
|
164
|
+
<span class="method-args">(color)</span>
|
165
|
+
</div>
|
166
|
+
<div class="method-description">
|
167
|
+
<p>Changes vertices color</p>
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
|
171
|
+
<div id="set_graph" class="method-detail ">
|
172
|
+
|
173
|
+
<div class="method-heading">
|
174
|
+
<span class="method-name">set_graph</span>
|
175
|
+
<span class="method-args">(graph)</span>
|
176
|
+
</div>
|
177
|
+
<div class="method-description">
|
178
|
+
<p>Set the graph for visualization</p>
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
|
182
|
+
<div id="clear_window" class="method-detail ">
|
183
|
+
|
184
|
+
<div class="method-heading">
|
185
|
+
<span class="method-name">clear_window</span>
|
186
|
+
<span class="method-args">()</span>
|
187
|
+
</div>
|
188
|
+
<div class="method-description">
|
189
|
+
<p>Clear screen</p>
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
|
193
|
+
<div id="close_window" class="method-detail ">
|
194
|
+
|
195
|
+
<div class="method-heading">
|
196
|
+
<span class="method-name">close_window</span>
|
197
|
+
<span class="method-args">()</span>
|
198
|
+
</div>
|
199
|
+
<div class="method-description">
|
200
|
+
<p>Close screen</p>
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div id="show_window" class="method-detail ">
|
205
|
+
|
206
|
+
<div class="method-heading">
|
207
|
+
<span class="method-name">show_window</span>
|
208
|
+
<span class="method-args">()</span>
|
209
|
+
</div>
|
210
|
+
<div class="method-description">
|
211
|
+
<p>Show graph on the screen</p>
|
212
|
+
</div>
|
213
|
+
</div>
|
214
|
+
</section>
|
215
|
+
|
216
|
+
</section>
|
217
|
+
|
218
|
+
</main>
|
219
|
+
|
220
|
+
|
221
|
+
<footer id="validator-badges" role="contentinfo">
|
222
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
223
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
224
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
225
|
+
</footer>
|
226
|
+
|
@@ -1,106 +1,106 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Silicium::Graphs::GraphError - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "../../";
|
11
|
-
var index_rel_prefix = "../../";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="../../js/navigation.js" defer></script>
|
15
|
-
<script src="../../js/search.js" defer></script>
|
16
|
-
<script src="../../js/search_index.js" defer></script>
|
17
|
-
<script src="../../js/searcher.js" defer></script>
|
18
|
-
<script src="../../js/darkfish.js" defer></script>
|
19
|
-
|
20
|
-
<link href="../../css/fonts.css" rel="stylesheet">
|
21
|
-
<link href="../../css/rdoc.css" rel="stylesheet">
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<body id="top" role="document" class="class">
|
27
|
-
<nav role="navigation">
|
28
|
-
<div id="project-navigation">
|
29
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
-
<h2>
|
31
|
-
<a href="../../index.html" rel="home">Home</a>
|
32
|
-
</h2>
|
33
|
-
|
34
|
-
<div id="table-of-contents-navigation">
|
35
|
-
<a href="../../table_of_contents.html#pages">Pages</a>
|
36
|
-
<a href="../../table_of_contents.html#classes">Classes</a>
|
37
|
-
<a href="../../table_of_contents.html#methods">Methods</a>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
-
<form action="#" method="get" accept-charset="utf-8">
|
43
|
-
<div id="search-field-wrapper">
|
44
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
-
aria-autocomplete="list" aria-controls="search-results"
|
46
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<ul id="search-results" aria-label="Search Results"
|
51
|
-
aria-busy="false" aria-expanded="false"
|
52
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
<div id="class-metadata">
|
61
|
-
|
62
|
-
<div id="parent-class-section" class="nav-section">
|
63
|
-
<h3>Parent</h3>
|
64
|
-
|
65
|
-
|
66
|
-
<p class="link">Error
|
67
|
-
|
68
|
-
</div>
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
</div>
|
74
|
-
</nav>
|
75
|
-
|
76
|
-
<main role="main" aria-labelledby="class-Silicium::Graphs::GraphError">
|
77
|
-
<h1 id="class-Silicium::Graphs::GraphError" class="class">
|
78
|
-
class Silicium::Graphs::GraphError
|
79
|
-
</h1>
|
80
|
-
|
81
|
-
<section class="description">
|
82
|
-
|
83
|
-
</section>
|
84
|
-
|
85
|
-
|
86
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
</section>
|
97
|
-
|
98
|
-
</main>
|
99
|
-
|
100
|
-
|
101
|
-
<footer id="validator-badges" role="contentinfo">
|
102
|
-
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
103
|
-
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
104
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
105
|
-
</footer>
|
106
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Silicium::Graphs::GraphError - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../../";
|
11
|
+
var index_rel_prefix = "../../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../../js/navigation.js" defer></script>
|
15
|
+
<script src="../../js/search.js" defer></script>
|
16
|
+
<script src="../../js/search_index.js" defer></script>
|
17
|
+
<script src="../../js/searcher.js" defer></script>
|
18
|
+
<script src="../../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="class">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="../../index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="../../table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="../../table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="../../table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
<div id="parent-class-section" class="nav-section">
|
63
|
+
<h3>Parent</h3>
|
64
|
+
|
65
|
+
|
66
|
+
<p class="link">Error
|
67
|
+
|
68
|
+
</div>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
</div>
|
74
|
+
</nav>
|
75
|
+
|
76
|
+
<main role="main" aria-labelledby="class-Silicium::Graphs::GraphError">
|
77
|
+
<h1 id="class-Silicium::Graphs::GraphError" class="class">
|
78
|
+
class Silicium::Graphs::GraphError
|
79
|
+
</h1>
|
80
|
+
|
81
|
+
<section class="description">
|
82
|
+
|
83
|
+
</section>
|
84
|
+
|
85
|
+
|
86
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
</section>
|
97
|
+
|
98
|
+
</main>
|
99
|
+
|
100
|
+
|
101
|
+
<footer id="validator-badges" role="contentinfo">
|
102
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
103
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
104
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
105
|
+
</footer>
|
106
|
+
|
@@ -1,775 +1,901 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>class Silicium::Graphs::OrientedGraph - RDoc Documentation</title>
|
8
|
-
|
9
|
-
<script type="text/javascript">
|
10
|
-
var rdoc_rel_prefix = "../../";
|
11
|
-
var index_rel_prefix = "../../";
|
12
|
-
</script>
|
13
|
-
|
14
|
-
<script src="../../js/navigation.js" defer></script>
|
15
|
-
<script src="../../js/search.js" defer></script>
|
16
|
-
<script src="../../js/search_index.js" defer></script>
|
17
|
-
<script src="../../js/searcher.js" defer></script>
|
18
|
-
<script src="../../js/darkfish.js" defer></script>
|
19
|
-
|
20
|
-
<link href="../../css/fonts.css" rel="stylesheet">
|
21
|
-
<link href="../../css/rdoc.css" rel="stylesheet">
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<body id="top" role="document" class="class">
|
27
|
-
<nav role="navigation">
|
28
|
-
<div id="project-navigation">
|
29
|
-
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
-
<h2>
|
31
|
-
<a href="../../index.html" rel="home">Home</a>
|
32
|
-
</h2>
|
33
|
-
|
34
|
-
<div id="table-of-contents-navigation">
|
35
|
-
<a href="../../table_of_contents.html#pages">Pages</a>
|
36
|
-
<a href="../../table_of_contents.html#classes">Classes</a>
|
37
|
-
<a href="../../table_of_contents.html#methods">Methods</a>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
|
41
|
-
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
-
<form action="#" method="get" accept-charset="utf-8">
|
43
|
-
<div id="search-field-wrapper">
|
44
|
-
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
-
aria-autocomplete="list" aria-controls="search-results"
|
46
|
-
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<ul id="search-results" aria-label="Search Results"
|
51
|
-
aria-busy="false" aria-expanded="false"
|
52
|
-
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
-
</form>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
<div id="class-metadata">
|
61
|
-
|
62
|
-
<div id="parent-class-section" class="nav-section">
|
63
|
-
<h3>Parent</h3>
|
64
|
-
|
65
|
-
|
66
|
-
<p class="link"><a href="../../Object.html">Object</a>
|
67
|
-
|
68
|
-
</div>
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
<!-- Method Quickref -->
|
73
|
-
<div id="method-list-section" class="nav-section">
|
74
|
-
<h3>Methods</h3>
|
75
|
-
|
76
|
-
<ul class="link-list" role="directory">
|
77
|
-
|
78
|
-
<li ><a href="#method-c-new">::new</a>
|
79
|
-
|
80
|
-
<li ><a href="#method-i-add_edge-21">#add_edge!</a>
|
81
|
-
|
82
|
-
<li ><a href="#method-i-
|
83
|
-
|
84
|
-
<li ><a href="#method-i-
|
85
|
-
|
86
|
-
<li ><a href="#method-i-
|
87
|
-
|
88
|
-
<li ><a href="#method-i-
|
89
|
-
|
90
|
-
<li ><a href="#method-i-
|
91
|
-
|
92
|
-
<li ><a href="#method-i-
|
93
|
-
|
94
|
-
<li ><a href="#method-i-
|
95
|
-
|
96
|
-
<li ><a href="#method-i-
|
97
|
-
|
98
|
-
<li ><a href="#method-i-
|
99
|
-
|
100
|
-
<li ><a href="#method-i-
|
101
|
-
|
102
|
-
<li ><a href="#method-i-
|
103
|
-
|
104
|
-
<li ><a href="#method-i-
|
105
|
-
|
106
|
-
<li ><a href="#method-i-
|
107
|
-
|
108
|
-
<li ><a href="#method-i-
|
109
|
-
|
110
|
-
<li ><a href="#method-i-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
</
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
</
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
<span class="ruby-
|
172
|
-
<span class="ruby-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
</
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
<
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
<div class="method-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
<
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
<span class="ruby-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
<span class="ruby-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
<span class="method-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
<span class="ruby-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
<span class="method-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
<span class="ruby-keyword">
|
471
|
-
|
472
|
-
<span class="ruby-keyword">end</span
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
<span class="method-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
<span class="ruby-keyword">end</span
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
<span class="method-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
<span class="ruby-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
<span class="ruby-keyword">
|
611
|
-
|
612
|
-
<span class="ruby-keyword">end</span
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
<span class="method-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
<span class="ruby-keyword">end</span
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
<span class="method-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
<span class="ruby-
|
686
|
-
<span class="ruby-keyword">
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
<span class="
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
<span class="
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
</
|
766
|
-
|
767
|
-
</
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
</
|
775
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Silicium::Graphs::OrientedGraph - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../../";
|
11
|
+
var index_rel_prefix = "../../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../../js/navigation.js" defer></script>
|
15
|
+
<script src="../../js/search.js" defer></script>
|
16
|
+
<script src="../../js/search_index.js" defer></script>
|
17
|
+
<script src="../../js/searcher.js" defer></script>
|
18
|
+
<script src="../../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="class">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="../../index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="../../table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="../../table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="../../table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
<div id="parent-class-section" class="nav-section">
|
63
|
+
<h3>Parent</h3>
|
64
|
+
|
65
|
+
|
66
|
+
<p class="link"><a href="../../Object.html">Object</a>
|
67
|
+
|
68
|
+
</div>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
<!-- Method Quickref -->
|
73
|
+
<div id="method-list-section" class="nav-section">
|
74
|
+
<h3>Methods</h3>
|
75
|
+
|
76
|
+
<ul class="link-list" role="directory">
|
77
|
+
|
78
|
+
<li ><a href="#method-c-new">::new</a>
|
79
|
+
|
80
|
+
<li ><a href="#method-i-add_edge-21">#add_edge!</a>
|
81
|
+
|
82
|
+
<li ><a href="#method-i-add_vertex-21">#add_vertex!</a>
|
83
|
+
|
84
|
+
<li ><a href="#method-i-adjacted_with">#adjacted_with</a>
|
85
|
+
|
86
|
+
<li ><a href="#method-i-delete_edge-21">#delete_edge!</a>
|
87
|
+
|
88
|
+
<li ><a href="#method-i-delete_vertex-21">#delete_vertex!</a>
|
89
|
+
|
90
|
+
<li ><a href="#method-i-edge_label_number">#edge_label_number</a>
|
91
|
+
|
92
|
+
<li ><a href="#method-i-edge_number">#edge_number</a>
|
93
|
+
|
94
|
+
<li ><a href="#method-i-get_edge_label">#get_edge_label</a>
|
95
|
+
|
96
|
+
<li ><a href="#method-i-get_vertex_label">#get_vertex_label</a>
|
97
|
+
|
98
|
+
<li ><a href="#method-i-has_edge-3F">#has_edge?</a>
|
99
|
+
|
100
|
+
<li ><a href="#method-i-has_vertex-3F">#has_vertex?</a>
|
101
|
+
|
102
|
+
<li ><a href="#method-i-label_edge-21">#label_edge!</a>
|
103
|
+
|
104
|
+
<li ><a href="#method-i-label_vertex-21">#label_vertex!</a>
|
105
|
+
|
106
|
+
<li ><a href="#method-i-protected_add_edge-21">#protected_add_edge!</a>
|
107
|
+
|
108
|
+
<li ><a href="#method-i-protected_delete_edge-21">#protected_delete_edge!</a>
|
109
|
+
|
110
|
+
<li ><a href="#method-i-reverse-21">#reverse!</a>
|
111
|
+
|
112
|
+
<li ><a href="#method-i-vertex_label_number">#vertex_label_number</a>
|
113
|
+
|
114
|
+
<li ><a href="#method-i-vertex_number">#vertex_number</a>
|
115
|
+
|
116
|
+
<li ><a href="#method-i-vertices">#vertices</a>
|
117
|
+
|
118
|
+
</ul>
|
119
|
+
</div>
|
120
|
+
|
121
|
+
</div>
|
122
|
+
</nav>
|
123
|
+
|
124
|
+
<main role="main" aria-labelledby="class-Silicium::Graphs::OrientedGraph">
|
125
|
+
<h1 id="class-Silicium::Graphs::OrientedGraph" class="class">
|
126
|
+
class Silicium::Graphs::OrientedGraph
|
127
|
+
</h1>
|
128
|
+
|
129
|
+
<section class="description">
|
130
|
+
|
131
|
+
</section>
|
132
|
+
|
133
|
+
|
134
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
145
|
+
<header>
|
146
|
+
<h3>Public Class Methods</h3>
|
147
|
+
</header>
|
148
|
+
|
149
|
+
|
150
|
+
<div id="method-c-new" class="method-detail ">
|
151
|
+
|
152
|
+
<div class="method-heading">
|
153
|
+
<span class="method-name">new</span><span
|
154
|
+
class="method-args">(initializer = [])</span>
|
155
|
+
|
156
|
+
<span class="method-click-advice">click to toggle source</span>
|
157
|
+
|
158
|
+
</div>
|
159
|
+
|
160
|
+
|
161
|
+
<div class="method-description">
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<div class="method-source-code" id="new-source">
|
169
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 13</span>
|
170
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">initializer</span> = [])
|
171
|
+
<span class="ruby-ivar">@vertices</span> = {}
|
172
|
+
<span class="ruby-ivar">@edge_labels</span> = {}
|
173
|
+
<span class="ruby-ivar">@vertex_labels</span> = {}
|
174
|
+
<span class="ruby-ivar">@edge_number</span> = <span class="ruby-value">0</span>
|
175
|
+
<span class="ruby-identifier">initializer</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
176
|
+
<span class="ruby-identifier">add_vertex!</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:v</span>])
|
177
|
+
<span class="ruby-identifier">v</span>[<span class="ruby-value">:i</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">iv</span><span class="ruby-operator">|</span>
|
178
|
+
<span class="ruby-identifier">add_vertex!</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:v</span>])
|
179
|
+
<span class="ruby-identifier">add_vertex!</span>(<span class="ruby-identifier">iv</span>)
|
180
|
+
<span class="ruby-identifier">add_edge!</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:v</span>], <span class="ruby-identifier">iv</span>)
|
181
|
+
<span class="ruby-keyword">end</span>
|
182
|
+
<span class="ruby-keyword">end</span>
|
183
|
+
<span class="ruby-keyword">end</span></pre>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
</div>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
</div>
|
192
|
+
|
193
|
+
|
194
|
+
</section>
|
195
|
+
|
196
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
197
|
+
<header>
|
198
|
+
<h3>Public Instance Methods</h3>
|
199
|
+
</header>
|
200
|
+
|
201
|
+
|
202
|
+
<div id="method-i-add_edge-21" class="method-detail ">
|
203
|
+
|
204
|
+
<div class="method-heading">
|
205
|
+
<span class="method-name">add_edge!</span><span
|
206
|
+
class="method-args">(from, to)</span>
|
207
|
+
|
208
|
+
<span class="method-click-advice">click to toggle source</span>
|
209
|
+
|
210
|
+
</div>
|
211
|
+
|
212
|
+
|
213
|
+
<div class="method-description">
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
<div class="method-source-code" id="add_edge-21-source">
|
221
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 35</span>
|
222
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
223
|
+
<span class="ruby-identifier">protected_add_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
224
|
+
<span class="ruby-ivar">@edge_number</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
225
|
+
<span class="ruby-keyword">end</span></pre>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
</div>
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
</div>
|
234
|
+
|
235
|
+
|
236
|
+
<div id="method-i-add_vertex-21" class="method-detail ">
|
237
|
+
|
238
|
+
<div class="method-heading">
|
239
|
+
<span class="method-name">add_vertex!</span><span
|
240
|
+
class="method-args">(vertex_id)</span>
|
241
|
+
|
242
|
+
<span class="method-click-advice">click to toggle source</span>
|
243
|
+
|
244
|
+
</div>
|
245
|
+
|
246
|
+
|
247
|
+
<div class="method-description">
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
<div class="method-source-code" id="add_vertex-21-source">
|
255
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 28</span>
|
256
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_vertex!</span>(<span class="ruby-identifier">vertex_id</span>)
|
257
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">vertex_id</span>)
|
258
|
+
<span class="ruby-keyword">return</span>
|
259
|
+
<span class="ruby-keyword">end</span>
|
260
|
+
<span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">vertex_id</span>] = [].<span class="ruby-identifier">to_set</span>
|
261
|
+
<span class="ruby-keyword">end</span></pre>
|
262
|
+
</div>
|
263
|
+
|
264
|
+
</div>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
</div>
|
270
|
+
|
271
|
+
|
272
|
+
<div id="method-i-adjacted_with" class="method-detail ">
|
273
|
+
|
274
|
+
<div class="method-heading">
|
275
|
+
<span class="method-name">adjacted_with</span><span
|
276
|
+
class="method-args">(vertex)</span>
|
277
|
+
|
278
|
+
<span class="method-click-advice">click to toggle source</span>
|
279
|
+
|
280
|
+
</div>
|
281
|
+
|
282
|
+
|
283
|
+
<div class="method-description">
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
<div class="method-source-code" id="adjacted_with-source">
|
291
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 40</span>
|
292
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">adjacted_with</span>(<span class="ruby-identifier">vertex</span>)
|
293
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Graph does not contain vertex #{vertex}"</span>) <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">vertex</span>)
|
294
|
+
<span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">vertex</span>].<span class="ruby-identifier">clone</span>
|
295
|
+
<span class="ruby-keyword">end</span></pre>
|
296
|
+
</div>
|
297
|
+
|
298
|
+
</div>
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
</div>
|
304
|
+
|
305
|
+
|
306
|
+
<div id="method-i-delete_edge-21" class="method-detail ">
|
307
|
+
|
308
|
+
<div class="method-heading">
|
309
|
+
<span class="method-name">delete_edge!</span><span
|
310
|
+
class="method-args">(from, to)</span>
|
311
|
+
|
312
|
+
<span class="method-click-advice">click to toggle source</span>
|
313
|
+
|
314
|
+
</div>
|
315
|
+
|
316
|
+
|
317
|
+
<div class="method-description">
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
<div class="method-source-code" id="delete_edge-21-source">
|
325
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 115</span>
|
326
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
327
|
+
<span class="ruby-identifier">protected_delete_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
328
|
+
<span class="ruby-ivar">@edge_number</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
|
329
|
+
<span class="ruby-keyword">end</span></pre>
|
330
|
+
</div>
|
331
|
+
|
332
|
+
</div>
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
</div>
|
338
|
+
|
339
|
+
|
340
|
+
<div id="method-i-delete_vertex-21" class="method-detail ">
|
341
|
+
|
342
|
+
<div class="method-heading">
|
343
|
+
<span class="method-name">delete_vertex!</span><span
|
344
|
+
class="method-args">(vertex)</span>
|
345
|
+
|
346
|
+
<span class="method-click-advice">click to toggle source</span>
|
347
|
+
|
348
|
+
</div>
|
349
|
+
|
350
|
+
|
351
|
+
<div class="method-description">
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
<div class="method-source-code" id="delete_vertex-21-source">
|
359
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 101</span>
|
360
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_vertex!</span>(<span class="ruby-identifier">vertex</span>)
|
361
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">has_vertex?</span>(<span class="ruby-identifier">vertex</span>)
|
362
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
363
|
+
<span class="ruby-identifier">delete_edge!</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">vertex</span>)
|
364
|
+
<span class="ruby-keyword">end</span>
|
365
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">vertex</span>)
|
366
|
+
<span class="ruby-ivar">@vertex_labels</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">vertex</span>)
|
367
|
+
|
368
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span><span class="ruby-operator">|</span>
|
369
|
+
<span class="ruby-ivar">@edge_labels</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">Pair</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">vertex</span>, <span class="ruby-identifier">key</span>))
|
370
|
+
<span class="ruby-keyword">end</span>
|
371
|
+
<span class="ruby-keyword">end</span>
|
372
|
+
<span class="ruby-keyword">end</span></pre>
|
373
|
+
</div>
|
374
|
+
|
375
|
+
</div>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
</div>
|
381
|
+
|
382
|
+
|
383
|
+
<div id="method-i-edge_label_number" class="method-detail ">
|
384
|
+
|
385
|
+
<div class="method-heading">
|
386
|
+
<span class="method-name">edge_label_number</span><span
|
387
|
+
class="method-args">()</span>
|
388
|
+
|
389
|
+
<span class="method-click-advice">click to toggle source</span>
|
390
|
+
|
391
|
+
</div>
|
392
|
+
|
393
|
+
|
394
|
+
<div class="method-description">
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
<div class="method-source-code" id="edge_label_number-source">
|
402
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 89</span>
|
403
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">edge_label_number</span>
|
404
|
+
<span class="ruby-ivar">@edge_labels</span>.<span class="ruby-identifier">count</span>
|
405
|
+
<span class="ruby-keyword">end</span></pre>
|
406
|
+
</div>
|
407
|
+
|
408
|
+
</div>
|
409
|
+
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
</div>
|
414
|
+
|
415
|
+
|
416
|
+
<div id="method-i-edge_number" class="method-detail ">
|
417
|
+
|
418
|
+
<div class="method-heading">
|
419
|
+
<span class="method-name">edge_number</span><span
|
420
|
+
class="method-args">()</span>
|
421
|
+
|
422
|
+
<span class="method-click-advice">click to toggle source</span>
|
423
|
+
|
424
|
+
</div>
|
425
|
+
|
426
|
+
|
427
|
+
<div class="method-description">
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
<div class="method-source-code" id="edge_number-source">
|
435
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 81</span>
|
436
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">edge_number</span>
|
437
|
+
<span class="ruby-ivar">@edge_number</span>
|
438
|
+
<span class="ruby-keyword">end</span></pre>
|
439
|
+
</div>
|
440
|
+
|
441
|
+
</div>
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
</div>
|
447
|
+
|
448
|
+
|
449
|
+
<div id="method-i-get_edge_label" class="method-detail ">
|
450
|
+
|
451
|
+
<div class="method-heading">
|
452
|
+
<span class="method-name">get_edge_label</span><span
|
453
|
+
class="method-args">(from, to)</span>
|
454
|
+
|
455
|
+
<span class="method-click-advice">click to toggle source</span>
|
456
|
+
|
457
|
+
</div>
|
458
|
+
|
459
|
+
|
460
|
+
<div class="method-description">
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
<div class="method-source-code" id="get_edge_label-source">
|
468
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 61</span>
|
469
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_edge_label</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
470
|
+
<span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">from</span>) <span class="ruby-operator">||</span> <span class="ruby-operator">!</span> <span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">to</span>)
|
471
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Graph does not contain edge (#{from}, #{to})"</span>)
|
472
|
+
<span class="ruby-keyword">end</span>
|
473
|
+
|
474
|
+
<span class="ruby-ivar">@edge_labels</span>[<span class="ruby-constant">Pair</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)]
|
475
|
+
<span class="ruby-keyword">end</span></pre>
|
476
|
+
</div>
|
477
|
+
|
478
|
+
</div>
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
</div>
|
484
|
+
|
485
|
+
|
486
|
+
<div id="method-i-get_vertex_label" class="method-detail ">
|
487
|
+
|
488
|
+
<div class="method-heading">
|
489
|
+
<span class="method-name">get_vertex_label</span><span
|
490
|
+
class="method-args">(vertex)</span>
|
491
|
+
|
492
|
+
<span class="method-click-advice">click to toggle source</span>
|
493
|
+
|
494
|
+
</div>
|
495
|
+
|
496
|
+
|
497
|
+
<div class="method-description">
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
<div class="method-source-code" id="get_vertex_label-source">
|
505
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 69</span>
|
506
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_vertex_label</span>(<span class="ruby-identifier">vertex</span>)
|
507
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">vertex</span>)
|
508
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Graph does not contain vertex #{vertex}"</span>)
|
509
|
+
<span class="ruby-keyword">end</span>
|
510
|
+
|
511
|
+
<span class="ruby-ivar">@vertex_labels</span>[<span class="ruby-identifier">vertex</span>]
|
512
|
+
<span class="ruby-keyword">end</span></pre>
|
513
|
+
</div>
|
514
|
+
|
515
|
+
</div>
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
</div>
|
521
|
+
|
522
|
+
|
523
|
+
<div id="method-i-has_edge-3F" class="method-detail ">
|
524
|
+
|
525
|
+
<div class="method-heading">
|
526
|
+
<span class="method-name">has_edge?</span><span
|
527
|
+
class="method-args">(from, to)</span>
|
528
|
+
|
529
|
+
<span class="method-click-advice">click to toggle source</span>
|
530
|
+
|
531
|
+
</div>
|
532
|
+
|
533
|
+
|
534
|
+
<div class="method-description">
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
<div class="method-source-code" id="has_edge-3F-source">
|
542
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 97</span>
|
543
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">has_edge?</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
544
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">from</span>) <span class="ruby-operator">&&</span> <span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">to</span>)
|
545
|
+
<span class="ruby-keyword">end</span></pre>
|
546
|
+
</div>
|
547
|
+
|
548
|
+
</div>
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
</div>
|
554
|
+
|
555
|
+
|
556
|
+
<div id="method-i-has_vertex-3F" class="method-detail ">
|
557
|
+
|
558
|
+
<div class="method-heading">
|
559
|
+
<span class="method-name">has_vertex?</span><span
|
560
|
+
class="method-args">(vertex)</span>
|
561
|
+
|
562
|
+
<span class="method-click-advice">click to toggle source</span>
|
563
|
+
|
564
|
+
</div>
|
565
|
+
|
566
|
+
|
567
|
+
<div class="method-description">
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
<div class="method-source-code" id="has_vertex-3F-source">
|
575
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 93</span>
|
576
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">has_vertex?</span>(<span class="ruby-identifier">vertex</span>)
|
577
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">vertex</span>)
|
578
|
+
<span class="ruby-keyword">end</span></pre>
|
579
|
+
</div>
|
580
|
+
|
581
|
+
</div>
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
</div>
|
587
|
+
|
588
|
+
|
589
|
+
<div id="method-i-label_edge-21" class="method-detail ">
|
590
|
+
|
591
|
+
<div class="method-heading">
|
592
|
+
<span class="method-name">label_edge!</span><span
|
593
|
+
class="method-args">(from, to, label)</span>
|
594
|
+
|
595
|
+
<span class="method-click-advice">click to toggle source</span>
|
596
|
+
|
597
|
+
</div>
|
598
|
+
|
599
|
+
|
600
|
+
<div class="method-description">
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
<div class="method-source-code" id="label_edge-21-source">
|
608
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 45</span>
|
609
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">label_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>, <span class="ruby-identifier">label</span>)
|
610
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">from</span>) <span class="ruby-operator">&&</span> <span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">to</span>)
|
611
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Graph does not contain edge (#{from}, #{to})"</span>)
|
612
|
+
<span class="ruby-keyword">end</span>
|
613
|
+
|
614
|
+
<span class="ruby-ivar">@edge_labels</span>[<span class="ruby-constant">Pair</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)] = <span class="ruby-identifier">label</span>
|
615
|
+
<span class="ruby-keyword">end</span></pre>
|
616
|
+
</div>
|
617
|
+
|
618
|
+
</div>
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
</div>
|
624
|
+
|
625
|
+
|
626
|
+
<div id="method-i-label_vertex-21" class="method-detail ">
|
627
|
+
|
628
|
+
<div class="method-heading">
|
629
|
+
<span class="method-name">label_vertex!</span><span
|
630
|
+
class="method-args">(vertex, label)</span>
|
631
|
+
|
632
|
+
<span class="method-click-advice">click to toggle source</span>
|
633
|
+
|
634
|
+
</div>
|
635
|
+
|
636
|
+
|
637
|
+
<div class="method-description">
|
638
|
+
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
|
643
|
+
|
644
|
+
<div class="method-source-code" id="label_vertex-21-source">
|
645
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 53</span>
|
646
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">label_vertex!</span>(<span class="ruby-identifier">vertex</span>, <span class="ruby-identifier">label</span>)
|
647
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">vertex</span>)
|
648
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">"Graph does not contain vertex #{vertex}"</span>)
|
649
|
+
<span class="ruby-keyword">end</span>
|
650
|
+
|
651
|
+
<span class="ruby-ivar">@vertex_labels</span>[<span class="ruby-identifier">vertex</span>] = <span class="ruby-identifier">label</span>
|
652
|
+
<span class="ruby-keyword">end</span></pre>
|
653
|
+
</div>
|
654
|
+
|
655
|
+
</div>
|
656
|
+
|
657
|
+
|
658
|
+
|
659
|
+
|
660
|
+
</div>
|
661
|
+
|
662
|
+
|
663
|
+
<div id="method-i-reverse-21" class="method-detail ">
|
664
|
+
|
665
|
+
<div class="method-heading">
|
666
|
+
<span class="method-name">reverse!</span><span
|
667
|
+
class="method-args">()</span>
|
668
|
+
|
669
|
+
<span class="method-click-advice">click to toggle source</span>
|
670
|
+
|
671
|
+
</div>
|
672
|
+
|
673
|
+
|
674
|
+
<div class="method-description">
|
675
|
+
|
676
|
+
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
<div class="method-source-code" id="reverse-21-source">
|
682
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 120</span>
|
683
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">reverse!</span>
|
684
|
+
<span class="ruby-identifier">v</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>()
|
685
|
+
<span class="ruby-identifier">l</span> = {}
|
686
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">from</span><span class="ruby-operator">|</span>
|
687
|
+
<span class="ruby-identifier">v</span>[<span class="ruby-identifier">from</span>] = [].<span class="ruby-identifier">to_set</span>
|
688
|
+
<span class="ruby-keyword">end</span>
|
689
|
+
|
690
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">from</span><span class="ruby-operator">|</span>
|
691
|
+
<span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">to</span><span class="ruby-operator">|</span>
|
692
|
+
<span class="ruby-identifier">v</span>[<span class="ruby-identifier">to</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">from</span>
|
693
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@edge_labels</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-constant">Pair</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>))
|
694
|
+
<span class="ruby-identifier">l</span>[<span class="ruby-constant">Pair</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">to</span>, <span class="ruby-identifier">from</span>)] = <span class="ruby-ivar">@edge_labels</span>[<span class="ruby-constant">Pair</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)]
|
695
|
+
<span class="ruby-keyword">end</span>
|
696
|
+
<span class="ruby-keyword">end</span>
|
697
|
+
<span class="ruby-keyword">end</span>
|
698
|
+
<span class="ruby-ivar">@vertices</span> = <span class="ruby-identifier">v</span>
|
699
|
+
<span class="ruby-ivar">@edge_labels</span> = <span class="ruby-identifier">l</span>
|
700
|
+
<span class="ruby-keyword">end</span></pre>
|
701
|
+
</div>
|
702
|
+
|
703
|
+
</div>
|
704
|
+
|
705
|
+
|
706
|
+
|
707
|
+
|
708
|
+
</div>
|
709
|
+
|
710
|
+
|
711
|
+
<div id="method-i-vertex_label_number" class="method-detail ">
|
712
|
+
|
713
|
+
<div class="method-heading">
|
714
|
+
<span class="method-name">vertex_label_number</span><span
|
715
|
+
class="method-args">()</span>
|
716
|
+
|
717
|
+
<span class="method-click-advice">click to toggle source</span>
|
718
|
+
|
719
|
+
</div>
|
720
|
+
|
721
|
+
|
722
|
+
<div class="method-description">
|
723
|
+
|
724
|
+
|
725
|
+
|
726
|
+
|
727
|
+
|
728
|
+
|
729
|
+
<div class="method-source-code" id="vertex_label_number-source">
|
730
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 85</span>
|
731
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">vertex_label_number</span>
|
732
|
+
<span class="ruby-ivar">@vertex_labels</span>.<span class="ruby-identifier">count</span>
|
733
|
+
<span class="ruby-keyword">end</span></pre>
|
734
|
+
</div>
|
735
|
+
|
736
|
+
</div>
|
737
|
+
|
738
|
+
|
739
|
+
|
740
|
+
|
741
|
+
</div>
|
742
|
+
|
743
|
+
|
744
|
+
<div id="method-i-vertex_number" class="method-detail ">
|
745
|
+
|
746
|
+
<div class="method-heading">
|
747
|
+
<span class="method-name">vertex_number</span><span
|
748
|
+
class="method-args">()</span>
|
749
|
+
|
750
|
+
<span class="method-click-advice">click to toggle source</span>
|
751
|
+
|
752
|
+
</div>
|
753
|
+
|
754
|
+
|
755
|
+
<div class="method-description">
|
756
|
+
|
757
|
+
|
758
|
+
|
759
|
+
|
760
|
+
|
761
|
+
|
762
|
+
<div class="method-source-code" id="vertex_number-source">
|
763
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 77</span>
|
764
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">vertex_number</span>
|
765
|
+
<span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">count</span>
|
766
|
+
<span class="ruby-keyword">end</span></pre>
|
767
|
+
</div>
|
768
|
+
|
769
|
+
</div>
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
|
774
|
+
</div>
|
775
|
+
|
776
|
+
|
777
|
+
<div id="method-i-vertices" class="method-detail ">
|
778
|
+
|
779
|
+
<div class="method-heading">
|
780
|
+
<span class="method-name">vertices</span><span
|
781
|
+
class="method-args">()</span>
|
782
|
+
|
783
|
+
<span class="method-click-advice">click to toggle source</span>
|
784
|
+
|
785
|
+
</div>
|
786
|
+
|
787
|
+
|
788
|
+
<div class="method-description">
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
|
793
|
+
|
794
|
+
|
795
|
+
<div class="method-source-code" id="vertices-source">
|
796
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 139</span>
|
797
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">vertices</span>
|
798
|
+
<span class="ruby-ivar">@vertices</span>
|
799
|
+
<span class="ruby-keyword">end</span></pre>
|
800
|
+
</div>
|
801
|
+
|
802
|
+
</div>
|
803
|
+
|
804
|
+
|
805
|
+
|
806
|
+
|
807
|
+
</div>
|
808
|
+
|
809
|
+
|
810
|
+
</section>
|
811
|
+
|
812
|
+
<section id="protected-instance-5Buntitled-5D-method-details" class="method-section">
|
813
|
+
<header>
|
814
|
+
<h3>Protected Instance Methods</h3>
|
815
|
+
</header>
|
816
|
+
|
817
|
+
|
818
|
+
<div id="method-i-protected_add_edge-21" class="method-detail ">
|
819
|
+
|
820
|
+
<div class="method-heading">
|
821
|
+
<span class="method-name">protected_add_edge!</span><span
|
822
|
+
class="method-args">(from, to)</span>
|
823
|
+
|
824
|
+
<span class="method-click-advice">click to toggle source</span>
|
825
|
+
|
826
|
+
</div>
|
827
|
+
|
828
|
+
|
829
|
+
<div class="method-description">
|
830
|
+
|
831
|
+
|
832
|
+
|
833
|
+
|
834
|
+
|
835
|
+
|
836
|
+
<div class="method-source-code" id="protected_add_edge-21-source">
|
837
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 145</span>
|
838
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">protected_add_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
839
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">from</span>) <span class="ruby-operator">&&</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">to</span>)
|
840
|
+
<span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">to</span>
|
841
|
+
<span class="ruby-keyword">end</span>
|
842
|
+
<span class="ruby-keyword">end</span></pre>
|
843
|
+
</div>
|
844
|
+
|
845
|
+
</div>
|
846
|
+
|
847
|
+
|
848
|
+
|
849
|
+
|
850
|
+
</div>
|
851
|
+
|
852
|
+
|
853
|
+
<div id="method-i-protected_delete_edge-21" class="method-detail ">
|
854
|
+
|
855
|
+
<div class="method-heading">
|
856
|
+
<span class="method-name">protected_delete_edge!</span><span
|
857
|
+
class="method-args">(from, to)</span>
|
858
|
+
|
859
|
+
<span class="method-click-advice">click to toggle source</span>
|
860
|
+
|
861
|
+
</div>
|
862
|
+
|
863
|
+
|
864
|
+
<div class="method-description">
|
865
|
+
|
866
|
+
|
867
|
+
|
868
|
+
|
869
|
+
|
870
|
+
|
871
|
+
<div class="method-source-code" id="protected_delete_edge-21-source">
|
872
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 151</span>
|
873
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">protected_delete_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
874
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">has_edge?</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
|
875
|
+
<span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">to</span>)
|
876
|
+
<span class="ruby-ivar">@edge_labels</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">Pair</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>))
|
877
|
+
<span class="ruby-keyword">end</span>
|
878
|
+
<span class="ruby-keyword">end</span></pre>
|
879
|
+
</div>
|
880
|
+
|
881
|
+
</div>
|
882
|
+
|
883
|
+
|
884
|
+
|
885
|
+
|
886
|
+
</div>
|
887
|
+
|
888
|
+
|
889
|
+
</section>
|
890
|
+
|
891
|
+
</section>
|
892
|
+
|
893
|
+
</main>
|
894
|
+
|
895
|
+
|
896
|
+
<footer id="validator-badges" role="contentinfo">
|
897
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
898
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
899
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
900
|
+
</footer>
|
901
|
+
|