silicium 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +3 -3
  3. data/.gitignore +13 -13
  4. data/.rakeTasks +8 -0
  5. data/.travis.yml +28 -25
  6. data/CODE_OF_CONDUCT.md +74 -74
  7. data/Gemfile +8 -8
  8. data/LICENSE.txt +21 -21
  9. data/Makefile +269 -269
  10. data/README.md +588 -46
  11. data/Rakefile +16 -16
  12. data/bin/console +14 -14
  13. data/bin/setup +8 -8
  14. data/docs/Object.html +117 -117
  15. data/docs/README_md.html +142 -142
  16. data/docs/Silicium/Combinatorics.html +270 -270
  17. data/docs/Silicium/Dice/Polyhedron.html +315 -315
  18. data/docs/Silicium/Dice/PolyhedronSet.html +321 -321
  19. data/docs/Silicium/Dice.html +99 -99
  20. data/docs/Silicium/Error.html +106 -106
  21. data/docs/Silicium/Geometry/Line2dCanon.html +243 -243
  22. data/docs/Silicium/Geometry/VariablesOrderException.html +106 -106
  23. data/docs/Silicium/Geometry.html +940 -940
  24. data/docs/Silicium/GraphVisualizer.html +226 -0
  25. data/docs/Silicium/Graphs/GraphError.html +106 -106
  26. data/docs/Silicium/Graphs/OrientedGraph.html +901 -775
  27. data/docs/Silicium/Graphs/UnorientedGraph.html +237 -284
  28. data/docs/Silicium/Graphs.html +374 -164
  29. data/docs/Silicium/IntegralDoesntExistError.html +106 -106
  30. data/docs/Silicium/NumericalIntegration.html +521 -521
  31. data/docs/Silicium/Optimization.html +629 -639
  32. data/docs/Silicium/Plotter/Image.html +297 -297
  33. data/docs/Silicium/Plotter.html +186 -186
  34. data/docs/Silicium.html +101 -101
  35. data/docs/created.rid +9 -9
  36. data/docs/css/fonts.css +167 -167
  37. data/docs/css/rdoc.css +619 -619
  38. data/docs/index.html +134 -132
  39. data/docs/js/darkfish.js +84 -84
  40. data/docs/js/navigation.js +105 -105
  41. data/docs/js/search.js +110 -110
  42. data/docs/js/search_index.js +1 -1
  43. data/docs/js/search_index.js.gz +0 -0
  44. data/docs/js/searcher.js +229 -229
  45. data/docs/table_of_contents.html +697 -608
  46. data/lib/algebra.rb +452 -0
  47. data/lib/algebra_diff.rb +258 -0
  48. data/lib/geometry/figure.rb +62 -0
  49. data/lib/geometry.rb +290 -236
  50. data/lib/geometry3d.rb +270 -0
  51. data/lib/graph/dfs.rb +42 -0
  52. data/lib/graph/kruskal.rb +36 -0
  53. data/lib/graph/scc.rb +97 -0
  54. data/lib/graph.rb +350 -164
  55. data/lib/graph_visualizer.rb +287 -0
  56. data/lib/ml_algorithms.rb +181 -0
  57. data/lib/numerical_integration.rb +184 -147
  58. data/lib/optimization.rb +209 -144
  59. data/lib/plotter.rb +256 -96
  60. data/lib/polynomial_division.rb +132 -0
  61. data/lib/polynomial_interpolation.rb +94 -0
  62. data/lib/regression.rb +120 -0
  63. data/lib/silicium/adding.rb +37 -0
  64. data/lib/silicium/conversions.rb +23 -0
  65. data/lib/silicium/multi.rb +82 -0
  66. data/lib/silicium/sparse.rb +76 -0
  67. data/lib/silicium/sugar.rb +37 -0
  68. data/lib/silicium/trans.rb +26 -0
  69. data/lib/silicium/version.rb +3 -3
  70. data/lib/silicium.rb +5 -5
  71. data/lib/theory_of_probability.rb +240 -226
  72. data/lib/topological_sort.rb +50 -0
  73. data/oriented_graph.png +0 -0
  74. data/plot.png +0 -0
  75. data/silicium.gemspec +38 -39
  76. 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-add_edge_force-21">#add_edge_force!</a>
83
-
84
- <li ><a href="#method-i-add_vertex-21">#add_vertex!</a>
85
-
86
- <li ><a href="#method-i-adjacted_with">#adjacted_with</a>
87
-
88
- <li ><a href="#method-i-delete_edge-21">#delete_edge!</a>
89
-
90
- <li ><a href="#method-i-delete_vertex-21">#delete_vertex!</a>
91
-
92
- <li ><a href="#method-i-edge_label_number">#edge_label_number</a>
93
-
94
- <li ><a href="#method-i-edge_number">#edge_number</a>
95
-
96
- <li ><a href="#method-i-get_edge_label">#get_edge_label</a>
97
-
98
- <li ><a href="#method-i-get_vertex_label">#get_vertex_label</a>
99
-
100
- <li ><a href="#method-i-has_edge-3F">#has_edge?</a>
101
-
102
- <li ><a href="#method-i-has_vertex-3F">#has_vertex?</a>
103
-
104
- <li ><a href="#method-i-label_edge-21">#label_edge!</a>
105
-
106
- <li ><a href="#method-i-label_vertex-21">#label_vertex!</a>
107
-
108
- <li ><a href="#method-i-vertex_label_number">#vertex_label_number</a>
109
-
110
- <li ><a href="#method-i-vertex_number">#vertex_number</a>
111
-
112
- </ul>
113
- </div>
114
-
115
- </div>
116
- </nav>
117
-
118
- <main role="main" aria-labelledby="class-Silicium::Graphs::OrientedGraph">
119
- <h1 id="class-Silicium::Graphs::OrientedGraph" class="class">
120
- class Silicium::Graphs::OrientedGraph
121
- </h1>
122
-
123
- <section class="description">
124
-
125
- </section>
126
-
127
-
128
- <section id="5Buntitled-5D" class="documentation-section">
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
139
- <header>
140
- <h3>Public Class Methods</h3>
141
- </header>
142
-
143
-
144
- <div id="method-c-new" class="method-detail ">
145
-
146
- <div class="method-heading">
147
- <span class="method-name">new</span><span
148
- class="method-args">(initializer = [])</span>
149
-
150
- <span class="method-click-advice">click to toggle source</span>
151
-
152
- </div>
153
-
154
-
155
- <div class="method-description">
156
-
157
-
158
-
159
-
160
-
161
-
162
- <div class="method-source-code" id="new-source">
163
- <pre><span class="ruby-comment"># File lib/graph.rb, line 13</span>
164
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">initializer</span> = [])
165
- <span class="ruby-ivar">@vertices</span> = {}
166
- <span class="ruby-ivar">@edge_labels</span> = {}
167
- <span class="ruby-ivar">@vertex_labels</span> = {}
168
- <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>
169
- <span class="ruby-identifier">add_vertex!</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:v</span>])
170
- <span class="ruby-identifier">v</span>[<span class="ruby-value">:i</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">iv</span><span class="ruby-operator">|</span> <span class="ruby-identifier">add_edge_force!</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:v</span>], <span class="ruby-identifier">iv</span>)}
171
- <span class="ruby-keyword">end</span>
172
- <span class="ruby-keyword">end</span></pre>
173
- </div>
174
-
175
- </div>
176
-
177
-
178
-
179
-
180
- </div>
181
-
182
-
183
- </section>
184
-
185
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
186
- <header>
187
- <h3>Public Instance Methods</h3>
188
- </header>
189
-
190
-
191
- <div id="method-i-add_edge-21" class="method-detail ">
192
-
193
- <div class="method-heading">
194
- <span class="method-name">add_edge!</span><span
195
- class="method-args">(from, to)</span>
196
-
197
- <span class="method-click-advice">click to toggle source</span>
198
-
199
- </div>
200
-
201
-
202
- <div class="method-description">
203
-
204
-
205
-
206
-
207
-
208
-
209
- <div class="method-source-code" id="add_edge-21-source">
210
- <pre><span class="ruby-comment"># File lib/graph.rb, line 30</span>
211
- <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>)
212
- <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">&amp;&amp;</span> <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">to</span>)
213
- <span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">to</span>
214
- <span class="ruby-keyword">end</span>
215
- <span class="ruby-keyword">end</span></pre>
216
- </div>
217
-
218
- </div>
219
-
220
-
221
-
222
-
223
- </div>
224
-
225
-
226
- <div id="method-i-add_edge_force-21" class="method-detail ">
227
-
228
- <div class="method-heading">
229
- <span class="method-name">add_edge_force!</span><span
230
- class="method-args">(from, to)</span>
231
-
232
- <span class="method-click-advice">click to toggle source</span>
233
-
234
- </div>
235
-
236
-
237
- <div class="method-description">
238
-
239
- <p>should only be used in constructor</p>
240
-
241
-
242
-
243
-
244
- <div class="method-source-code" id="add_edge_force-21-source">
245
- <pre><span class="ruby-comment"># File lib/graph.rb, line 37</span>
246
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_edge_force!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
247
- <span class="ruby-identifier">add_vertex!</span>(<span class="ruby-identifier">from</span>)
248
- <span class="ruby-identifier">add_vertex!</span>(<span class="ruby-identifier">to</span>)
249
- <span class="ruby-identifier">add_edge!</span>(<span class="ruby-identifier">from</span>, <span class="ruby-identifier">to</span>)
250
- <span class="ruby-keyword">end</span></pre>
251
- </div>
252
-
253
- </div>
254
-
255
-
256
-
257
-
258
- </div>
259
-
260
-
261
- <div id="method-i-add_vertex-21" class="method-detail ">
262
-
263
- <div class="method-heading">
264
- <span class="method-name">add_vertex!</span><span
265
- class="method-args">(vertex_id)</span>
266
-
267
- <span class="method-click-advice">click to toggle source</span>
268
-
269
- </div>
270
-
271
-
272
- <div class="method-description">
273
-
274
-
275
-
276
-
277
-
278
-
279
- <div class="method-source-code" id="add_vertex-21-source">
280
- <pre><span class="ruby-comment"># File lib/graph.rb, line 23</span>
281
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_vertex!</span>(<span class="ruby-identifier">vertex_id</span>)
282
- <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>)
283
- <span class="ruby-keyword">return</span>
284
- <span class="ruby-keyword">end</span>
285
- <span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">vertex_id</span>] = [].<span class="ruby-identifier">to_set</span>
286
- <span class="ruby-keyword">end</span></pre>
287
- </div>
288
-
289
- </div>
290
-
291
-
292
-
293
-
294
- </div>
295
-
296
-
297
- <div id="method-i-adjacted_with" class="method-detail ">
298
-
299
- <div class="method-heading">
300
- <span class="method-name">adjacted_with</span><span
301
- class="method-args">(vertex)</span>
302
-
303
- <span class="method-click-advice">click to toggle source</span>
304
-
305
- </div>
306
-
307
-
308
- <div class="method-description">
309
-
310
-
311
-
312
-
313
-
314
-
315
- <div class="method-source-code" id="adjacted_with-source">
316
- <pre><span class="ruby-comment"># File lib/graph.rb, line 43</span>
317
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">adjacted_with</span>(<span class="ruby-identifier">vertex</span>)
318
- <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>)
319
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Graph does not contain vertex #{vertex}&quot;</span>)
320
- <span class="ruby-keyword">end</span>
321
-
322
- <span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">vertex</span>].<span class="ruby-identifier">clone</span>
323
- <span class="ruby-keyword">end</span></pre>
324
- </div>
325
-
326
- </div>
327
-
328
-
329
-
330
-
331
- </div>
332
-
333
-
334
- <div id="method-i-delete_edge-21" class="method-detail ">
335
-
336
- <div class="method-heading">
337
- <span class="method-name">delete_edge!</span><span
338
- class="method-args">(from, to)</span>
339
-
340
- <span class="method-click-advice">click to toggle source</span>
341
-
342
- </div>
343
-
344
-
345
- <div class="method-description">
346
-
347
-
348
-
349
-
350
-
351
-
352
- <div class="method-source-code" id="delete_edge-21-source">
353
- <pre><span class="ruby-comment"># File lib/graph.rb, line 125</span>
354
- <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>)
355
- <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>)
356
- <span class="ruby-ivar">@vertices</span>[<span class="ruby-identifier">from</span>].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">to</span>)
357
- <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>))
358
- <span class="ruby-keyword">end</span>
359
- <span class="ruby-keyword">end</span></pre>
360
- </div>
361
-
362
- </div>
363
-
364
-
365
-
366
-
367
- </div>
368
-
369
-
370
- <div id="method-i-delete_vertex-21" class="method-detail ">
371
-
372
- <div class="method-heading">
373
- <span class="method-name">delete_vertex!</span><span
374
- class="method-args">(vertex)</span>
375
-
376
- <span class="method-click-advice">click to toggle source</span>
377
-
378
- </div>
379
-
380
-
381
- <div class="method-description">
382
-
383
-
384
-
385
-
386
-
387
-
388
- <div class="method-source-code" id="delete_vertex-21-source">
389
- <pre><span class="ruby-comment"># File lib/graph.rb, line 111</span>
390
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_vertex!</span>(<span class="ruby-identifier">vertex</span>)
391
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">has_vertex?</span>(<span class="ruby-identifier">vertex</span>)
392
- <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>
393
- <span class="ruby-identifier">delete_edge!</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">vertex</span>)
394
- <span class="ruby-keyword">end</span>
395
- <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">vertex</span>)
396
- <span class="ruby-ivar">@vertex_labels</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">vertex</span>)
397
-
398
- <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>
399
- <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>))
400
- <span class="ruby-keyword">end</span>
401
- <span class="ruby-keyword">end</span>
402
- <span class="ruby-keyword">end</span></pre>
403
- </div>
404
-
405
- </div>
406
-
407
-
408
-
409
-
410
- </div>
411
-
412
-
413
- <div id="method-i-edge_label_number" class="method-detail ">
414
-
415
- <div class="method-heading">
416
- <span class="method-name">edge_label_number</span><span
417
- class="method-args">()</span>
418
-
419
- <span class="method-click-advice">click to toggle source</span>
420
-
421
- </div>
422
-
423
-
424
- <div class="method-description">
425
-
426
-
427
-
428
-
429
-
430
-
431
- <div class="method-source-code" id="edge_label_number-source">
432
- <pre><span class="ruby-comment"># File lib/graph.rb, line 99</span>
433
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">edge_label_number</span>
434
- <span class="ruby-ivar">@edge_labels</span>.<span class="ruby-identifier">count</span>
435
- <span class="ruby-keyword">end</span></pre>
436
- </div>
437
-
438
- </div>
439
-
440
-
441
-
442
-
443
- </div>
444
-
445
-
446
- <div id="method-i-edge_number" class="method-detail ">
447
-
448
- <div class="method-heading">
449
- <span class="method-name">edge_number</span><span
450
- class="method-args">()</span>
451
-
452
- <span class="method-click-advice">click to toggle source</span>
453
-
454
- </div>
455
-
456
-
457
- <div class="method-description">
458
-
459
-
460
-
461
-
462
-
463
-
464
- <div class="method-source-code" id="edge_number-source">
465
- <pre><span class="ruby-comment"># File lib/graph.rb, line 87</span>
466
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">edge_number</span>
467
- <span class="ruby-identifier">res</span> = <span class="ruby-value">0</span>
468
- <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">values</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>
469
- <span class="ruby-identifier">res</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">count</span>
470
- <span class="ruby-keyword">end</span>
471
- <span class="ruby-identifier">res</span>
472
- <span class="ruby-keyword">end</span></pre>
473
- </div>
474
-
475
- </div>
476
-
477
-
478
-
479
-
480
- </div>
481
-
482
-
483
- <div id="method-i-get_edge_label" class="method-detail ">
484
-
485
- <div class="method-heading">
486
- <span class="method-name">get_edge_label</span><span
487
- class="method-args">(from, to)</span>
488
-
489
- <span class="method-click-advice">click to toggle source</span>
490
-
491
- </div>
492
-
493
-
494
- <div class="method-description">
495
-
496
-
497
-
498
-
499
-
500
-
501
- <div class="method-source-code" id="get_edge_label-source">
502
- <pre><span class="ruby-comment"># File lib/graph.rb, line 67</span>
503
- <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>)
504
- <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>)
505
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Graph does not contain edge (#{from}, #{to})&quot;</span>)
506
- <span class="ruby-keyword">end</span>
507
-
508
- <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>)]
509
- <span class="ruby-keyword">end</span></pre>
510
- </div>
511
-
512
- </div>
513
-
514
-
515
-
516
-
517
- </div>
518
-
519
-
520
- <div id="method-i-get_vertex_label" class="method-detail ">
521
-
522
- <div class="method-heading">
523
- <span class="method-name">get_vertex_label</span><span
524
- class="method-args">(vertex)</span>
525
-
526
- <span class="method-click-advice">click to toggle source</span>
527
-
528
- </div>
529
-
530
-
531
- <div class="method-description">
532
-
533
-
534
-
535
-
536
-
537
-
538
- <div class="method-source-code" id="get_vertex_label-source">
539
- <pre><span class="ruby-comment"># File lib/graph.rb, line 75</span>
540
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_vertex_label</span>(<span class="ruby-identifier">vertex</span>)
541
- <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>)
542
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Graph does not contain vertex #{vertex}&quot;</span>)
543
- <span class="ruby-keyword">end</span>
544
-
545
- <span class="ruby-ivar">@vertex_labels</span>[<span class="ruby-identifier">vertex</span>]
546
- <span class="ruby-keyword">end</span></pre>
547
- </div>
548
-
549
- </div>
550
-
551
-
552
-
553
-
554
- </div>
555
-
556
-
557
- <div id="method-i-has_edge-3F" class="method-detail ">
558
-
559
- <div class="method-heading">
560
- <span class="method-name">has_edge?</span><span
561
- class="method-args">(from, to)</span>
562
-
563
- <span class="method-click-advice">click to toggle source</span>
564
-
565
- </div>
566
-
567
-
568
- <div class="method-description">
569
-
570
-
571
-
572
-
573
-
574
-
575
- <div class="method-source-code" id="has_edge-3F-source">
576
- <pre><span class="ruby-comment"># File lib/graph.rb, line 107</span>
577
- <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>)
578
- <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">from</span>) <span class="ruby-operator">&amp;&amp;</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>)
579
- <span class="ruby-keyword">end</span></pre>
580
- </div>
581
-
582
- </div>
583
-
584
-
585
-
586
-
587
- </div>
588
-
589
-
590
- <div id="method-i-has_vertex-3F" class="method-detail ">
591
-
592
- <div class="method-heading">
593
- <span class="method-name">has_vertex?</span><span
594
- class="method-args">(vertex)</span>
595
-
596
- <span class="method-click-advice">click to toggle source</span>
597
-
598
- </div>
599
-
600
-
601
- <div class="method-description">
602
-
603
-
604
-
605
-
606
-
607
-
608
- <div class="method-source-code" id="has_vertex-3F-source">
609
- <pre><span class="ruby-comment"># File lib/graph.rb, line 103</span>
610
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">has_vertex?</span>(<span class="ruby-identifier">vertex</span>)
611
- <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">vertex</span>)
612
- <span class="ruby-keyword">end</span></pre>
613
- </div>
614
-
615
- </div>
616
-
617
-
618
-
619
-
620
- </div>
621
-
622
-
623
- <div id="method-i-label_edge-21" class="method-detail ">
624
-
625
- <div class="method-heading">
626
- <span class="method-name">label_edge!</span><span
627
- class="method-args">(from, to, label)</span>
628
-
629
- <span class="method-click-advice">click to toggle source</span>
630
-
631
- </div>
632
-
633
-
634
- <div class="method-description">
635
-
636
-
637
-
638
-
639
-
640
-
641
- <div class="method-source-code" id="label_edge-21-source">
642
- <pre><span class="ruby-comment"># File lib/graph.rb, line 51</span>
643
- <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>)
644
- <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">&amp;&amp;</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>)
645
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Graph does not contain edge (#{from}, #{to})&quot;</span>)
646
- <span class="ruby-keyword">end</span>
647
-
648
- <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>
649
- <span class="ruby-keyword">end</span></pre>
650
- </div>
651
-
652
- </div>
653
-
654
-
655
-
656
-
657
- </div>
658
-
659
-
660
- <div id="method-i-label_vertex-21" class="method-detail ">
661
-
662
- <div class="method-heading">
663
- <span class="method-name">label_vertex!</span><span
664
- class="method-args">(vertex, label)</span>
665
-
666
- <span class="method-click-advice">click to toggle source</span>
667
-
668
- </div>
669
-
670
-
671
- <div class="method-description">
672
-
673
-
674
-
675
-
676
-
677
-
678
- <div class="method-source-code" id="label_vertex-21-source">
679
- <pre><span class="ruby-comment"># File lib/graph.rb, line 59</span>
680
- <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>)
681
- <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>)
682
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">GraphError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;Graph does not contain vertex #{vertex}&quot;</span>)
683
- <span class="ruby-keyword">end</span>
684
-
685
- <span class="ruby-ivar">@vertex_labels</span>[<span class="ruby-identifier">vertex</span>] = <span class="ruby-identifier">label</span>
686
- <span class="ruby-keyword">end</span></pre>
687
- </div>
688
-
689
- </div>
690
-
691
-
692
-
693
-
694
- </div>
695
-
696
-
697
- <div id="method-i-vertex_label_number" class="method-detail ">
698
-
699
- <div class="method-heading">
700
- <span class="method-name">vertex_label_number</span><span
701
- class="method-args">()</span>
702
-
703
- <span class="method-click-advice">click to toggle source</span>
704
-
705
- </div>
706
-
707
-
708
- <div class="method-description">
709
-
710
-
711
-
712
-
713
-
714
-
715
- <div class="method-source-code" id="vertex_label_number-source">
716
- <pre><span class="ruby-comment"># File lib/graph.rb, line 95</span>
717
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">vertex_label_number</span>
718
- <span class="ruby-ivar">@vertex_labels</span>.<span class="ruby-identifier">count</span>
719
- <span class="ruby-keyword">end</span></pre>
720
- </div>
721
-
722
- </div>
723
-
724
-
725
-
726
-
727
- </div>
728
-
729
-
730
- <div id="method-i-vertex_number" class="method-detail ">
731
-
732
- <div class="method-heading">
733
- <span class="method-name">vertex_number</span><span
734
- class="method-args">()</span>
735
-
736
- <span class="method-click-advice">click to toggle source</span>
737
-
738
- </div>
739
-
740
-
741
- <div class="method-description">
742
-
743
-
744
-
745
-
746
-
747
-
748
- <div class="method-source-code" id="vertex_number-source">
749
- <pre><span class="ruby-comment"># File lib/graph.rb, line 83</span>
750
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">vertex_number</span>
751
- <span class="ruby-ivar">@vertices</span>.<span class="ruby-identifier">count</span>
752
- <span class="ruby-keyword">end</span></pre>
753
- </div>
754
-
755
- </div>
756
-
757
-
758
-
759
-
760
- </div>
761
-
762
-
763
- </section>
764
-
765
- </section>
766
-
767
- </main>
768
-
769
-
770
- <footer id="validator-badges" role="contentinfo">
771
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
772
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
773
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
774
- </footer>
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">&quot;Graph does not contain vertex #{vertex}&quot;</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">&quot;Graph does not contain edge (#{from}, #{to})&quot;</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">&quot;Graph does not contain vertex #{vertex}&quot;</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">&amp;&amp;</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">&amp;&amp;</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">&quot;Graph does not contain edge (#{from}, #{to})&quot;</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">&quot;Graph does not contain vertex #{vertex}&quot;</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">&lt;&lt;</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">&amp;&amp;</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">&lt;&lt;</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
+