silicium 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.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
data/docs/Silicium/Graphs.html
CHANGED
@@ -1,164 +1,374 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta charset="UTF-8">
|
6
|
-
|
7
|
-
<title>module Silicium::Graphs - 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="#method-i-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
</
|
78
|
-
|
79
|
-
<
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
</
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module Silicium::Graphs - 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="#method-i-add_to_queue">#add_to_queue</a>
|
72
|
+
|
73
|
+
<li ><a href="#method-i-breadth_first_search-3F">#breadth_first_search?</a>
|
74
|
+
|
75
|
+
<li ><a href="#method-i-connected-3F">#connected?</a>
|
76
|
+
|
77
|
+
<li ><a href="#method-i-dfu">#dfu</a>
|
78
|
+
|
79
|
+
<li ><a href="#method-i-dijkstra_algorythm">#dijkstra_algorythm</a>
|
80
|
+
|
81
|
+
<li ><a href="#method-i-number_of_connected">#number_of_connected</a>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
</nav>
|
88
|
+
|
89
|
+
<main role="main" aria-labelledby="module-Silicium::Graphs">
|
90
|
+
<h1 id="module-Silicium::Graphs" class="module">
|
91
|
+
module Silicium::Graphs
|
92
|
+
</h1>
|
93
|
+
|
94
|
+
<section class="description">
|
95
|
+
|
96
|
+
</section>
|
97
|
+
|
98
|
+
|
99
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<section class="constants-list">
|
106
|
+
<header>
|
107
|
+
<h3>Constants</h3>
|
108
|
+
</header>
|
109
|
+
<dl>
|
110
|
+
|
111
|
+
<dt id="Pair">Pair
|
112
|
+
|
113
|
+
<dd>
|
114
|
+
|
115
|
+
|
116
|
+
</dl>
|
117
|
+
</section>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
124
|
+
<header>
|
125
|
+
<h3>Public Instance Methods</h3>
|
126
|
+
</header>
|
127
|
+
|
128
|
+
|
129
|
+
<div id="method-i-add_to_queue" class="method-detail ">
|
130
|
+
|
131
|
+
<div class="method-heading">
|
132
|
+
<span class="method-name">add_to_queue</span><span
|
133
|
+
class="method-args">(graph, queue, node, visited)</span>
|
134
|
+
|
135
|
+
<span class="method-click-advice">click to toggle source</span>
|
136
|
+
|
137
|
+
</div>
|
138
|
+
|
139
|
+
|
140
|
+
<div class="method-description">
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<div class="method-source-code" id="add_to_queue-source">
|
148
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 196</span>
|
149
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_to_queue</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">queue</span>, <span class="ruby-identifier">node</span>, <span class="ruby-identifier">visited</span>)
|
150
|
+
<span class="ruby-identifier">graph</span>.<span class="ruby-identifier">vertices</span>[<span class="ruby-identifier">node</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
|
151
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">visited</span>[<span class="ruby-identifier">child</span>]
|
152
|
+
<span class="ruby-identifier">queue</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">child</span>)
|
153
|
+
<span class="ruby-identifier">visited</span>[<span class="ruby-identifier">child</span>] = <span class="ruby-keyword">true</span>
|
154
|
+
<span class="ruby-keyword">end</span>
|
155
|
+
<span class="ruby-keyword">end</span>
|
156
|
+
<span class="ruby-keyword">end</span></pre>
|
157
|
+
</div>
|
158
|
+
|
159
|
+
</div>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
</div>
|
165
|
+
|
166
|
+
|
167
|
+
<div id="method-i-breadth_first_search-3F" class="method-detail ">
|
168
|
+
|
169
|
+
<div class="method-heading">
|
170
|
+
<span class="method-name">breadth_first_search?</span><span
|
171
|
+
class="method-args">(graph, start, goal)</span>
|
172
|
+
|
173
|
+
<span class="method-click-advice">click to toggle source</span>
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
|
178
|
+
<div class="method-description">
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<div class="method-source-code" id="breadth_first_search-3F-source">
|
186
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 181</span>
|
187
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">breadth_first_search?</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">start</span>, <span class="ruby-identifier">goal</span>)
|
188
|
+
<span class="ruby-identifier">visited</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">false</span>)
|
189
|
+
<span class="ruby-identifier">queue</span> = <span class="ruby-constant">Queue</span>.<span class="ruby-identifier">new</span>
|
190
|
+
<span class="ruby-identifier">queue</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">start</span>)
|
191
|
+
<span class="ruby-identifier">visited</span>[<span class="ruby-identifier">start</span>] = <span class="ruby-keyword">true</span>
|
192
|
+
<span class="ruby-keyword">until</span> <span class="ruby-identifier">queue</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">do</span>
|
193
|
+
<span class="ruby-identifier">node</span> = <span class="ruby-identifier">queue</span>.<span class="ruby-identifier">pop</span>
|
194
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">node</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">goal</span>
|
195
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
|
196
|
+
<span class="ruby-keyword">end</span>
|
197
|
+
<span class="ruby-identifier">add_to_queue</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">queue</span>, <span class="ruby-identifier">node</span>, <span class="ruby-identifier">visited</span>)
|
198
|
+
<span class="ruby-keyword">end</span>
|
199
|
+
<span class="ruby-keyword">false</span>
|
200
|
+
<span class="ruby-keyword">end</span></pre>
|
201
|
+
</div>
|
202
|
+
|
203
|
+
</div>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
</div>
|
209
|
+
|
210
|
+
|
211
|
+
<div id="method-i-connected-3F" class="method-detail ">
|
212
|
+
|
213
|
+
<div class="method-heading">
|
214
|
+
<span class="method-name">connected?</span><span
|
215
|
+
class="method-args">(graph)</span>
|
216
|
+
|
217
|
+
<span class="method-click-advice">click to toggle source</span>
|
218
|
+
|
219
|
+
</div>
|
220
|
+
|
221
|
+
|
222
|
+
<div class="method-description">
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
<div class="method-source-code" id="connected-3F-source">
|
230
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 205</span>
|
231
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">connected?</span>(<span class="ruby-identifier">graph</span>)
|
232
|
+
<span class="ruby-identifier">start</span> = <span class="ruby-identifier">graph</span>.<span class="ruby-identifier">vertices</span>.<span class="ruby-identifier">keys</span>[<span class="ruby-value">0</span>]
|
233
|
+
<span class="ruby-identifier">goal</span> = <span class="ruby-identifier">graph</span>.<span class="ruby-identifier">vertices</span>.<span class="ruby-identifier">keys</span>[<span class="ruby-identifier">graph</span>.<span class="ruby-identifier">vertex_number</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>]
|
234
|
+
<span class="ruby-identifier">pred</span> = <span class="ruby-identifier">breadth_first_search?</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">start</span>, <span class="ruby-identifier">goal</span>)
|
235
|
+
<span class="ruby-identifier">graph</span>.<span class="ruby-identifier">reverse!</span>
|
236
|
+
<span class="ruby-identifier">pred</span> = <span class="ruby-identifier">pred</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">breadth_first_search?</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">goal</span>, <span class="ruby-identifier">start</span>)
|
237
|
+
<span class="ruby-identifier">graph</span>.<span class="ruby-identifier">reverse!</span>
|
238
|
+
<span class="ruby-identifier">pred</span>
|
239
|
+
<span class="ruby-keyword">end</span></pre>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
</div>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
</div>
|
248
|
+
|
249
|
+
|
250
|
+
<div id="method-i-dfu" class="method-detail ">
|
251
|
+
|
252
|
+
<div class="method-heading">
|
253
|
+
<span class="method-name">dfu</span><span
|
254
|
+
class="method-args">(graph, vertice, visited)</span>
|
255
|
+
|
256
|
+
<span class="method-click-advice">click to toggle source</span>
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
<div class="method-description">
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
<div class="method-source-code" id="dfu-source">
|
269
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 227</span>
|
270
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">dfu</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">vertice</span>, <span class="ruby-identifier">visited</span>)
|
271
|
+
<span class="ruby-identifier">visited</span>[<span class="ruby-identifier">vertice</span>] = <span class="ruby-keyword">true</span>
|
272
|
+
<span class="ruby-identifier">graph</span>.<span class="ruby-identifier">vertices</span>[<span class="ruby-identifier">vertice</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
|
273
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">visited</span>[<span class="ruby-identifier">item</span>]
|
274
|
+
<span class="ruby-identifier">dfu</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">item</span>, <span class="ruby-identifier">visited</span>)
|
275
|
+
<span class="ruby-keyword">end</span>
|
276
|
+
<span class="ruby-keyword">end</span>
|
277
|
+
<span class="ruby-keyword">end</span></pre>
|
278
|
+
</div>
|
279
|
+
|
280
|
+
</div>
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
</div>
|
286
|
+
|
287
|
+
|
288
|
+
<div id="method-i-dijkstra_algorythm" class="method-detail ">
|
289
|
+
|
290
|
+
<div class="method-heading">
|
291
|
+
<span class="method-name">dijkstra_algorythm</span><span
|
292
|
+
class="method-args">(graph, starting_vertex)</span>
|
293
|
+
|
294
|
+
<span class="method-click-advice">click to toggle source</span>
|
295
|
+
|
296
|
+
</div>
|
297
|
+
|
298
|
+
|
299
|
+
<div class="method-description">
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
<div class="method-source-code" id="dijkstra_algorythm-source">
|
307
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 236</span>
|
308
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">dijkstra_algorythm</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">starting_vertex</span>)
|
309
|
+
<span class="ruby-comment">#</span>
|
310
|
+
<span class="ruby-keyword">end</span></pre>
|
311
|
+
</div>
|
312
|
+
|
313
|
+
</div>
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
</div>
|
319
|
+
|
320
|
+
|
321
|
+
<div id="method-i-number_of_connected" class="method-detail ">
|
322
|
+
|
323
|
+
<div class="method-heading">
|
324
|
+
<span class="method-name">number_of_connected</span><span
|
325
|
+
class="method-args">(graph)</span>
|
326
|
+
|
327
|
+
<span class="method-click-advice">click to toggle source</span>
|
328
|
+
|
329
|
+
</div>
|
330
|
+
|
331
|
+
|
332
|
+
<div class="method-description">
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
<div class="method-source-code" id="number_of_connected-source">
|
340
|
+
<pre><span class="ruby-comment"># File lib/graph.rb, line 215</span>
|
341
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">number_of_connected</span>(<span class="ruby-identifier">graph</span>)
|
342
|
+
<span class="ruby-identifier">visited</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">false</span>)
|
343
|
+
<span class="ruby-identifier">res</span> = <span class="ruby-value">0</span>
|
344
|
+
<span class="ruby-identifier">graph</span>.<span class="ruby-identifier">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">v</span><span class="ruby-operator">|</span>
|
345
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">visited</span>[<span class="ruby-identifier">v</span>]
|
346
|
+
<span class="ruby-identifier">dfu</span>(<span class="ruby-identifier">graph</span>, <span class="ruby-identifier">v</span>, <span class="ruby-identifier">visited</span>)
|
347
|
+
<span class="ruby-identifier">res</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
348
|
+
<span class="ruby-keyword">end</span>
|
349
|
+
<span class="ruby-keyword">end</span>
|
350
|
+
<span class="ruby-identifier">res</span>
|
351
|
+
<span class="ruby-keyword">end</span></pre>
|
352
|
+
</div>
|
353
|
+
|
354
|
+
</div>
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
</div>
|
360
|
+
|
361
|
+
|
362
|
+
</section>
|
363
|
+
|
364
|
+
</section>
|
365
|
+
|
366
|
+
</main>
|
367
|
+
|
368
|
+
|
369
|
+
<footer id="validator-badges" role="contentinfo">
|
370
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
371
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
372
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
373
|
+
</footer>
|
374
|
+
|