simple_graph 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/SimpleGraph/Graph/Node.html +497 -497
- data/docs/SimpleGraph/Graph.html +1123 -1123
- data/docs/SimpleGraph.html +146 -146
- data/docs/_index.html +136 -136
- data/docs/class_list.html +51 -51
- data/docs/css/full_list.css +58 -58
- data/docs/css/style.css +492 -492
- data/docs/file.README.html +154 -154
- data/docs/file_list.html +56 -56
- data/docs/frames.html +17 -17
- data/docs/index.html +154 -154
- data/docs/js/app.js +248 -248
- data/docs/js/full_list.js +216 -216
- data/docs/js/jquery.js +3 -3
- data/docs/method_list.html +203 -203
- data/docs/top-level-namespace.html +109 -109
- data/lib/simple_graph/version.rb +1 -1
- data/simple_graph.gemspec +2 -0
- metadata +23 -3
data/docs/SimpleGraph/Graph.html
CHANGED
@@ -1,506 +1,506 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>
|
7
|
-
Class: SimpleGraph::Graph
|
8
|
-
|
9
|
-
— Documentation by YARD 0.9.9
|
10
|
-
|
11
|
-
</title>
|
12
|
-
|
13
|
-
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
-
|
15
|
-
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
-
|
17
|
-
<script type="text/javascript" charset="utf-8">
|
18
|
-
pathId = "SimpleGraph::Graph";
|
19
|
-
relpath = '../';
|
20
|
-
</script>
|
21
|
-
|
22
|
-
|
23
|
-
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
-
|
25
|
-
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
-
|
27
|
-
|
28
|
-
</head>
|
29
|
-
<body>
|
30
|
-
<div class="nav_wrap">
|
31
|
-
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
-
<div id="resizer"></div>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div id="main" tabindex="-1">
|
36
|
-
<div id="header">
|
37
|
-
<div id="menu">
|
38
|
-
|
39
|
-
<a href="../_index.html">Index (G)</a> »
|
40
|
-
<span class='title'><span class='object_link'><a href="../SimpleGraph.html" title="SimpleGraph (module)">SimpleGraph</a></span></span>
|
41
|
-
»
|
42
|
-
<span class="title">Graph</span>
|
43
|
-
|
44
|
-
</div>
|
45
|
-
|
46
|
-
<div id="search">
|
47
|
-
|
48
|
-
<a class="full_list_link" id="class_list_link"
|
49
|
-
href="../class_list.html">
|
50
|
-
|
51
|
-
<svg width="24" height="24">
|
52
|
-
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
-
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
-
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
-
</svg>
|
56
|
-
</a>
|
57
|
-
|
58
|
-
</div>
|
59
|
-
<div class="clear"></div>
|
60
|
-
</div>
|
61
|
-
|
62
|
-
<div id="content"><h1>Class: SimpleGraph::Graph
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</h1>
|
67
|
-
<div class="box_info">
|
68
|
-
|
69
|
-
<dl>
|
70
|
-
<dt>Inherits:</dt>
|
71
|
-
<dd>
|
72
|
-
<span class="inheritName">Object</span>
|
73
|
-
|
74
|
-
<ul class="fullTree">
|
75
|
-
<li>Object</li>
|
76
|
-
|
77
|
-
<li class="next">SimpleGraph::Graph</li>
|
78
|
-
|
79
|
-
</ul>
|
80
|
-
<a href="#" class="inheritanceTree">show all</a>
|
81
|
-
|
82
|
-
</dd>
|
83
|
-
</dl>
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
<dl>
|
96
|
-
<dt>Defined in:</dt>
|
97
|
-
<dd>lib/simple_graph.rb</dd>
|
98
|
-
</dl>
|
99
|
-
|
100
|
-
</div>
|
101
|
-
|
102
|
-
<h2>Overview</h2><div class="docstring">
|
103
|
-
<div class="discussion">
|
104
|
-
<p>A class representing a unweighted, undirected graph</p>
|
105
|
-
|
106
|
-
|
107
|
-
</div>
|
108
|
-
</div>
|
109
|
-
<div class="tags">
|
110
|
-
|
111
|
-
|
112
|
-
</div><h2>Defined Under Namespace</h2>
|
113
|
-
<p class="children">
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Graph/Node.html" title="SimpleGraph::Graph::Node (class)">Node</a></span>
|
119
|
-
|
120
|
-
|
121
|
-
</p>
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
<h2>
|
131
|
-
Instance Method Summary
|
132
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
133
|
-
</h2>
|
134
|
-
|
135
|
-
<ul class="summary">
|
136
|
-
|
137
|
-
<li class="public ">
|
138
|
-
<span class="summary_signature">
|
139
|
-
|
140
|
-
<a href="#add_node-instance_method" title="#add_node (instance method)">#<strong>add_node</strong>(id: nil, data: {}) ⇒ Object </a>
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
</span>
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
<span class="summary_desc"><div class='inline'><p>Add a new node to the graph.</p>
|
155
|
-
</div></span>
|
156
|
-
|
157
|
-
</li>
|
158
|
-
|
159
|
-
|
160
|
-
<li class="public ">
|
161
|
-
<span class="summary_signature">
|
162
|
-
|
163
|
-
<a href="#are_connected%3F-instance_method" title="#are_connected? (instance method)">#<strong>are_connected?</strong>(first, second) ⇒ Boolean </a>
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
</span>
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
<span class="summary_desc"><div class='inline'><p>Check if two nodes are connected by an edge.</p>
|
178
|
-
</div></span>
|
179
|
-
|
180
|
-
</li>
|
181
|
-
|
182
|
-
|
183
|
-
<li class="public ">
|
184
|
-
<span class="summary_signature">
|
185
|
-
|
186
|
-
<a href="#clear-instance_method" title="#clear (instance method)">#<strong>clear</strong> ⇒ Object </a>
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
</span>
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
<span class="summary_desc"><div class='inline'><p>Remove all nodes from the graph.</p>
|
201
|
-
</div></span>
|
202
|
-
|
203
|
-
</li>
|
204
|
-
|
205
|
-
|
206
|
-
<li class="public ">
|
207
|
-
<span class="summary_signature">
|
208
|
-
|
209
|
-
<a href="#connect_nodes-instance_method" title="#connect_nodes (instance method)">#<strong>connect_nodes</strong>(first, second) ⇒ Object </a>
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
</span>
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
<span class="summary_desc"><div class='inline'><p>Method to connect 2 nodes.</p>
|
224
|
-
</div></span>
|
225
|
-
|
226
|
-
</li>
|
227
|
-
|
228
|
-
|
229
|
-
<li class="public ">
|
230
|
-
<span class="summary_signature">
|
231
|
-
|
232
|
-
<a href="#delete_node-instance_method" title="#delete_node (instance method)">#<strong>delete_node</strong>(node) ⇒ Object </a>
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
</span>
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
<span class="summary_desc"><div class='inline'><p>Delete a node from the graph.</p>
|
247
|
-
</div></span>
|
248
|
-
|
249
|
-
</li>
|
250
|
-
|
251
|
-
|
252
|
-
<li class="public ">
|
253
|
-
<span class="summary_signature">
|
254
|
-
|
255
|
-
<a href="#find_paths-instance_method" title="#find_paths (instance method)">#<strong>find_paths</strong>(source_id, terminal_id) ⇒ Object </a>
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
</span>
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
<span class="summary_desc"><div class='inline'><p>Returns all the paths between two nodes as found by breadth-first-search.</p>
|
270
|
-
</div></span>
|
271
|
-
|
272
|
-
</li>
|
273
|
-
|
274
|
-
|
275
|
-
<li class="public ">
|
276
|
-
<span class="summary_signature">
|
277
|
-
|
278
|
-
<a href="#include%3F-instance_method" title="#include? (instance method)">#<strong>include?</strong>(node_id) ⇒ Boolean </a>
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
</span>
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
<span class="summary_desc"><div class='inline'><p>Checks whether the graph contains a node with the given ID.</p>
|
293
|
-
</div></span>
|
294
|
-
|
295
|
-
</li>
|
296
|
-
|
297
|
-
|
298
|
-
<li class="public ">
|
299
|
-
<span class="summary_signature">
|
300
|
-
|
301
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> ⇒ Graph </a>
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
</span>
|
306
|
-
|
307
|
-
|
308
|
-
<span class="note title constructor">constructor</span>
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
<span class="summary_desc"><div class='inline'><p>A new instance of Graph.</p>
|
318
|
-
</div></span>
|
319
|
-
|
320
|
-
</li>
|
321
|
-
|
322
|
-
|
323
|
-
<li class="public ">
|
324
|
-
<span class="summary_signature">
|
325
|
-
|
326
|
-
<a href="#load_from_json-instance_method" title="#load_from_json (instance method)">#<strong>load_from_json</strong>(str) ⇒ Object </a>
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
</span>
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
<span class="summary_desc"><div class='inline'><p>Loads the graph from a JSON string Returns the number of Nodes imported.</p>
|
341
|
-
</div></span>
|
342
|
-
|
343
|
-
</li>
|
344
|
-
|
345
|
-
|
346
|
-
<li class="public ">
|
347
|
-
<span class="summary_signature">
|
348
|
-
|
349
|
-
<a href="#node_count-instance_method" title="#node_count (instance method)">#<strong>node_count</strong> ⇒ Object </a>
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
</span>
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
<span class="summary_desc"><div class='inline'><p>Retrieve the amount of nodes in the graph.</p>
|
364
|
-
</div></span>
|
365
|
-
|
366
|
-
</li>
|
367
|
-
|
368
|
-
|
369
|
-
<li class="public ">
|
370
|
-
<span class="summary_signature">
|
371
|
-
|
372
|
-
<a href="#node_ids-instance_method" title="#node_ids (instance method)">#<strong>node_ids</strong> ⇒ Object </a>
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
</span>
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
<span class="summary_desc"><div class='inline'><p>Retrieve a array of node ids in the graph.</p>
|
387
|
-
</div></span>
|
388
|
-
|
389
|
-
</li>
|
390
|
-
|
391
|
-
|
392
|
-
<li class="public ">
|
393
|
-
<span class="summary_signature">
|
394
|
-
|
395
|
-
<a href="#nodes-instance_method" title="#nodes (instance method)">#<strong>nodes</strong> ⇒ Object </a>
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
</span>
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
<span class="summary_desc"><div class='inline'><p>Returns a hash of nodes in the graph mapped to node_id => node_data pairs.</p>
|
410
|
-
</div></span>
|
411
|
-
|
412
|
-
</li>
|
413
|
-
|
414
|
-
|
415
|
-
<li class="public ">
|
416
|
-
<span class="summary_signature">
|
417
|
-
|
418
|
-
<a href="#to_dot_string-instance_method" title="#to_dot_string (instance method)">#<strong>to_dot_string</strong> ⇒ Object </a>
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
</span>
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
<span class="summary_desc"><div class='inline'><p>Retrieve the current graph in the DOT format to be used with Graphviz.</p>
|
433
|
-
</div></span>
|
434
|
-
|
435
|
-
</li>
|
436
|
-
|
437
|
-
|
438
|
-
<li class="public ">
|
439
|
-
<span class="summary_signature">
|
440
|
-
|
441
|
-
<a href="#to_json-instance_method" title="#to_json (instance method)">#<strong>to_json</strong> ⇒ Object </a>
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
</span>
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
<span class="summary_desc"><div class='inline'><p>Dumps the graph to a JSON string.</p>
|
456
|
-
</div></span>
|
457
|
-
|
458
|
-
</li>
|
459
|
-
|
460
|
-
|
461
|
-
</ul>
|
462
|
-
|
463
|
-
|
464
|
-
<div id="constructor_details" class="method_details_list">
|
465
|
-
<h2>Constructor Details</h2>
|
466
|
-
|
467
|
-
<div class="method_details first">
|
468
|
-
<h3 class="signature first" id="initialize-instance_method">
|
469
|
-
|
470
|
-
#<strong>initialize</strong> ⇒ <tt><span class='object_link'><a href="" title="SimpleGraph::Graph (class)">Graph</a></span></tt>
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
</h3><div class="docstring">
|
477
|
-
<div class="discussion">
|
478
|
-
<p>Returns a new instance of Graph</p>
|
479
|
-
|
480
|
-
|
481
|
-
</div>
|
482
|
-
</div>
|
483
|
-
<div class="tags">
|
484
|
-
|
485
|
-
|
486
|
-
</div><table class="source_code">
|
487
|
-
<tr>
|
488
|
-
<td>
|
489
|
-
<pre class="lines">
|
490
|
-
|
491
|
-
|
492
|
-
26
|
493
|
-
27
|
494
|
-
28
|
495
|
-
29
|
496
|
-
30
|
497
|
-
31
|
498
|
-
32
|
499
|
-
33</pre>
|
500
|
-
</td>
|
501
|
-
<td>
|
502
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 26</span>
|
503
|
-
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: SimpleGraph::Graph
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "SimpleGraph::Graph";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (G)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../SimpleGraph.html" title="SimpleGraph (module)">SimpleGraph</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Graph</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: SimpleGraph::Graph
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">SimpleGraph::Graph</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/simple_graph.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
<p>A class representing a unweighted, undirected graph</p>
|
105
|
+
|
106
|
+
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
<div class="tags">
|
110
|
+
|
111
|
+
|
112
|
+
</div><h2>Defined Under Namespace</h2>
|
113
|
+
<p class="children">
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Graph/Node.html" title="SimpleGraph::Graph::Node (class)">Node</a></span>
|
119
|
+
|
120
|
+
|
121
|
+
</p>
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
<h2>
|
131
|
+
Instance Method Summary
|
132
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
133
|
+
</h2>
|
134
|
+
|
135
|
+
<ul class="summary">
|
136
|
+
|
137
|
+
<li class="public ">
|
138
|
+
<span class="summary_signature">
|
139
|
+
|
140
|
+
<a href="#add_node-instance_method" title="#add_node (instance method)">#<strong>add_node</strong>(id: nil, data: {}) ⇒ Object </a>
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
</span>
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
<span class="summary_desc"><div class='inline'><p>Add a new node to the graph.</p>
|
155
|
+
</div></span>
|
156
|
+
|
157
|
+
</li>
|
158
|
+
|
159
|
+
|
160
|
+
<li class="public ">
|
161
|
+
<span class="summary_signature">
|
162
|
+
|
163
|
+
<a href="#are_connected%3F-instance_method" title="#are_connected? (instance method)">#<strong>are_connected?</strong>(first, second) ⇒ Boolean </a>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
</span>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
<span class="summary_desc"><div class='inline'><p>Check if two nodes are connected by an edge.</p>
|
178
|
+
</div></span>
|
179
|
+
|
180
|
+
</li>
|
181
|
+
|
182
|
+
|
183
|
+
<li class="public ">
|
184
|
+
<span class="summary_signature">
|
185
|
+
|
186
|
+
<a href="#clear-instance_method" title="#clear (instance method)">#<strong>clear</strong> ⇒ Object </a>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
</span>
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
<span class="summary_desc"><div class='inline'><p>Remove all nodes from the graph.</p>
|
201
|
+
</div></span>
|
202
|
+
|
203
|
+
</li>
|
204
|
+
|
205
|
+
|
206
|
+
<li class="public ">
|
207
|
+
<span class="summary_signature">
|
208
|
+
|
209
|
+
<a href="#connect_nodes-instance_method" title="#connect_nodes (instance method)">#<strong>connect_nodes</strong>(first, second) ⇒ Object </a>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
</span>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<span class="summary_desc"><div class='inline'><p>Method to connect 2 nodes.</p>
|
224
|
+
</div></span>
|
225
|
+
|
226
|
+
</li>
|
227
|
+
|
228
|
+
|
229
|
+
<li class="public ">
|
230
|
+
<span class="summary_signature">
|
231
|
+
|
232
|
+
<a href="#delete_node-instance_method" title="#delete_node (instance method)">#<strong>delete_node</strong>(node) ⇒ Object </a>
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
</span>
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
<span class="summary_desc"><div class='inline'><p>Delete a node from the graph.</p>
|
247
|
+
</div></span>
|
248
|
+
|
249
|
+
</li>
|
250
|
+
|
251
|
+
|
252
|
+
<li class="public ">
|
253
|
+
<span class="summary_signature">
|
254
|
+
|
255
|
+
<a href="#find_paths-instance_method" title="#find_paths (instance method)">#<strong>find_paths</strong>(source_id, terminal_id) ⇒ Object </a>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
</span>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<span class="summary_desc"><div class='inline'><p>Returns all the paths between two nodes as found by breadth-first-search.</p>
|
270
|
+
</div></span>
|
271
|
+
|
272
|
+
</li>
|
273
|
+
|
274
|
+
|
275
|
+
<li class="public ">
|
276
|
+
<span class="summary_signature">
|
277
|
+
|
278
|
+
<a href="#include%3F-instance_method" title="#include? (instance method)">#<strong>include?</strong>(node_id) ⇒ Boolean </a>
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
</span>
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
<span class="summary_desc"><div class='inline'><p>Checks whether the graph contains a node with the given ID.</p>
|
293
|
+
</div></span>
|
294
|
+
|
295
|
+
</li>
|
296
|
+
|
297
|
+
|
298
|
+
<li class="public ">
|
299
|
+
<span class="summary_signature">
|
300
|
+
|
301
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> ⇒ Graph </a>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
</span>
|
306
|
+
|
307
|
+
|
308
|
+
<span class="note title constructor">constructor</span>
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
<span class="summary_desc"><div class='inline'><p>A new instance of Graph.</p>
|
318
|
+
</div></span>
|
319
|
+
|
320
|
+
</li>
|
321
|
+
|
322
|
+
|
323
|
+
<li class="public ">
|
324
|
+
<span class="summary_signature">
|
325
|
+
|
326
|
+
<a href="#load_from_json-instance_method" title="#load_from_json (instance method)">#<strong>load_from_json</strong>(str) ⇒ Object </a>
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
</span>
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
<span class="summary_desc"><div class='inline'><p>Loads the graph from a JSON string Returns the number of Nodes imported.</p>
|
341
|
+
</div></span>
|
342
|
+
|
343
|
+
</li>
|
344
|
+
|
345
|
+
|
346
|
+
<li class="public ">
|
347
|
+
<span class="summary_signature">
|
348
|
+
|
349
|
+
<a href="#node_count-instance_method" title="#node_count (instance method)">#<strong>node_count</strong> ⇒ Object </a>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
</span>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
<span class="summary_desc"><div class='inline'><p>Retrieve the amount of nodes in the graph.</p>
|
364
|
+
</div></span>
|
365
|
+
|
366
|
+
</li>
|
367
|
+
|
368
|
+
|
369
|
+
<li class="public ">
|
370
|
+
<span class="summary_signature">
|
371
|
+
|
372
|
+
<a href="#node_ids-instance_method" title="#node_ids (instance method)">#<strong>node_ids</strong> ⇒ Object </a>
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
</span>
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
<span class="summary_desc"><div class='inline'><p>Retrieve a array of node ids in the graph.</p>
|
387
|
+
</div></span>
|
388
|
+
|
389
|
+
</li>
|
390
|
+
|
391
|
+
|
392
|
+
<li class="public ">
|
393
|
+
<span class="summary_signature">
|
394
|
+
|
395
|
+
<a href="#nodes-instance_method" title="#nodes (instance method)">#<strong>nodes</strong> ⇒ Object </a>
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
</span>
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
<span class="summary_desc"><div class='inline'><p>Returns a hash of nodes in the graph mapped to node_id => node_data pairs.</p>
|
410
|
+
</div></span>
|
411
|
+
|
412
|
+
</li>
|
413
|
+
|
414
|
+
|
415
|
+
<li class="public ">
|
416
|
+
<span class="summary_signature">
|
417
|
+
|
418
|
+
<a href="#to_dot_string-instance_method" title="#to_dot_string (instance method)">#<strong>to_dot_string</strong> ⇒ Object </a>
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
</span>
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
<span class="summary_desc"><div class='inline'><p>Retrieve the current graph in the DOT format to be used with Graphviz.</p>
|
433
|
+
</div></span>
|
434
|
+
|
435
|
+
</li>
|
436
|
+
|
437
|
+
|
438
|
+
<li class="public ">
|
439
|
+
<span class="summary_signature">
|
440
|
+
|
441
|
+
<a href="#to_json-instance_method" title="#to_json (instance method)">#<strong>to_json</strong> ⇒ Object </a>
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
</span>
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
<span class="summary_desc"><div class='inline'><p>Dumps the graph to a JSON string.</p>
|
456
|
+
</div></span>
|
457
|
+
|
458
|
+
</li>
|
459
|
+
|
460
|
+
|
461
|
+
</ul>
|
462
|
+
|
463
|
+
|
464
|
+
<div id="constructor_details" class="method_details_list">
|
465
|
+
<h2>Constructor Details</h2>
|
466
|
+
|
467
|
+
<div class="method_details first">
|
468
|
+
<h3 class="signature first" id="initialize-instance_method">
|
469
|
+
|
470
|
+
#<strong>initialize</strong> ⇒ <tt><span class='object_link'><a href="" title="SimpleGraph::Graph (class)">Graph</a></span></tt>
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
</h3><div class="docstring">
|
477
|
+
<div class="discussion">
|
478
|
+
<p>Returns a new instance of Graph</p>
|
479
|
+
|
480
|
+
|
481
|
+
</div>
|
482
|
+
</div>
|
483
|
+
<div class="tags">
|
484
|
+
|
485
|
+
|
486
|
+
</div><table class="source_code">
|
487
|
+
<tr>
|
488
|
+
<td>
|
489
|
+
<pre class="lines">
|
490
|
+
|
491
|
+
|
492
|
+
26
|
493
|
+
27
|
494
|
+
28
|
495
|
+
29
|
496
|
+
30
|
497
|
+
31
|
498
|
+
32
|
499
|
+
33</pre>
|
500
|
+
</td>
|
501
|
+
<td>
|
502
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 26</span>
|
503
|
+
|
504
504
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
|
505
505
|
<span class='comment'># Our array of internal nodes
|
506
506
|
</span> <span class='ivar'>@nodes</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -508,239 +508,239 @@
|
|
508
508
|
</span> <span class='ivar'>@nodes_by_id</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
509
509
|
<span class='comment'># Tracks the highest used id for autoincrement
|
510
510
|
</span> <span class='ivar'>@last_id</span> <span class='op'>=</span> <span class='int'>0</span>
|
511
|
-
<span class='kw'>end</span></pre>
|
512
|
-
</td>
|
513
|
-
</tr>
|
514
|
-
</table>
|
515
|
-
</div>
|
516
|
-
|
517
|
-
</div>
|
518
|
-
|
519
|
-
|
520
|
-
<div id="instance_method_details" class="method_details_list">
|
521
|
-
<h2>Instance Method Details</h2>
|
522
|
-
|
523
|
-
|
524
|
-
<div class="method_details first">
|
525
|
-
<h3 class="signature first" id="add_node-instance_method">
|
526
|
-
|
527
|
-
#<strong>add_node</strong>(id: nil, data: {}) ⇒ <tt>Object</tt>
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
</h3><div class="docstring">
|
534
|
-
<div class="discussion">
|
535
|
-
<p>Add a new node to the graph</p>
|
536
|
-
|
537
|
-
|
538
|
-
</div>
|
539
|
-
</div>
|
540
|
-
<div class="tags">
|
541
|
-
|
542
|
-
|
543
|
-
</div><table class="source_code">
|
544
|
-
<tr>
|
545
|
-
<td>
|
546
|
-
<pre class="lines">
|
547
|
-
|
548
|
-
|
549
|
-
41
|
550
|
-
42
|
551
|
-
43
|
552
|
-
44
|
553
|
-
45
|
554
|
-
46
|
555
|
-
47</pre>
|
556
|
-
</td>
|
557
|
-
<td>
|
558
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 41</span>
|
559
|
-
|
511
|
+
<span class='kw'>end</span></pre>
|
512
|
+
</td>
|
513
|
+
</tr>
|
514
|
+
</table>
|
515
|
+
</div>
|
516
|
+
|
517
|
+
</div>
|
518
|
+
|
519
|
+
|
520
|
+
<div id="instance_method_details" class="method_details_list">
|
521
|
+
<h2>Instance Method Details</h2>
|
522
|
+
|
523
|
+
|
524
|
+
<div class="method_details first">
|
525
|
+
<h3 class="signature first" id="add_node-instance_method">
|
526
|
+
|
527
|
+
#<strong>add_node</strong>(id: nil, data: {}) ⇒ <tt>Object</tt>
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
|
533
|
+
</h3><div class="docstring">
|
534
|
+
<div class="discussion">
|
535
|
+
<p>Add a new node to the graph</p>
|
536
|
+
|
537
|
+
|
538
|
+
</div>
|
539
|
+
</div>
|
540
|
+
<div class="tags">
|
541
|
+
|
542
|
+
|
543
|
+
</div><table class="source_code">
|
544
|
+
<tr>
|
545
|
+
<td>
|
546
|
+
<pre class="lines">
|
547
|
+
|
548
|
+
|
549
|
+
41
|
550
|
+
42
|
551
|
+
43
|
552
|
+
44
|
553
|
+
45
|
554
|
+
46
|
555
|
+
47</pre>
|
556
|
+
</td>
|
557
|
+
<td>
|
558
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 41</span>
|
559
|
+
|
560
560
|
<span class='kw'>def</span> <span class='id identifier rubyid_add_node'>add_node</span><span class='lparen'>(</span><span class='label'>id:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>data:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
561
561
|
<span class='id identifier rubyid_id'>id</span> <span class='op'>||=</span> <span class='id identifier rubyid_next_id'>next_id</span>
|
562
562
|
<span class='id identifier rubyid_node'>node</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="SimpleGraph::Graph (class)">Graph</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Graph/Node.html" title="SimpleGraph::Graph::Node (class)">Node</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Graph/Node.html#initialize-instance_method" title="SimpleGraph::Graph::Node#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>id:</span> <span class='id identifier rubyid_id'>id</span><span class='comma'>,</span> <span class='label'>data:</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
|
563
563
|
<span class='ivar'>@nodes</span> <span class='op'><<</span> <span class='id identifier rubyid_node'>node</span>
|
564
564
|
<span class='ivar'>@nodes_by_id</span><span class='lbracket'>[</span><span class='id identifier rubyid_id'>id</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_node'>node</span>
|
565
565
|
<span class='id identifier rubyid_node'>node</span>
|
566
|
-
<span class='kw'>end</span></pre>
|
567
|
-
</td>
|
568
|
-
</tr>
|
569
|
-
</table>
|
570
|
-
</div>
|
571
|
-
|
572
|
-
<div class="method_details ">
|
573
|
-
<h3 class="signature " id="are_connected?-instance_method">
|
574
|
-
|
575
|
-
#<strong>are_connected?</strong>(first, second) ⇒ <tt>Boolean</tt>
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
</h3><div class="docstring">
|
582
|
-
<div class="discussion">
|
583
|
-
<p>Check if two nodes are connected by an edge</p>
|
584
|
-
|
585
|
-
|
586
|
-
</div>
|
587
|
-
</div>
|
588
|
-
<div class="tags">
|
589
|
-
|
590
|
-
<p class="tag_title">Returns:</p>
|
591
|
-
<ul class="return">
|
592
|
-
|
593
|
-
<li>
|
594
|
-
|
595
|
-
|
596
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
</li>
|
601
|
-
|
602
|
-
</ul>
|
603
|
-
|
604
|
-
</div><table class="source_code">
|
605
|
-
<tr>
|
606
|
-
<td>
|
607
|
-
<pre class="lines">
|
608
|
-
|
609
|
-
|
610
|
-
87
|
611
|
-
88
|
612
|
-
89</pre>
|
613
|
-
</td>
|
614
|
-
<td>
|
615
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 87</span>
|
616
|
-
|
566
|
+
<span class='kw'>end</span></pre>
|
567
|
+
</td>
|
568
|
+
</tr>
|
569
|
+
</table>
|
570
|
+
</div>
|
571
|
+
|
572
|
+
<div class="method_details ">
|
573
|
+
<h3 class="signature " id="are_connected?-instance_method">
|
574
|
+
|
575
|
+
#<strong>are_connected?</strong>(first, second) ⇒ <tt>Boolean</tt>
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
</h3><div class="docstring">
|
582
|
+
<div class="discussion">
|
583
|
+
<p>Check if two nodes are connected by an edge</p>
|
584
|
+
|
585
|
+
|
586
|
+
</div>
|
587
|
+
</div>
|
588
|
+
<div class="tags">
|
589
|
+
|
590
|
+
<p class="tag_title">Returns:</p>
|
591
|
+
<ul class="return">
|
592
|
+
|
593
|
+
<li>
|
594
|
+
|
595
|
+
|
596
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
</li>
|
601
|
+
|
602
|
+
</ul>
|
603
|
+
|
604
|
+
</div><table class="source_code">
|
605
|
+
<tr>
|
606
|
+
<td>
|
607
|
+
<pre class="lines">
|
608
|
+
|
609
|
+
|
610
|
+
87
|
611
|
+
88
|
612
|
+
89</pre>
|
613
|
+
</td>
|
614
|
+
<td>
|
615
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 87</span>
|
616
|
+
|
617
617
|
<span class='kw'>def</span> <span class='id identifier rubyid_are_connected?'>are_connected?</span><span class='lparen'>(</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='id identifier rubyid_second'>second</span><span class='rparen'>)</span>
|
618
618
|
<span class='ivar'>@nodes_by_id</span><span class='lbracket'>[</span><span class='id identifier rubyid_first'>first</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_neighbors'>neighbors</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@nodes_by_id</span><span class='lbracket'>[</span><span class='id identifier rubyid_second'>second</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
619
|
-
<span class='kw'>end</span></pre>
|
620
|
-
</td>
|
621
|
-
</tr>
|
622
|
-
</table>
|
623
|
-
</div>
|
624
|
-
|
625
|
-
<div class="method_details ">
|
626
|
-
<h3 class="signature " id="clear-instance_method">
|
627
|
-
|
628
|
-
#<strong>clear</strong> ⇒ <tt>Object</tt>
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
</h3><div class="docstring">
|
635
|
-
<div class="discussion">
|
636
|
-
<p>Remove all nodes from the graph</p>
|
637
|
-
|
638
|
-
|
639
|
-
</div>
|
640
|
-
</div>
|
641
|
-
<div class="tags">
|
642
|
-
|
643
|
-
|
644
|
-
</div><table class="source_code">
|
645
|
-
<tr>
|
646
|
-
<td>
|
647
|
-
<pre class="lines">
|
648
|
-
|
649
|
-
|
650
|
-
36
|
651
|
-
37
|
652
|
-
38</pre>
|
653
|
-
</td>
|
654
|
-
<td>
|
655
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 36</span>
|
656
|
-
|
619
|
+
<span class='kw'>end</span></pre>
|
620
|
+
</td>
|
621
|
+
</tr>
|
622
|
+
</table>
|
623
|
+
</div>
|
624
|
+
|
625
|
+
<div class="method_details ">
|
626
|
+
<h3 class="signature " id="clear-instance_method">
|
627
|
+
|
628
|
+
#<strong>clear</strong> ⇒ <tt>Object</tt>
|
629
|
+
|
630
|
+
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
</h3><div class="docstring">
|
635
|
+
<div class="discussion">
|
636
|
+
<p>Remove all nodes from the graph</p>
|
637
|
+
|
638
|
+
|
639
|
+
</div>
|
640
|
+
</div>
|
641
|
+
<div class="tags">
|
642
|
+
|
643
|
+
|
644
|
+
</div><table class="source_code">
|
645
|
+
<tr>
|
646
|
+
<td>
|
647
|
+
<pre class="lines">
|
648
|
+
|
649
|
+
|
650
|
+
36
|
651
|
+
37
|
652
|
+
38</pre>
|
653
|
+
</td>
|
654
|
+
<td>
|
655
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 36</span>
|
656
|
+
|
657
657
|
<span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
|
658
658
|
<span class='id identifier rubyid_initialize'>initialize</span>
|
659
|
-
<span class='kw'>end</span></pre>
|
660
|
-
</td>
|
661
|
-
</tr>
|
662
|
-
</table>
|
663
|
-
</div>
|
664
|
-
|
665
|
-
<div class="method_details ">
|
666
|
-
<h3 class="signature " id="connect_nodes-instance_method">
|
667
|
-
|
668
|
-
#<strong>connect_nodes</strong>(first, second) ⇒ <tt>Object</tt>
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
</h3><div class="docstring">
|
675
|
-
<div class="discussion">
|
676
|
-
<p>Method to connect 2 nodes</p>
|
677
|
-
|
678
|
-
|
679
|
-
</div>
|
680
|
-
</div>
|
681
|
-
<div class="tags">
|
682
|
-
|
683
|
-
|
684
|
-
</div><table class="source_code">
|
685
|
-
<tr>
|
686
|
-
<td>
|
687
|
-
<pre class="lines">
|
688
|
-
|
689
|
-
|
690
|
-
76
|
691
|
-
77
|
692
|
-
78
|
693
|
-
79</pre>
|
694
|
-
</td>
|
695
|
-
<td>
|
696
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 76</span>
|
697
|
-
|
659
|
+
<span class='kw'>end</span></pre>
|
660
|
+
</td>
|
661
|
+
</tr>
|
662
|
+
</table>
|
663
|
+
</div>
|
664
|
+
|
665
|
+
<div class="method_details ">
|
666
|
+
<h3 class="signature " id="connect_nodes-instance_method">
|
667
|
+
|
668
|
+
#<strong>connect_nodes</strong>(first, second) ⇒ <tt>Object</tt>
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
</h3><div class="docstring">
|
675
|
+
<div class="discussion">
|
676
|
+
<p>Method to connect 2 nodes</p>
|
677
|
+
|
678
|
+
|
679
|
+
</div>
|
680
|
+
</div>
|
681
|
+
<div class="tags">
|
682
|
+
|
683
|
+
|
684
|
+
</div><table class="source_code">
|
685
|
+
<tr>
|
686
|
+
<td>
|
687
|
+
<pre class="lines">
|
688
|
+
|
689
|
+
|
690
|
+
76
|
691
|
+
77
|
692
|
+
78
|
693
|
+
79</pre>
|
694
|
+
</td>
|
695
|
+
<td>
|
696
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 76</span>
|
697
|
+
|
698
698
|
<span class='kw'>def</span> <span class='id identifier rubyid_connect_nodes'>connect_nodes</span><span class='lparen'>(</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='id identifier rubyid_second'>second</span><span class='rparen'>)</span>
|
699
699
|
<span class='ivar'>@nodes_by_id</span><span class='lbracket'>[</span><span class='id identifier rubyid_first'>first</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_add_neighbor'>add_neighbor</span><span class='lparen'>(</span><span class='ivar'>@nodes_by_id</span><span class='lbracket'>[</span><span class='id identifier rubyid_second'>second</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
700
700
|
<span class='ivar'>@nodes_by_id</span><span class='lbracket'>[</span><span class='id identifier rubyid_second'>second</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_add_neighbor'>add_neighbor</span><span class='lparen'>(</span><span class='ivar'>@nodes_by_id</span><span class='lbracket'>[</span><span class='id identifier rubyid_first'>first</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
701
|
-
<span class='kw'>end</span></pre>
|
702
|
-
</td>
|
703
|
-
</tr>
|
704
|
-
</table>
|
705
|
-
</div>
|
706
|
-
|
707
|
-
<div class="method_details ">
|
708
|
-
<h3 class="signature " id="delete_node-instance_method">
|
709
|
-
|
710
|
-
#<strong>delete_node</strong>(node) ⇒ <tt>Object</tt>
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
</h3><div class="docstring">
|
717
|
-
<div class="discussion">
|
718
|
-
<p>Delete a node from the graph</p>
|
719
|
-
|
720
|
-
|
721
|
-
</div>
|
722
|
-
</div>
|
723
|
-
<div class="tags">
|
724
|
-
|
725
|
-
|
726
|
-
</div><table class="source_code">
|
727
|
-
<tr>
|
728
|
-
<td>
|
729
|
-
<pre class="lines">
|
730
|
-
|
731
|
-
|
732
|
-
50
|
733
|
-
51
|
734
|
-
52
|
735
|
-
53
|
736
|
-
54
|
737
|
-
55
|
738
|
-
56
|
739
|
-
57</pre>
|
740
|
-
</td>
|
741
|
-
<td>
|
742
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 50</span>
|
743
|
-
|
701
|
+
<span class='kw'>end</span></pre>
|
702
|
+
</td>
|
703
|
+
</tr>
|
704
|
+
</table>
|
705
|
+
</div>
|
706
|
+
|
707
|
+
<div class="method_details ">
|
708
|
+
<h3 class="signature " id="delete_node-instance_method">
|
709
|
+
|
710
|
+
#<strong>delete_node</strong>(node) ⇒ <tt>Object</tt>
|
711
|
+
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
</h3><div class="docstring">
|
717
|
+
<div class="discussion">
|
718
|
+
<p>Delete a node from the graph</p>
|
719
|
+
|
720
|
+
|
721
|
+
</div>
|
722
|
+
</div>
|
723
|
+
<div class="tags">
|
724
|
+
|
725
|
+
|
726
|
+
</div><table class="source_code">
|
727
|
+
<tr>
|
728
|
+
<td>
|
729
|
+
<pre class="lines">
|
730
|
+
|
731
|
+
|
732
|
+
50
|
733
|
+
51
|
734
|
+
52
|
735
|
+
53
|
736
|
+
54
|
737
|
+
55
|
738
|
+
56
|
739
|
+
57</pre>
|
740
|
+
</td>
|
741
|
+
<td>
|
742
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 50</span>
|
743
|
+
|
744
744
|
<span class='kw'>def</span> <span class='id identifier rubyid_delete_node'>delete_node</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
|
745
745
|
<span class='comment'># Remove all edges connected with this node
|
746
746
|
</span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_neighbors'>neighbors</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_neighbor'>neighbor</span><span class='op'>|</span>
|
@@ -748,70 +748,70 @@
|
|
748
748
|
<span class='kw'>end</span>
|
749
749
|
<span class='comment'># Remove the node itself
|
750
750
|
</span> <span class='ivar'>@nodes</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span>
|
751
|
-
<span class='kw'>end</span></pre>
|
752
|
-
</td>
|
753
|
-
</tr>
|
754
|
-
</table>
|
755
|
-
</div>
|
756
|
-
|
757
|
-
<div class="method_details ">
|
758
|
-
<h3 class="signature " id="find_paths-instance_method">
|
759
|
-
|
760
|
-
#<strong>find_paths</strong>(source_id, terminal_id) ⇒ <tt>Object</tt>
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
</h3><div class="docstring">
|
767
|
-
<div class="discussion">
|
768
|
-
<p>Returns all the paths between two nodes as found by breadth-first-search</p>
|
769
|
-
|
770
|
-
|
771
|
-
</div>
|
772
|
-
</div>
|
773
|
-
<div class="tags">
|
774
|
-
|
775
|
-
|
776
|
-
</div><table class="source_code">
|
777
|
-
<tr>
|
778
|
-
<td>
|
779
|
-
<pre class="lines">
|
780
|
-
|
781
|
-
|
782
|
-
144
|
783
|
-
145
|
784
|
-
146
|
785
|
-
147
|
786
|
-
148
|
787
|
-
149
|
788
|
-
150
|
789
|
-
151
|
790
|
-
152
|
791
|
-
153
|
792
|
-
154
|
793
|
-
155
|
794
|
-
156
|
795
|
-
157
|
796
|
-
158
|
797
|
-
159
|
798
|
-
160
|
799
|
-
161
|
800
|
-
162
|
801
|
-
163
|
802
|
-
164
|
803
|
-
165
|
804
|
-
166
|
805
|
-
167
|
806
|
-
168
|
807
|
-
169
|
808
|
-
170
|
809
|
-
171
|
810
|
-
172</pre>
|
811
|
-
</td>
|
812
|
-
<td>
|
813
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 144</span>
|
814
|
-
|
751
|
+
<span class='kw'>end</span></pre>
|
752
|
+
</td>
|
753
|
+
</tr>
|
754
|
+
</table>
|
755
|
+
</div>
|
756
|
+
|
757
|
+
<div class="method_details ">
|
758
|
+
<h3 class="signature " id="find_paths-instance_method">
|
759
|
+
|
760
|
+
#<strong>find_paths</strong>(source_id, terminal_id) ⇒ <tt>Object</tt>
|
761
|
+
|
762
|
+
|
763
|
+
|
764
|
+
|
765
|
+
|
766
|
+
</h3><div class="docstring">
|
767
|
+
<div class="discussion">
|
768
|
+
<p>Returns all the paths between two nodes as found by breadth-first-search</p>
|
769
|
+
|
770
|
+
|
771
|
+
</div>
|
772
|
+
</div>
|
773
|
+
<div class="tags">
|
774
|
+
|
775
|
+
|
776
|
+
</div><table class="source_code">
|
777
|
+
<tr>
|
778
|
+
<td>
|
779
|
+
<pre class="lines">
|
780
|
+
|
781
|
+
|
782
|
+
144
|
783
|
+
145
|
784
|
+
146
|
785
|
+
147
|
786
|
+
148
|
787
|
+
149
|
788
|
+
150
|
789
|
+
151
|
790
|
+
152
|
791
|
+
153
|
792
|
+
154
|
793
|
+
155
|
794
|
+
156
|
795
|
+
157
|
796
|
+
158
|
797
|
+
159
|
798
|
+
160
|
799
|
+
161
|
800
|
+
162
|
801
|
+
163
|
802
|
+
164
|
803
|
+
165
|
804
|
+
166
|
805
|
+
167
|
806
|
+
168
|
807
|
+
169
|
808
|
+
170
|
809
|
+
171
|
810
|
+
172</pre>
|
811
|
+
</td>
|
812
|
+
<td>
|
813
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 144</span>
|
814
|
+
|
815
815
|
<span class='kw'>def</span> <span class='id identifier rubyid_find_paths'>find_paths</span><span class='lparen'>(</span><span class='id identifier rubyid_source_id'>source_id</span><span class='comma'>,</span> <span class='id identifier rubyid_terminal_id'>terminal_id</span><span class='rparen'>)</span>
|
816
816
|
<span class='id identifier rubyid_found_paths'>found_paths</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
817
817
|
|
@@ -840,111 +840,111 @@
|
|
840
840
|
<span class='kw'>end</span>
|
841
841
|
|
842
842
|
<span class='id identifier rubyid_found_paths'>found_paths</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_found_path'>found_path</span><span class='op'>|</span> <span class='id identifier rubyid_found_path'>found_path</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='op'>=></span> <span class='id identifier rubyid_item'>item</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
843
|
-
<span class='kw'>end</span></pre>
|
844
|
-
</td>
|
845
|
-
</tr>
|
846
|
-
</table>
|
847
|
-
</div>
|
848
|
-
|
849
|
-
<div class="method_details ">
|
850
|
-
<h3 class="signature " id="include?-instance_method">
|
851
|
-
|
852
|
-
#<strong>include?</strong>(node_id) ⇒ <tt>Boolean</tt>
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
</h3><div class="docstring">
|
859
|
-
<div class="discussion">
|
860
|
-
<p>Checks whether the graph contains a node with the given ID</p>
|
861
|
-
|
862
|
-
|
863
|
-
</div>
|
864
|
-
</div>
|
865
|
-
<div class="tags">
|
866
|
-
|
867
|
-
<p class="tag_title">Returns:</p>
|
868
|
-
<ul class="return">
|
869
|
-
|
870
|
-
<li>
|
871
|
-
|
872
|
-
|
873
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
</li>
|
878
|
-
|
879
|
-
</ul>
|
880
|
-
|
881
|
-
</div><table class="source_code">
|
882
|
-
<tr>
|
883
|
-
<td>
|
884
|
-
<pre class="lines">
|
885
|
-
|
886
|
-
|
887
|
-
82
|
888
|
-
83
|
889
|
-
84</pre>
|
890
|
-
</td>
|
891
|
-
<td>
|
892
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 82</span>
|
893
|
-
|
843
|
+
<span class='kw'>end</span></pre>
|
844
|
+
</td>
|
845
|
+
</tr>
|
846
|
+
</table>
|
847
|
+
</div>
|
848
|
+
|
849
|
+
<div class="method_details ">
|
850
|
+
<h3 class="signature " id="include?-instance_method">
|
851
|
+
|
852
|
+
#<strong>include?</strong>(node_id) ⇒ <tt>Boolean</tt>
|
853
|
+
|
854
|
+
|
855
|
+
|
856
|
+
|
857
|
+
|
858
|
+
</h3><div class="docstring">
|
859
|
+
<div class="discussion">
|
860
|
+
<p>Checks whether the graph contains a node with the given ID</p>
|
861
|
+
|
862
|
+
|
863
|
+
</div>
|
864
|
+
</div>
|
865
|
+
<div class="tags">
|
866
|
+
|
867
|
+
<p class="tag_title">Returns:</p>
|
868
|
+
<ul class="return">
|
869
|
+
|
870
|
+
<li>
|
871
|
+
|
872
|
+
|
873
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
874
|
+
|
875
|
+
|
876
|
+
|
877
|
+
</li>
|
878
|
+
|
879
|
+
</ul>
|
880
|
+
|
881
|
+
</div><table class="source_code">
|
882
|
+
<tr>
|
883
|
+
<td>
|
884
|
+
<pre class="lines">
|
885
|
+
|
886
|
+
|
887
|
+
82
|
888
|
+
83
|
889
|
+
84</pre>
|
890
|
+
</td>
|
891
|
+
<td>
|
892
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 82</span>
|
893
|
+
|
894
894
|
<span class='kw'>def</span> <span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_node_id'>node_id</span><span class='rparen'>)</span>
|
895
895
|
<span class='ivar'>@nodes_by_id</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_node_id'>node_id</span><span class='rparen'>)</span>
|
896
|
-
<span class='kw'>end</span></pre>
|
897
|
-
</td>
|
898
|
-
</tr>
|
899
|
-
</table>
|
900
|
-
</div>
|
901
|
-
|
902
|
-
<div class="method_details ">
|
903
|
-
<h3 class="signature " id="load_from_json-instance_method">
|
904
|
-
|
905
|
-
#<strong>load_from_json</strong>(str) ⇒ <tt>Object</tt>
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
</h3><div class="docstring">
|
912
|
-
<div class="discussion">
|
913
|
-
<p>Loads the graph from a JSON string
|
914
|
-
Returns the number of Nodes imported</p>
|
915
|
-
|
916
|
-
|
917
|
-
</div>
|
918
|
-
</div>
|
919
|
-
<div class="tags">
|
920
|
-
|
921
|
-
|
922
|
-
</div><table class="source_code">
|
923
|
-
<tr>
|
924
|
-
<td>
|
925
|
-
<pre class="lines">
|
926
|
-
|
927
|
-
|
928
|
-
126
|
929
|
-
127
|
930
|
-
128
|
931
|
-
129
|
932
|
-
130
|
933
|
-
131
|
934
|
-
132
|
935
|
-
133
|
936
|
-
134
|
937
|
-
135
|
938
|
-
136
|
939
|
-
137
|
940
|
-
138
|
941
|
-
139
|
942
|
-
140
|
943
|
-
141</pre>
|
944
|
-
</td>
|
945
|
-
<td>
|
946
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 126</span>
|
947
|
-
|
896
|
+
<span class='kw'>end</span></pre>
|
897
|
+
</td>
|
898
|
+
</tr>
|
899
|
+
</table>
|
900
|
+
</div>
|
901
|
+
|
902
|
+
<div class="method_details ">
|
903
|
+
<h3 class="signature " id="load_from_json-instance_method">
|
904
|
+
|
905
|
+
#<strong>load_from_json</strong>(str) ⇒ <tt>Object</tt>
|
906
|
+
|
907
|
+
|
908
|
+
|
909
|
+
|
910
|
+
|
911
|
+
</h3><div class="docstring">
|
912
|
+
<div class="discussion">
|
913
|
+
<p>Loads the graph from a JSON string
|
914
|
+
Returns the number of Nodes imported</p>
|
915
|
+
|
916
|
+
|
917
|
+
</div>
|
918
|
+
</div>
|
919
|
+
<div class="tags">
|
920
|
+
|
921
|
+
|
922
|
+
</div><table class="source_code">
|
923
|
+
<tr>
|
924
|
+
<td>
|
925
|
+
<pre class="lines">
|
926
|
+
|
927
|
+
|
928
|
+
126
|
929
|
+
127
|
930
|
+
128
|
931
|
+
129
|
932
|
+
130
|
933
|
+
131
|
934
|
+
132
|
935
|
+
133
|
936
|
+
134
|
937
|
+
135
|
938
|
+
136
|
939
|
+
137
|
940
|
+
138
|
941
|
+
139
|
942
|
+
140
|
943
|
+
141</pre>
|
944
|
+
</td>
|
945
|
+
<td>
|
946
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 126</span>
|
947
|
+
|
948
948
|
<span class='kw'>def</span> <span class='id identifier rubyid_load_from_json'>load_from_json</span><span class='lparen'>(</span><span class='id identifier rubyid_str'>str</span><span class='rparen'>)</span>
|
949
949
|
<span class='id identifier rubyid_temp_hash'>temp_hash</span> <span class='op'>=</span> <span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_str'>str</span><span class='rparen'>)</span>
|
950
950
|
<span class='id identifier rubyid_nodes'>nodes</span> <span class='op'>=</span> <span class='id identifier rubyid_temp_hash'>temp_hash</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>nodes</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
@@ -960,237 +960,237 @@ Returns the number of Nodes imported</p>
|
|
960
960
|
<span class='kw'>end</span>
|
961
961
|
|
962
962
|
<span class='id identifier rubyid_nodes'>nodes</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
963
|
-
<span class='kw'>end</span></pre>
|
964
|
-
</td>
|
965
|
-
</tr>
|
966
|
-
</table>
|
967
|
-
</div>
|
968
|
-
|
969
|
-
<div class="method_details ">
|
970
|
-
<h3 class="signature " id="node_count-instance_method">
|
971
|
-
|
972
|
-
#<strong>node_count</strong> ⇒ <tt>Object</tt>
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
</h3><div class="docstring">
|
979
|
-
<div class="discussion">
|
980
|
-
<p>Retrieve the amount of nodes in the graph</p>
|
981
|
-
|
982
|
-
|
983
|
-
</div>
|
984
|
-
</div>
|
985
|
-
<div class="tags">
|
986
|
-
|
987
|
-
|
988
|
-
</div><table class="source_code">
|
989
|
-
<tr>
|
990
|
-
<td>
|
991
|
-
<pre class="lines">
|
992
|
-
|
993
|
-
|
994
|
-
60
|
995
|
-
61
|
996
|
-
62</pre>
|
997
|
-
</td>
|
998
|
-
<td>
|
999
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 60</span>
|
1000
|
-
|
963
|
+
<span class='kw'>end</span></pre>
|
964
|
+
</td>
|
965
|
+
</tr>
|
966
|
+
</table>
|
967
|
+
</div>
|
968
|
+
|
969
|
+
<div class="method_details ">
|
970
|
+
<h3 class="signature " id="node_count-instance_method">
|
971
|
+
|
972
|
+
#<strong>node_count</strong> ⇒ <tt>Object</tt>
|
973
|
+
|
974
|
+
|
975
|
+
|
976
|
+
|
977
|
+
|
978
|
+
</h3><div class="docstring">
|
979
|
+
<div class="discussion">
|
980
|
+
<p>Retrieve the amount of nodes in the graph</p>
|
981
|
+
|
982
|
+
|
983
|
+
</div>
|
984
|
+
</div>
|
985
|
+
<div class="tags">
|
986
|
+
|
987
|
+
|
988
|
+
</div><table class="source_code">
|
989
|
+
<tr>
|
990
|
+
<td>
|
991
|
+
<pre class="lines">
|
992
|
+
|
993
|
+
|
994
|
+
60
|
995
|
+
61
|
996
|
+
62</pre>
|
997
|
+
</td>
|
998
|
+
<td>
|
999
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 60</span>
|
1000
|
+
|
1001
1001
|
<span class='kw'>def</span> <span class='id identifier rubyid_node_count'>node_count</span>
|
1002
1002
|
<span class='ivar'>@nodes</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
1003
|
-
<span class='kw'>end</span></pre>
|
1004
|
-
</td>
|
1005
|
-
</tr>
|
1006
|
-
</table>
|
1007
|
-
</div>
|
1008
|
-
|
1009
|
-
<div class="method_details ">
|
1010
|
-
<h3 class="signature " id="node_ids-instance_method">
|
1011
|
-
|
1012
|
-
#<strong>node_ids</strong> ⇒ <tt>Object</tt>
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
</h3><div class="docstring">
|
1019
|
-
<div class="discussion">
|
1020
|
-
<p>Retrieve a array of node ids in the graph</p>
|
1021
|
-
|
1022
|
-
|
1023
|
-
</div>
|
1024
|
-
</div>
|
1025
|
-
<div class="tags">
|
1026
|
-
|
1027
|
-
|
1028
|
-
</div><table class="source_code">
|
1029
|
-
<tr>
|
1030
|
-
<td>
|
1031
|
-
<pre class="lines">
|
1032
|
-
|
1033
|
-
|
1034
|
-
65
|
1035
|
-
66
|
1036
|
-
67
|
1037
|
-
68</pre>
|
1038
|
-
</td>
|
1039
|
-
<td>
|
1040
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 65</span>
|
1041
|
-
|
1003
|
+
<span class='kw'>end</span></pre>
|
1004
|
+
</td>
|
1005
|
+
</tr>
|
1006
|
+
</table>
|
1007
|
+
</div>
|
1008
|
+
|
1009
|
+
<div class="method_details ">
|
1010
|
+
<h3 class="signature " id="node_ids-instance_method">
|
1011
|
+
|
1012
|
+
#<strong>node_ids</strong> ⇒ <tt>Object</tt>
|
1013
|
+
|
1014
|
+
|
1015
|
+
|
1016
|
+
|
1017
|
+
|
1018
|
+
</h3><div class="docstring">
|
1019
|
+
<div class="discussion">
|
1020
|
+
<p>Retrieve a array of node ids in the graph</p>
|
1021
|
+
|
1022
|
+
|
1023
|
+
</div>
|
1024
|
+
</div>
|
1025
|
+
<div class="tags">
|
1026
|
+
|
1027
|
+
|
1028
|
+
</div><table class="source_code">
|
1029
|
+
<tr>
|
1030
|
+
<td>
|
1031
|
+
<pre class="lines">
|
1032
|
+
|
1033
|
+
|
1034
|
+
65
|
1035
|
+
66
|
1036
|
+
67
|
1037
|
+
68</pre>
|
1038
|
+
</td>
|
1039
|
+
<td>
|
1040
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 65</span>
|
1041
|
+
|
1042
1042
|
<span class='kw'>def</span> <span class='id identifier rubyid_node_ids'>node_ids</span>
|
1043
1043
|
<span class='comment'># The .to_a call is used to return a copy of the array so it cannot be modified from the outside.
|
1044
1044
|
</span> <span class='ivar'>@nodes_by_id</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
|
1045
|
-
<span class='kw'>end</span></pre>
|
1046
|
-
</td>
|
1047
|
-
</tr>
|
1048
|
-
</table>
|
1049
|
-
</div>
|
1050
|
-
|
1051
|
-
<div class="method_details ">
|
1052
|
-
<h3 class="signature " id="nodes-instance_method">
|
1053
|
-
|
1054
|
-
#<strong>nodes</strong> ⇒ <tt>Object</tt>
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
</h3><div class="docstring">
|
1061
|
-
<div class="discussion">
|
1062
|
-
<p>Returns a hash of nodes in the graph mapped to node_id => node_data pairs</p>
|
1063
|
-
|
1064
|
-
|
1065
|
-
</div>
|
1066
|
-
</div>
|
1067
|
-
<div class="tags">
|
1068
|
-
|
1069
|
-
|
1070
|
-
</div><table class="source_code">
|
1071
|
-
<tr>
|
1072
|
-
<td>
|
1073
|
-
<pre class="lines">
|
1074
|
-
|
1075
|
-
|
1076
|
-
71
|
1077
|
-
72
|
1078
|
-
73</pre>
|
1079
|
-
</td>
|
1080
|
-
<td>
|
1081
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 71</span>
|
1082
|
-
|
1045
|
+
<span class='kw'>end</span></pre>
|
1046
|
+
</td>
|
1047
|
+
</tr>
|
1048
|
+
</table>
|
1049
|
+
</div>
|
1050
|
+
|
1051
|
+
<div class="method_details ">
|
1052
|
+
<h3 class="signature " id="nodes-instance_method">
|
1053
|
+
|
1054
|
+
#<strong>nodes</strong> ⇒ <tt>Object</tt>
|
1055
|
+
|
1056
|
+
|
1057
|
+
|
1058
|
+
|
1059
|
+
|
1060
|
+
</h3><div class="docstring">
|
1061
|
+
<div class="discussion">
|
1062
|
+
<p>Returns a hash of nodes in the graph mapped to node_id => node_data pairs</p>
|
1063
|
+
|
1064
|
+
|
1065
|
+
</div>
|
1066
|
+
</div>
|
1067
|
+
<div class="tags">
|
1068
|
+
|
1069
|
+
|
1070
|
+
</div><table class="source_code">
|
1071
|
+
<tr>
|
1072
|
+
<td>
|
1073
|
+
<pre class="lines">
|
1074
|
+
|
1075
|
+
|
1076
|
+
71
|
1077
|
+
72
|
1078
|
+
73</pre>
|
1079
|
+
</td>
|
1080
|
+
<td>
|
1081
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 71</span>
|
1082
|
+
|
1083
1083
|
<span class='kw'>def</span> <span class='id identifier rubyid_nodes'>nodes</span>
|
1084
1084
|
<span class='ivar'>@nodes</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_node'>node</span><span class='op'>|</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='op'>=></span> <span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_data'>data</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
1085
|
-
<span class='kw'>end</span></pre>
|
1086
|
-
</td>
|
1087
|
-
</tr>
|
1088
|
-
</table>
|
1089
|
-
</div>
|
1090
|
-
|
1091
|
-
<div class="method_details ">
|
1092
|
-
<h3 class="signature " id="to_dot_string-instance_method">
|
1093
|
-
|
1094
|
-
#<strong>to_dot_string</strong> ⇒ <tt>Object</tt>
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
</h3><div class="docstring">
|
1101
|
-
<div class="discussion">
|
1102
|
-
<p>Retrieve the current graph in the DOT format to be used with Graphviz</p>
|
1103
|
-
|
1104
|
-
|
1105
|
-
</div>
|
1106
|
-
</div>
|
1107
|
-
<div class="tags">
|
1108
|
-
|
1109
|
-
|
1110
|
-
</div><table class="source_code">
|
1111
|
-
<tr>
|
1112
|
-
<td>
|
1113
|
-
<pre class="lines">
|
1114
|
-
|
1115
|
-
|
1116
|
-
92
|
1117
|
-
93
|
1118
|
-
94
|
1119
|
-
95
|
1120
|
-
96
|
1121
|
-
97
|
1122
|
-
98
|
1123
|
-
99
|
1124
|
-
100
|
1125
|
-
101
|
1126
|
-
102</pre>
|
1127
|
-
</td>
|
1128
|
-
<td>
|
1129
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 92</span>
|
1130
|
-
|
1085
|
+
<span class='kw'>end</span></pre>
|
1086
|
+
</td>
|
1087
|
+
</tr>
|
1088
|
+
</table>
|
1089
|
+
</div>
|
1090
|
+
|
1091
|
+
<div class="method_details ">
|
1092
|
+
<h3 class="signature " id="to_dot_string-instance_method">
|
1093
|
+
|
1094
|
+
#<strong>to_dot_string</strong> ⇒ <tt>Object</tt>
|
1095
|
+
|
1096
|
+
|
1097
|
+
|
1098
|
+
|
1099
|
+
|
1100
|
+
</h3><div class="docstring">
|
1101
|
+
<div class="discussion">
|
1102
|
+
<p>Retrieve the current graph in the DOT format to be used with Graphviz</p>
|
1103
|
+
|
1104
|
+
|
1105
|
+
</div>
|
1106
|
+
</div>
|
1107
|
+
<div class="tags">
|
1108
|
+
|
1109
|
+
|
1110
|
+
</div><table class="source_code">
|
1111
|
+
<tr>
|
1112
|
+
<td>
|
1113
|
+
<pre class="lines">
|
1114
|
+
|
1115
|
+
|
1116
|
+
92
|
1117
|
+
93
|
1118
|
+
94
|
1119
|
+
95
|
1120
|
+
96
|
1121
|
+
97
|
1122
|
+
98
|
1123
|
+
99
|
1124
|
+
100
|
1125
|
+
101
|
1126
|
+
102</pre>
|
1127
|
+
</td>
|
1128
|
+
<td>
|
1129
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 92</span>
|
1130
|
+
|
1131
1131
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_dot_string'>to_dot_string</span>
|
1132
1132
|
<span class='id identifier rubyid_str'>str</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>strict graph {\n</span><span class='tstring_end'>"</span></span>
|
1133
1133
|
|
1134
1134
|
<span class='ivar'>@nodes</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_node'>node</span><span class='op'>|</span>
|
1135
1135
|
<span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_neighbors'>neighbors</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_neighbor'>neighbor</span><span class='op'>|</span>
|
1136
|
-
<span class='id identifier rubyid_str'>str</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier
|
1136
|
+
<span class='id identifier rubyid_str'>str</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='embexpr_end'>}</span><span class='tstring_content'>\" -- \"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_neighbor'>neighbor</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='embexpr_end'>}</span><span class='tstring_content'>\";\n</span><span class='tstring_end'>"</span></span>
|
1137
1137
|
<span class='kw'>end</span>
|
1138
1138
|
<span class='kw'>end</span>
|
1139
1139
|
|
1140
1140
|
<span class='id identifier rubyid_str'>str</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>}</span><span class='tstring_end'>"</span></span>
|
1141
|
-
<span class='kw'>end</span></pre>
|
1142
|
-
</td>
|
1143
|
-
</tr>
|
1144
|
-
</table>
|
1145
|
-
</div>
|
1146
|
-
|
1147
|
-
<div class="method_details ">
|
1148
|
-
<h3 class="signature " id="to_json-instance_method">
|
1149
|
-
|
1150
|
-
#<strong>to_json</strong> ⇒ <tt>Object</tt>
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
</h3><div class="docstring">
|
1157
|
-
<div class="discussion">
|
1158
|
-
<p>Dumps the graph to a JSON string</p>
|
1159
|
-
|
1160
|
-
|
1161
|
-
</div>
|
1162
|
-
</div>
|
1163
|
-
<div class="tags">
|
1164
|
-
|
1165
|
-
|
1166
|
-
</div><table class="source_code">
|
1167
|
-
<tr>
|
1168
|
-
<td>
|
1169
|
-
<pre class="lines">
|
1170
|
-
|
1171
|
-
|
1172
|
-
105
|
1173
|
-
106
|
1174
|
-
107
|
1175
|
-
108
|
1176
|
-
109
|
1177
|
-
110
|
1178
|
-
111
|
1179
|
-
112
|
1180
|
-
113
|
1181
|
-
114
|
1182
|
-
115
|
1183
|
-
116
|
1184
|
-
117
|
1185
|
-
118
|
1186
|
-
119
|
1187
|
-
120
|
1188
|
-
121
|
1189
|
-
122</pre>
|
1190
|
-
</td>
|
1191
|
-
<td>
|
1192
|
-
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 105</span>
|
1193
|
-
|
1141
|
+
<span class='kw'>end</span></pre>
|
1142
|
+
</td>
|
1143
|
+
</tr>
|
1144
|
+
</table>
|
1145
|
+
</div>
|
1146
|
+
|
1147
|
+
<div class="method_details ">
|
1148
|
+
<h3 class="signature " id="to_json-instance_method">
|
1149
|
+
|
1150
|
+
#<strong>to_json</strong> ⇒ <tt>Object</tt>
|
1151
|
+
|
1152
|
+
|
1153
|
+
|
1154
|
+
|
1155
|
+
|
1156
|
+
</h3><div class="docstring">
|
1157
|
+
<div class="discussion">
|
1158
|
+
<p>Dumps the graph to a JSON string</p>
|
1159
|
+
|
1160
|
+
|
1161
|
+
</div>
|
1162
|
+
</div>
|
1163
|
+
<div class="tags">
|
1164
|
+
|
1165
|
+
|
1166
|
+
</div><table class="source_code">
|
1167
|
+
<tr>
|
1168
|
+
<td>
|
1169
|
+
<pre class="lines">
|
1170
|
+
|
1171
|
+
|
1172
|
+
105
|
1173
|
+
106
|
1174
|
+
107
|
1175
|
+
108
|
1176
|
+
109
|
1177
|
+
110
|
1178
|
+
111
|
1179
|
+
112
|
1180
|
+
113
|
1181
|
+
114
|
1182
|
+
115
|
1183
|
+
116
|
1184
|
+
117
|
1185
|
+
118
|
1186
|
+
119
|
1187
|
+
120
|
1188
|
+
121
|
1189
|
+
122</pre>
|
1190
|
+
</td>
|
1191
|
+
<td>
|
1192
|
+
<pre class="code"><span class="info file"># File 'lib/simple_graph.rb', line 105</span>
|
1193
|
+
|
1194
1194
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_json'>to_json</span>
|
1195
1195
|
<span class='id identifier rubyid_temp_hash'>temp_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
1196
1196
|
<span class='label'>nodes:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span>
|
@@ -1208,22 +1208,22 @@ Returns the number of Nodes imported</p>
|
|
1208
1208
|
<span class='kw'>end</span>
|
1209
1209
|
|
1210
1210
|
<span class='const'>JSON</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span><span class='lparen'>(</span><span class='id identifier rubyid_temp_hash'>temp_hash</span><span class='rparen'>)</span>
|
1211
|
-
<span class='kw'>end</span></pre>
|
1212
|
-
</td>
|
1213
|
-
</tr>
|
1214
|
-
</table>
|
1215
|
-
</div>
|
1216
|
-
|
1217
|
-
</div>
|
1218
|
-
|
1219
|
-
</div>
|
1220
|
-
|
1221
|
-
<div id="footer">
|
1222
|
-
Generated on
|
1223
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1224
|
-
0.9.9 (ruby-2.3.1).
|
1225
|
-
</div>
|
1226
|
-
|
1227
|
-
</div>
|
1228
|
-
</body>
|
1211
|
+
<span class='kw'>end</span></pre>
|
1212
|
+
</td>
|
1213
|
+
</tr>
|
1214
|
+
</table>
|
1215
|
+
</div>
|
1216
|
+
|
1217
|
+
</div>
|
1218
|
+
|
1219
|
+
</div>
|
1220
|
+
|
1221
|
+
<div id="footer">
|
1222
|
+
Generated on Wed Dec 6 15:09:43 2017 by
|
1223
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1224
|
+
0.9.9 (ruby-2.3.1).
|
1225
|
+
</div>
|
1226
|
+
|
1227
|
+
</div>
|
1228
|
+
</body>
|
1229
1229
|
</html>
|