ds 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +13 -0
  4. data/doc/Array.html +264 -0
  5. data/doc/DS.html +292 -0
  6. data/doc/DS/Array2D.html +345 -0
  7. data/doc/DS/BinaryHeap.html +493 -0
  8. data/doc/DS/BinarySearchTree.html +313 -0
  9. data/doc/DS/BinaryTree.html +433 -0
  10. data/doc/DS/CompleteBinaryTree.html +550 -0
  11. data/doc/DS/CyclicList.html +234 -0
  12. data/doc/DS/Digraph.html +299 -0
  13. data/doc/DS/Edge.html +283 -0
  14. data/doc/DS/ExpandableArray.html +316 -0
  15. data/doc/DS/Graph.html +739 -0
  16. data/doc/DS/GraphAsList.html +361 -0
  17. data/doc/DS/GraphAsMatrix.html +633 -0
  18. data/doc/DS/GraphAsTriMatrix.html +274 -0
  19. data/doc/DS/List.html +1263 -0
  20. data/doc/DS/ListElement.html +344 -0
  21. data/doc/DS/Queue.html +517 -0
  22. data/doc/DS/Ring.html +323 -0
  23. data/doc/DS/Stack.html +407 -0
  24. data/doc/DS/Tree.html +770 -0
  25. data/doc/DS/TreeWalker.html +561 -0
  26. data/doc/DS/TriMatrix.html +338 -0
  27. data/doc/created.rid +25 -0
  28. data/doc/ds/graphs/digraph_rb.html +52 -0
  29. data/doc/ds/graphs/edge_rb.html +52 -0
  30. data/doc/ds/graphs/graph_as_list_rb.html +52 -0
  31. data/doc/ds/graphs/graph_as_matrix_rb.html +52 -0
  32. data/doc/ds/graphs/graph_as_tri_matrix_rb.html +52 -0
  33. data/doc/ds/graphs/graph_rb.html +52 -0
  34. data/doc/ds/lists/cyclic_list_rb.html +52 -0
  35. data/doc/ds/lists/list_element_rb.html +52 -0
  36. data/doc/ds/lists/list_rb.html +52 -0
  37. data/doc/ds/lists/ring_rb.html +52 -0
  38. data/doc/ds/matrixes/array_2d_rb.html +52 -0
  39. data/doc/ds/matrixes/expandable_array_rb.html +52 -0
  40. data/doc/ds/matrixes/tri_matrix_rb.html +52 -0
  41. data/doc/ds/queues/queue_rb.html +52 -0
  42. data/doc/ds/stacks/stack_rb.html +52 -0
  43. data/doc/ds/trees/binary_heap_rb.html +52 -0
  44. data/doc/ds/trees/binary_search_tree_rb.html +52 -0
  45. data/doc/ds/trees/binary_tree_rb.html +52 -0
  46. data/doc/ds/trees/complete_binary_tree_rb.html +52 -0
  47. data/doc/ds/trees/tree_rb.html +52 -0
  48. data/doc/ds/trees/tree_walker_rb.html +52 -0
  49. data/doc/ds/version_rb.html +52 -0
  50. data/doc/ds_rb.html +98 -0
  51. data/doc/ext/ext_rb.html +52 -0
  52. data/doc/images/brick.png +0 -0
  53. data/doc/images/brick_link.png +0 -0
  54. data/doc/images/bug.png +0 -0
  55. data/doc/images/bullet_black.png +0 -0
  56. data/doc/images/bullet_toggle_minus.png +0 -0
  57. data/doc/images/bullet_toggle_plus.png +0 -0
  58. data/doc/images/date.png +0 -0
  59. data/doc/images/find.png +0 -0
  60. data/doc/images/loadingAnimation.gif +0 -0
  61. data/doc/images/macFFBgHack.png +0 -0
  62. data/doc/images/package.png +0 -0
  63. data/doc/images/page_green.png +0 -0
  64. data/doc/images/page_white_text.png +0 -0
  65. data/doc/images/page_white_width.png +0 -0
  66. data/doc/images/plugin.png +0 -0
  67. data/doc/images/ruby.png +0 -0
  68. data/doc/images/tag_green.png +0 -0
  69. data/doc/images/wrench.png +0 -0
  70. data/doc/images/wrench_orange.png +0 -0
  71. data/doc/images/zoom.png +0 -0
  72. data/doc/index.html +375 -0
  73. data/doc/js/darkfish.js +116 -0
  74. data/doc/js/jquery.js +32 -0
  75. data/doc/js/quicksearch.js +114 -0
  76. data/doc/js/thickbox-compressed.js +10 -0
  77. data/doc/rdoc.css +763 -0
  78. data/ds.gemspec +20 -0
  79. data/lib/ds.rb +38 -0
  80. data/lib/ds/graphs/digraph.rb +20 -0
  81. data/lib/ds/graphs/edge.rb +15 -0
  82. data/lib/ds/graphs/graph.rb +107 -0
  83. data/lib/ds/graphs/graph_as_list.rb +48 -0
  84. data/lib/ds/graphs/graph_as_matrix.rb +114 -0
  85. data/lib/ds/graphs/graph_as_tri_matrix.rb +25 -0
  86. data/lib/ds/lists/cyclic_list.rb +21 -0
  87. data/lib/ds/lists/list.rb +303 -0
  88. data/lib/ds/lists/list_element.rb +26 -0
  89. data/lib/ds/lists/ring.rb +42 -0
  90. data/lib/ds/matrixes/array_2d.rb +35 -0
  91. data/lib/ds/matrixes/expandable_array.rb +37 -0
  92. data/lib/ds/matrixes/tri_matrix.rb +30 -0
  93. data/lib/ds/queues/queue.rb +53 -0
  94. data/lib/ds/stacks/stack.rb +39 -0
  95. data/lib/ds/trees/binary_heap.rb +71 -0
  96. data/lib/ds/trees/binary_search_tree.rb +32 -0
  97. data/lib/ds/trees/binary_tree.rb +65 -0
  98. data/lib/ds/trees/complete_binary_tree.rb +52 -0
  99. data/lib/ds/trees/tree.rb +117 -0
  100. data/lib/ds/trees/tree_walker.rb +179 -0
  101. data/lib/ds/version.rb +3 -0
  102. data/lib/ext/ext.rb +15 -0
  103. data/test/help.rb +8 -0
  104. data/test/test_array2d.rb +51 -0
  105. data/test/test_binary_heap.rb +35 -0
  106. data/test/test_binary_search_tree.rb +32 -0
  107. data/test/test_binary_tree.rb +51 -0
  108. data/test/test_complete_binary_tree.rb +30 -0
  109. data/test/test_digraph.rb +134 -0
  110. data/test/test_expandable_array.rb +26 -0
  111. data/test/test_graph.rb +71 -0
  112. data/test/test_list.rb +138 -0
  113. data/test/test_list_element.rb +56 -0
  114. data/test/test_queue.rb +110 -0
  115. data/test/test_ring.rb +28 -0
  116. data/test/test_stack.rb +87 -0
  117. data/test/test_tree.rb +48 -0
  118. data/test/test_tree_walker.rb +69 -0
  119. data/test/test_tri_matrix.rb +22 -0
  120. metadata +184 -0
@@ -0,0 +1,739 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: DS::Graph</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
+
17
+ </head>
18
+ <body id="top" class="class">
19
+
20
+ <div id="metadata">
21
+ <div id="home-metadata">
22
+ <div id="home-section" class="section">
23
+ <h3 class="section-header">
24
+ <a href="../index.html">Home</a>
25
+ <a href="../index.html#classes">Classes</a>
26
+ <a href="../index.html#methods">Methods</a>
27
+ </h3>
28
+ </div>
29
+ </div>
30
+
31
+ <div id="file-metadata">
32
+ <div id="file-list-section" class="section">
33
+ <h3 class="section-header">In Files</h3>
34
+ <div class="section-body">
35
+ <ul>
36
+
37
+ <li><a href="../ds/graphs/graph_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
+ class="thickbox" title="ds/graphs/graph.rb">ds/graphs/graph.rb</a></li>
39
+
40
+ </ul>
41
+ </div>
42
+ </div>
43
+
44
+
45
+ </div>
46
+
47
+ <div id="class-metadata">
48
+
49
+ <!-- Parent Class -->
50
+ <div id="parent-class-section" class="section">
51
+ <h3 class="section-header">Parent</h3>
52
+
53
+ <p class="link">Object</p>
54
+
55
+ </div>
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ <!-- Method Quickref -->
64
+ <div id="method-list-section" class="section">
65
+ <h3 class="section-header">Methods</h3>
66
+ <ul class="link-list">
67
+
68
+ <li><a href="#method-c-create">::create</a></li>
69
+
70
+ <li><a href="#method-c-new">::new</a></li>
71
+
72
+ <li><a href="#method-i-add">#add</a></li>
73
+
74
+ <li><a href="#method-i-add_edges">#add_edges</a></li>
75
+
76
+ <li><a href="#method-i-bfs">#bfs</a></li>
77
+
78
+ <li><a href="#method-i-degree">#degree</a></li>
79
+
80
+ <li><a href="#method-i-each_edge">#each_edge</a></li>
81
+
82
+ <li><a href="#method-i-each_vertex">#each_vertex</a></li>
83
+
84
+ <li><a href="#method-i-edge-3F">#edge?</a></li>
85
+
86
+ <li><a href="#method-i-edge_size">#edge_size</a></li>
87
+
88
+ <li><a href="#method-i-get_edge">#get_edge</a></li>
89
+
90
+ <li><a href="#method-i-neighbors">#neighbors</a></li>
91
+
92
+ <li><a href="#method-i-remove">#remove</a></li>
93
+
94
+ <li><a href="#method-i-vertex_size">#vertex_size</a></li>
95
+
96
+ </ul>
97
+ </div>
98
+
99
+
100
+
101
+ </div>
102
+
103
+ <div id="project-metadata">
104
+
105
+
106
+
107
+ <div id="classindex-section" class="section project-section">
108
+ <h3 class="section-header">Class/Module Index
109
+ <span class="search-toggle"><img src="../images/find.png"
110
+ height="16" width="16" alt="[+]"
111
+ title="show/hide quicksearch" /></span></h3>
112
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
113
+ <fieldset>
114
+ <legend>Quicksearch</legend>
115
+ <input type="text" name="quicksearch" value=""
116
+ class="quicksearch-field" />
117
+ </fieldset>
118
+ </form>
119
+
120
+ <ul class="link-list">
121
+
122
+ <li><a href="../DS.html">DS</a></li>
123
+
124
+ <li><a href="../DS/Array2D.html">DS::Array2D</a></li>
125
+
126
+ <li><a href="../DS/BinaryHeap.html">DS::BinaryHeap</a></li>
127
+
128
+ <li><a href="../DS/BinarySearchTree.html">DS::BinarySearchTree</a></li>
129
+
130
+ <li><a href="../DS/BinaryTree.html">DS::BinaryTree</a></li>
131
+
132
+ <li><a href="../DS/CompleteBinaryTree.html">DS::CompleteBinaryTree</a></li>
133
+
134
+ <li><a href="../DS/CyclicList.html">DS::CyclicList</a></li>
135
+
136
+ <li><a href="../DS/Digraph.html">DS::Digraph</a></li>
137
+
138
+ <li><a href="../DS/Edge.html">DS::Edge</a></li>
139
+
140
+ <li><a href="../DS/ExpandableArray.html">DS::ExpandableArray</a></li>
141
+
142
+ <li><a href="../DS/Graph.html">DS::Graph</a></li>
143
+
144
+ <li><a href="../DS/GraphAsList.html">DS::GraphAsList</a></li>
145
+
146
+ <li><a href="../DS/GraphAsMatrix.html">DS::GraphAsMatrix</a></li>
147
+
148
+ <li><a href="../DS/GraphAsTriMatrix.html">DS::GraphAsTriMatrix</a></li>
149
+
150
+ <li><a href="../DS/List.html">DS::List</a></li>
151
+
152
+ <li><a href="../DS/ListElement.html">DS::ListElement</a></li>
153
+
154
+ <li><a href="../DS/Queue.html">DS::Queue</a></li>
155
+
156
+ <li><a href="../DS/Ring.html">DS::Ring</a></li>
157
+
158
+ <li><a href="../DS/Stack.html">DS::Stack</a></li>
159
+
160
+ <li><a href="../DS/Tree.html">DS::Tree</a></li>
161
+
162
+ <li><a href="../DS/TreeWalker.html">DS::TreeWalker</a></li>
163
+
164
+ <li><a href="../DS/TriMatrix.html">DS::TriMatrix</a></li>
165
+
166
+ <li><a href="../Array.html">Array</a></li>
167
+
168
+ </ul>
169
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
170
+ </div>
171
+
172
+
173
+ </div>
174
+ </div>
175
+
176
+ <div id="documentation">
177
+ <h1 class="class">DS::Graph</h1>
178
+
179
+ <div id="description" class="description">
180
+
181
+ </div><!-- description -->
182
+
183
+
184
+
185
+
186
+ <div id="5Buntitled-5D" class="documentation-section">
187
+
188
+
189
+
190
+
191
+
192
+ <!-- Constants -->
193
+ <div id="constants-list" class="section">
194
+ <h3 class="section-header">Constants</h3>
195
+ <dl>
196
+
197
+ <dt><a name="Infinity">Infinity</a></dt>
198
+
199
+ <dd class="description"></dd>
200
+
201
+
202
+ </dl>
203
+ </div>
204
+
205
+
206
+
207
+
208
+ <!-- Methods -->
209
+
210
+ <div id="public-class-method-details" class="method-section section">
211
+ <h3 class="section-header">Public Class Methods</h3>
212
+
213
+
214
+ <div id="create-method" class="method-detail ">
215
+ <a name="method-c-create"></a>
216
+
217
+
218
+ <div class="method-heading">
219
+ <span class="method-name">create</span><span
220
+ class="method-args">(edges)</span>
221
+ <span class="method-click-advice">click to toggle source</span>
222
+ </div>
223
+
224
+
225
+ <div class="method-description">
226
+
227
+ <p>Create new graph from array of edges. Internally graph will be represented
228
+ by Triangular Matrix.</p>
229
+
230
+
231
+
232
+ <div class="method-source-code" id="create-source">
233
+ <pre>
234
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 22</span>
235
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">edges</span>)
236
+ <span class="ruby-identifier">new</span>(<span class="ruby-identifier">edges</span>,<span class="ruby-value">:tri_matrix</span>)
237
+ <span class="ruby-keyword">end</span></pre>
238
+ </div><!-- create-source -->
239
+
240
+ </div>
241
+
242
+
243
+
244
+
245
+ </div><!-- create-method -->
246
+
247
+
248
+ <div id="new-method" class="method-detail ">
249
+ <a name="method-c-new"></a>
250
+
251
+
252
+ <div class="method-heading">
253
+ <span class="method-name">new</span><span
254
+ class="method-args">(edges,store = :list)</span>
255
+ <span class="method-click-advice">click to toggle source</span>
256
+ </div>
257
+
258
+
259
+ <div class="method-description">
260
+
261
+ <p>Create new graph from array of edges. Second parameter determines graph
262
+ internal implementation: :list (Adjency <a href="List.html">List</a>),
263
+ :tri_matrix (Triangular Matrix), :matrix (Matrix).</p>
264
+
265
+
266
+
267
+ <div class="method-source-code" id="new-source">
268
+ <pre>
269
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 9</span>
270
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">edges</span>,<span class="ruby-identifier">store</span> = <span class="ruby-value">:list</span>)
271
+ <span class="ruby-keyword">case</span> <span class="ruby-identifier">store</span>
272
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:matrix</span>
273
+ <span class="ruby-ivar">@g</span> = <span class="ruby-constant">GraphAsMatrix</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">edges</span>)
274
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:tri_matrix</span>
275
+ <span class="ruby-ivar">@g</span> = <span class="ruby-constant">GraphAsTriMatrix</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">edges</span>)
276
+ <span class="ruby-keyword">else</span>
277
+ <span class="ruby-ivar">@g</span> = <span class="ruby-constant">GraphAsList</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">edges</span>)
278
+ <span class="ruby-keyword">end</span>
279
+ <span class="ruby-keyword">end</span></pre>
280
+ </div><!-- new-source -->
281
+
282
+ </div>
283
+
284
+
285
+
286
+
287
+ </div><!-- new-method -->
288
+
289
+
290
+ </div><!-- public-class-method-details -->
291
+
292
+ <div id="public-instance-method-details" class="method-section section">
293
+ <h3 class="section-header">Public Instance Methods</h3>
294
+
295
+
296
+ <div id="add-method" class="method-detail ">
297
+ <a name="method-i-add"></a>
298
+
299
+
300
+ <div class="method-heading">
301
+ <span class="method-name">add</span><span
302
+ class="method-args">(x,y)</span>
303
+ <span class="method-click-advice">click to toggle source</span>
304
+ </div>
305
+
306
+
307
+ <div class="method-description">
308
+
309
+
310
+
311
+
312
+
313
+ <div class="method-source-code" id="add-source">
314
+ <pre>
315
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 26</span>
316
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">add</span>(<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>)
317
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>)
318
+ <span class="ruby-keyword">end</span></pre>
319
+ </div><!-- add-source -->
320
+
321
+ </div>
322
+
323
+
324
+
325
+
326
+ </div><!-- add-method -->
327
+
328
+
329
+ <div id="add_edges-method" class="method-detail ">
330
+ <a name="method-i-add_edges"></a>
331
+
332
+
333
+ <div class="method-heading">
334
+ <span class="method-name">add_edges</span><span
335
+ class="method-args">(edges)</span>
336
+ <span class="method-click-advice">click to toggle source</span>
337
+ </div>
338
+
339
+
340
+ <div class="method-description">
341
+
342
+
343
+
344
+
345
+
346
+ <div class="method-source-code" id="add_edges-source">
347
+ <pre>
348
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 81</span>
349
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">add_edges</span>(<span class="ruby-identifier">edges</span>)
350
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">add_edges</span>(<span class="ruby-identifier">edges</span>)
351
+ <span class="ruby-keyword">end</span></pre>
352
+ </div><!-- add_edges-source -->
353
+
354
+ </div>
355
+
356
+
357
+
358
+
359
+ </div><!-- add_edges-method -->
360
+
361
+
362
+ <div id="bfs-method" class="method-detail ">
363
+ <a name="method-i-bfs"></a>
364
+
365
+
366
+ <div class="method-heading">
367
+ <span class="method-name">bfs</span><span
368
+ class="method-args">(s)</span>
369
+ <span class="method-click-advice">click to toggle source</span>
370
+ </div>
371
+
372
+
373
+ <div class="method-description">
374
+
375
+
376
+
377
+
378
+
379
+ <div class="method-source-code" id="bfs-source">
380
+ <pre>
381
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 46</span>
382
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">bfs</span> <span class="ruby-identifier">s</span>
383
+ <span class="ruby-identifier">colors</span> = {}
384
+ <span class="ruby-identifier">parents</span> = {}
385
+ <span class="ruby-identifier">res</span> = []
386
+ <span class="ruby-identifier">d</span> = {}
387
+ <span class="ruby-identifier">q</span> = <span class="ruby-constant">Queue</span>.<span class="ruby-identifier">new</span>
388
+
389
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">each_vertex</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
390
+ <span class="ruby-identifier">colors</span>[<span class="ruby-identifier">v</span>] = <span class="ruby-value">:white</span>
391
+ <span class="ruby-identifier">parents</span>[<span class="ruby-identifier">v</span>] = <span class="ruby-keyword">nil</span>
392
+ <span class="ruby-identifier">d</span>[<span class="ruby-identifier">v</span>] = <span class="ruby-constant">Infinity</span>
393
+ <span class="ruby-keyword">end</span>
394
+
395
+ <span class="ruby-identifier">colors</span>[<span class="ruby-identifier">s</span>] = <span class="ruby-value">:white</span>
396
+ <span class="ruby-identifier">parents</span>[<span class="ruby-identifier">s</span>] = <span class="ruby-keyword">nil</span>
397
+ <span class="ruby-identifier">d</span>[<span class="ruby-identifier">s</span>] = <span class="ruby-value">0</span>
398
+
399
+ <span class="ruby-identifier">q</span>.<span class="ruby-identifier">enqueue</span> <span class="ruby-identifier">s</span>
400
+
401
+ <span class="ruby-keyword">while</span> <span class="ruby-operator">!</span><span class="ruby-identifier">q</span>.<span class="ruby-identifier">empty?</span>
402
+ <span class="ruby-identifier">u</span> = <span class="ruby-identifier">q</span>.<span class="ruby-identifier">dequeue</span>
403
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">neighbors</span>(<span class="ruby-identifier">u</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>
404
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">colors</span>[<span class="ruby-identifier">v</span>] <span class="ruby-operator">===</span> <span class="ruby-value">:white</span>
405
+ <span class="ruby-identifier">colors</span>[<span class="ruby-identifier">v</span>] = <span class="ruby-value">:grey</span>
406
+ <span class="ruby-identifier">d</span>[<span class="ruby-identifier">v</span>] = <span class="ruby-identifier">d</span>[<span class="ruby-identifier">u</span>] <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
407
+ <span class="ruby-identifier">parents</span>[<span class="ruby-identifier">v</span>] = <span class="ruby-identifier">u</span>
408
+ <span class="ruby-identifier">q</span>.<span class="ruby-identifier">enqueue</span> <span class="ruby-identifier">v</span>
409
+ <span class="ruby-keyword">end</span>
410
+ <span class="ruby-keyword">end</span>
411
+ <span class="ruby-identifier">colors</span>[<span class="ruby-identifier">u</span>] = <span class="ruby-value">:black</span>
412
+ <span class="ruby-identifier">res</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">u</span>
413
+ <span class="ruby-keyword">end</span>
414
+ <span class="ruby-identifier">res</span>
415
+ <span class="ruby-keyword">end</span></pre>
416
+ </div><!-- bfs-source -->
417
+
418
+ </div>
419
+
420
+
421
+
422
+
423
+ </div><!-- bfs-method -->
424
+
425
+
426
+ <div id="degree-method" class="method-detail ">
427
+ <a name="method-i-degree"></a>
428
+
429
+
430
+ <div class="method-heading">
431
+ <span class="method-name">degree</span><span
432
+ class="method-args">(x)</span>
433
+ <span class="method-click-advice">click to toggle source</span>
434
+ </div>
435
+
436
+
437
+ <div class="method-description">
438
+
439
+ <p>Returns vertex degree. Second parameter determines direction - :in incoming
440
+ edges, :out - outcoming edges, :all - incoming and outcoming edges.</p>
441
+
442
+
443
+
444
+ <div class="method-source-code" id="degree-source">
445
+ <pre>
446
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 87</span>
447
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">degree</span> <span class="ruby-identifier">x</span>
448
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">degree</span> <span class="ruby-identifier">x</span>
449
+ <span class="ruby-keyword">end</span></pre>
450
+ </div><!-- degree-source -->
451
+
452
+ </div>
453
+
454
+
455
+
456
+
457
+ </div><!-- degree-method -->
458
+
459
+
460
+ <div id="each_edge-method" class="method-detail ">
461
+ <a name="method-i-each_edge"></a>
462
+
463
+
464
+ <div class="method-heading">
465
+ <span class="method-name">each_edge</span><span
466
+ class="method-args">(&block)</span>
467
+ <span class="method-click-advice">click to toggle source</span>
468
+ </div>
469
+
470
+
471
+ <div class="method-description">
472
+
473
+
474
+
475
+
476
+
477
+ <div class="method-source-code" id="each_edge-source">
478
+ <pre>
479
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 38</span>
480
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">each_edge</span> &amp;<span class="ruby-identifier">block</span>
481
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">each_edge</span> &amp;<span class="ruby-identifier">block</span>
482
+ <span class="ruby-keyword">end</span></pre>
483
+ </div><!-- each_edge-source -->
484
+
485
+ </div>
486
+
487
+
488
+
489
+
490
+ </div><!-- each_edge-method -->
491
+
492
+
493
+ <div id="each_vertex-method" class="method-detail ">
494
+ <a name="method-i-each_vertex"></a>
495
+
496
+
497
+ <div class="method-heading">
498
+ <span class="method-name">each_vertex</span><span
499
+ class="method-args">(&block)</span>
500
+ <span class="method-click-advice">click to toggle source</span>
501
+ </div>
502
+
503
+
504
+ <div class="method-description">
505
+
506
+
507
+
508
+
509
+
510
+ <div class="method-source-code" id="each_vertex-source">
511
+ <pre>
512
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 34</span>
513
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">each_vertex</span> &amp;<span class="ruby-identifier">block</span>
514
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">each_vertex</span> &amp;<span class="ruby-identifier">block</span>
515
+ <span class="ruby-keyword">end</span></pre>
516
+ </div><!-- each_vertex-source -->
517
+
518
+ </div>
519
+
520
+
521
+
522
+
523
+ </div><!-- each_vertex-method -->
524
+
525
+
526
+ <div id="edge-3F-method" class="method-detail ">
527
+ <a name="method-i-edge-3F"></a>
528
+
529
+
530
+ <div class="method-heading">
531
+ <span class="method-name">edge?</span><span
532
+ class="method-args">(x,y)</span>
533
+ <span class="method-click-advice">click to toggle source</span>
534
+ </div>
535
+
536
+
537
+ <div class="method-description">
538
+
539
+
540
+
541
+
542
+
543
+ <div class="method-source-code" id="edge-3F-source">
544
+ <pre>
545
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 91</span>
546
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">edge?</span> <span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>
547
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">edge?</span> <span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>
548
+ <span class="ruby-keyword">end</span></pre>
549
+ </div><!-- edge-3F-source -->
550
+
551
+ </div>
552
+
553
+
554
+
555
+
556
+ </div><!-- edge-3F-method -->
557
+
558
+
559
+ <div id="edge_size-method" class="method-detail ">
560
+ <a name="method-i-edge_size"></a>
561
+
562
+
563
+ <div class="method-heading">
564
+ <span class="method-name">edge_size</span><span
565
+ class="method-args">()</span>
566
+ <span class="method-click-advice">click to toggle source</span>
567
+ </div>
568
+
569
+
570
+ <div class="method-description">
571
+
572
+
573
+
574
+
575
+
576
+ <div class="method-source-code" id="edge_size-source">
577
+ <pre>
578
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 103</span>
579
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">edge_size</span>
580
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">vmax</span><span class="ruby-operator">+</span><span class="ruby-value">1</span>
581
+ <span class="ruby-keyword">end</span></pre>
582
+ </div><!-- edge_size-source -->
583
+
584
+ </div>
585
+
586
+
587
+
588
+
589
+ </div><!-- edge_size-method -->
590
+
591
+
592
+ <div id="get_edge-method" class="method-detail ">
593
+ <a name="method-i-get_edge"></a>
594
+
595
+
596
+ <div class="method-heading">
597
+ <span class="method-name">get_edge</span><span
598
+ class="method-args">(x, y)</span>
599
+ <span class="method-click-advice">click to toggle source</span>
600
+ </div>
601
+
602
+
603
+ <div class="method-description">
604
+
605
+
606
+
607
+
608
+
609
+ <div class="method-source-code" id="get_edge-source">
610
+ <pre>
611
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 95</span>
612
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">get_edge</span> <span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span>
613
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">get_edge</span> <span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>
614
+ <span class="ruby-keyword">end</span></pre>
615
+ </div><!-- get_edge-source -->
616
+
617
+ </div>
618
+
619
+
620
+
621
+
622
+ </div><!-- get_edge-method -->
623
+
624
+
625
+ <div id="neighbors-method" class="method-detail ">
626
+ <a name="method-i-neighbors"></a>
627
+
628
+
629
+ <div class="method-heading">
630
+ <span class="method-name">neighbors</span><span
631
+ class="method-args">(v)</span>
632
+ <span class="method-click-advice">click to toggle source</span>
633
+ </div>
634
+
635
+
636
+ <div class="method-description">
637
+
638
+
639
+
640
+
641
+
642
+ <div class="method-source-code" id="neighbors-source">
643
+ <pre>
644
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 42</span>
645
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">neighbors</span> <span class="ruby-identifier">v</span>
646
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">neighbors</span> <span class="ruby-identifier">v</span>
647
+ <span class="ruby-keyword">end</span></pre>
648
+ </div><!-- neighbors-source -->
649
+
650
+ </div>
651
+
652
+
653
+
654
+
655
+ </div><!-- neighbors-method -->
656
+
657
+
658
+ <div id="remove-method" class="method-detail ">
659
+ <a name="method-i-remove"></a>
660
+
661
+
662
+ <div class="method-heading">
663
+ <span class="method-name">remove</span><span
664
+ class="method-args">(x,y)</span>
665
+ <span class="method-click-advice">click to toggle source</span>
666
+ </div>
667
+
668
+
669
+ <div class="method-description">
670
+
671
+
672
+
673
+
674
+
675
+ <div class="method-source-code" id="remove-source">
676
+ <pre>
677
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 30</span>
678
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">remove</span>(<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>)
679
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">remove</span>(<span class="ruby-identifier">x</span>,<span class="ruby-identifier">y</span>)
680
+ <span class="ruby-keyword">end</span></pre>
681
+ </div><!-- remove-source -->
682
+
683
+ </div>
684
+
685
+
686
+
687
+
688
+ </div><!-- remove-method -->
689
+
690
+
691
+ <div id="vertex_size-method" class="method-detail ">
692
+ <a name="method-i-vertex_size"></a>
693
+
694
+
695
+ <div class="method-heading">
696
+ <span class="method-name">vertex_size</span><span
697
+ class="method-args">()</span>
698
+ <span class="method-click-advice">click to toggle source</span>
699
+ </div>
700
+
701
+
702
+ <div class="method-description">
703
+
704
+
705
+
706
+
707
+
708
+ <div class="method-source-code" id="vertex_size-source">
709
+ <pre>
710
+ <span class="ruby-comment"># File ds/graphs/graph.rb, line 99</span>
711
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">vertex_size</span>
712
+ <span class="ruby-ivar">@g</span>.<span class="ruby-identifier">vertex_size</span>
713
+ <span class="ruby-keyword">end</span></pre>
714
+ </div><!-- vertex_size-source -->
715
+
716
+ </div>
717
+
718
+
719
+
720
+
721
+ </div><!-- vertex_size-method -->
722
+
723
+
724
+ </div><!-- public-instance-method-details -->
725
+
726
+ </div><!-- 5Buntitled-5D -->
727
+
728
+
729
+ </div><!-- documentation -->
730
+
731
+ <div id="validator-badges">
732
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
733
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
734
+ Rdoc Generator</a> 2</small>.</p>
735
+ </div>
736
+
737
+ </body>
738
+ </html>
739
+