graphos 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c01223437fbfd0807465f7c3e906beea53a3968
4
- data.tar.gz: c22534c9913af9e5fe26f349ea47acae83076338
3
+ metadata.gz: 17e52e382a16f64bff7268a1e16d05b766ffba07
4
+ data.tar.gz: 2722ab24892ed985395292e46d7589cf0a610cbf
5
5
  SHA512:
6
- metadata.gz: 1bc419449e7f18fed8132f94b9adf7322a9e556f61f0cc281a488d8cd856b45b3477596e17762e2205427dddabd8c84806881363719e19c779e1be83528b6984
7
- data.tar.gz: 22504d8ce07925db07a2aab39d76db7b0201be6e0c0ff4f35205b9b767a9d602a0d963a5f5f0a5e34e34daf19d8ff27e9e0928cca17fc4d00dfc3675b64660b5
6
+ metadata.gz: 3ddb151b5cec18977a18fd12b6814009c0744241e02d42fd2b38c68fe05a78cb9c4dc0b4be8af84b5447792b59565ba2c15aeeb1ea6ea034f6c92a2e15b58458
7
+ data.tar.gz: e459dd620cb44803f8581bbd6f1df29a1d1a82db01731741bef88c6e23a3edf641d32915e58f9e9dde6bc28eafbeb7c8f9a718a7954318334f0a99b41de06c00
@@ -25,13 +25,18 @@ module Graphos
25
25
 
26
26
  update_cost = -> (idx,cost) do
27
27
  costs[idx] = cost
28
- heap.change_key(idx,idx)
28
+ if(heap.has_key?(idx))
29
+ heap.delete(idx)
30
+ heap.push(idx)
31
+ end
29
32
  end
30
33
 
34
+ count = 0
31
35
 
32
36
  #Para cada vértice v
33
37
  #enquanto heap (S-V) != 0
34
38
  while idx=heap.pop
39
+ count += 1
35
40
  #Selecione u em V-S, tal que dist[u] é mínima
36
41
  u = graph[idx]
37
42
  distu = costs[idx]
@@ -48,6 +53,9 @@ module Graphos
48
53
  allPaths[edge.to.index] = allPaths[u.index] + Path.new(edge)
49
54
  end
50
55
  end
56
+
57
+ # No more nodes!
58
+ break if(idx == heap.next)
51
59
  end
52
60
 
53
61
  allPaths
@@ -18,7 +18,10 @@ module Graphos
18
18
 
19
19
  update_cost = -> (idx,cost) do
20
20
  costs[idx] = cost
21
- heap.change_key(idx,idx)
21
+ if(heap.has_key?(idx))
22
+ heap.delete(idx)
23
+ heap.push(idx)
24
+ end
22
25
  end
23
26
 
24
27
  while idx=heap.pop
@@ -1,3 +1,3 @@
1
1
  module Graphos
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -3,6 +3,13 @@ require "graphos/weighted/graph"
3
3
  require "graphos/algorithm/dijkstra"
4
4
 
5
5
  class DijkstraTest < MiniTest::Test
6
+ def test_100
7
+ graph = Graphos::Weighted::TextFactory.read("test/fixtures/grafo_1.txt")
8
+
9
+ dij = Graphos::Algorithm.dijkstra graph, 0
10
+
11
+ assert_equal([99,16,7,66,9], ipath(dij[9]))
12
+ end
6
13
  def test_dijskstra
7
14
  graph = Graphos::Weighted::Graph.new(5)
8
15
  graph.add_edge 0, 1, 2
@@ -0,0 +1,420 @@
1
+ 100
2
+ 22 84 4
3
+ 30 37 15
4
+ 10 67 2
5
+ 24 64 6
6
+ 55 82 1
7
+ 73 82 10
8
+ 6 67 15
9
+ 55 87 2
10
+ 48 53 2
11
+ 47 81 14
12
+ 2 61 10
13
+ 57 100 12
14
+ 7 87 11
15
+ 79 95 12
16
+ 6 29 3
17
+ 5 6 7
18
+ 21 68 11
19
+ 55 62 6
20
+ 50 53 14
21
+ 10 26 8
22
+ 6 34 14
23
+ 67 89 1
24
+ 62 98 3
25
+ 26 85 11
26
+ 40 74 13
27
+ 92 93 12
28
+ 14 34 11
29
+ 8 39 5
30
+ 87 88 4
31
+ 3 4 8
32
+ 23 93 7
33
+ 10 40 3
34
+ 89 91 11
35
+ 25 81 12
36
+ 19 91 10
37
+ 10 98 6
38
+ 15 45 7
39
+ 72 82 13
40
+ 31 77 10
41
+ 30 93 1
42
+ 60 72 1
43
+ 7 58 5
44
+ 23 24 11
45
+ 51 52 15
46
+ 24 25 15
47
+ 21 97 6
48
+ 72 73 8
49
+ 59 60 7
50
+ 45 72 4
51
+ 72 94 8
52
+ 37 93 7
53
+ 55 59 8
54
+ 8 14 11
55
+ 30 94 3
56
+ 88 89 11
57
+ 50 73 6
58
+ 50 82 15
59
+ 6 73 2
60
+ 100 1 12
61
+ 24 94 15
62
+ 76 77 11
63
+ 29 87 5
64
+ 48 73 7
65
+ 24 26 9
66
+ 58 98 1
67
+ 57 86 1
68
+ 21 62 14
69
+ 6 72 12
70
+ 26 40 4
71
+ 14 64 3
72
+ 24 29 12
73
+ 48 87 3
74
+ 48 61 2
75
+ 44 45 7
76
+ 61 98 13
77
+ 36 37 1
78
+ 59 82 15
79
+ 9 79 7
80
+ 6 45 14
81
+ 24 72 6
82
+ 2 81 7
83
+ 45 60 7
84
+ 48 81 2
85
+ 48 60 9
86
+ 53 82 13
87
+ 10 74 15
88
+ 35 80 2
89
+ 7 35 5
90
+ 2 98 15
91
+ 37 97 7
92
+ 15 82 7
93
+ 34 87 11
94
+ 84 87 5
95
+ 6 41 9
96
+ 9 95 14
97
+ 6 50 8
98
+ 14 91 2
99
+ 19 26 7
100
+ 52 53 5
101
+ 50 59 3
102
+ 14 89 4
103
+ 15 60 1
104
+ 35 36 5
105
+ 53 55 7
106
+ 14 24 8
107
+ 9 10 2
108
+ 61 84 11
109
+ 19 20 3
110
+ 73 74 2
111
+ 62 94 5
112
+ 99 100 4
113
+ 75 76 1
114
+ 10 64 14
115
+ 24 67 14
116
+ 2 85 15
117
+ 4 8 12
118
+ 95 96 14
119
+ 13 14 1
120
+ 50 72 14
121
+ 72 93 5
122
+ 2 3 2
123
+ 24 40 4
124
+ 60 82 13
125
+ 62 73 4
126
+ 55 73 15
127
+ 34 35 12
128
+ 7 80 7
129
+ 71 72 4
130
+ 8 17 1
131
+ 15 16 12
132
+ 6 82 13
133
+ 40 58 6
134
+ 11 12 1
135
+ 45 62 11
136
+ 19 67 5
137
+ 24 74 12
138
+ 34 84 6
139
+ 65 66 15
140
+ 10 89 2
141
+ 60 87 14
142
+ 2 34 11
143
+ 62 87 12
144
+ 7 61 7
145
+ 67 91 11
146
+ 6 15 2
147
+ 81 86 4
148
+ 96 97 3
149
+ 18 90 8
150
+ 37 72 4
151
+ 14 40 9
152
+ 68 97 5
153
+ 40 62 7
154
+ 40 41 13
155
+ 24 93 15
156
+ 8 40 3
157
+ 10 24 4
158
+ 8 24 6
159
+ 48 62 4
160
+ 29 61 2
161
+ 47 86 13
162
+ 6 53 11
163
+ 7 67 14
164
+ 51 95 5
165
+ 55 56 3
166
+ 55 72 4
167
+ 33 34 8
168
+ 7 84 7
169
+ 37 98 8
170
+ 6 62 10
171
+ 8 79 2
172
+ 6 60 6
173
+ 4 51 4
174
+ 8 73 1
175
+ 14 19 5
176
+ 61 81 4
177
+ 15 59 11
178
+ 6 59 9
179
+ 6 98 15
180
+ 32 33 5
181
+ 38 39 13
182
+ 20 21 10
183
+ 2 25 15
184
+ 69 70 8
185
+ 40 89 12
186
+ 2 37 5
187
+ 30 31 2
188
+ 14 15 9
189
+ 59 73 14
190
+ 80 81 5
191
+ 8 95 7
192
+ 2 97 15
193
+ 2 20 11
194
+ 46 89 8
195
+ 29 93 6
196
+ 4 5 7
197
+ 60 62 13
198
+ 22 87 7
199
+ 53 54 5
200
+ 7 8 6
201
+ 93 94 8
202
+ 22 34 7
203
+ 25 47 8
204
+ 23 37 10
205
+ 53 87 14
206
+ 63 98 8
207
+ 74 89 10
208
+ 53 62 6
209
+ 55 60 7
210
+ 24 89 13
211
+ 1 2 15
212
+ 12 13 15
213
+ 73 87 3
214
+ 67 87 15
215
+ 47 61 15
216
+ 42 43 14
217
+ 2 47 13
218
+ 50 60 6
219
+ 84 98 2
220
+ 22 61 6
221
+ 8 91 3
222
+ 25 48 15
223
+ 30 72 5
224
+ 23 72 4
225
+ 63 64 9
226
+ 29 67 1
227
+ 45 46 15
228
+ 34 98 14
229
+ 18 19 12
230
+ 15 53 6
231
+ 10 63 12
232
+ 6 48 5
233
+ 15 73 15
234
+ 45 73 15
235
+ 9 39 8
236
+ 40 91 9
237
+ 23 94 9
238
+ 48 59 8
239
+ 61 67 9
240
+ 34 61 2
241
+ 61 87 6
242
+ 41 42 10
243
+ 45 59 8
244
+ 4 9 14
245
+ 48 86 12
246
+ 83 84 8
247
+ 20 34 10
248
+ 27 28 13
249
+ 15 55 13
250
+ 19 24 7
251
+ 64 89 10
252
+ 78 79 5
253
+ 14 74 9
254
+ 45 48 6
255
+ 82 87 6
256
+ 81 82 13
257
+ 62 63 12
258
+ 53 73 7
259
+ 48 82 8
260
+ 26 31 1
261
+ 62 82 13
262
+ 98 99 3
263
+ 38 92 2
264
+ 2 48 12
265
+ 2 6 11
266
+ 7 34 2
267
+ 6 52 10
268
+ 24 30 2
269
+ 8 74 4
270
+ 3 12 4
271
+ 8 10 4
272
+ 23 30 10
273
+ 29 30 14
274
+ 82 83 12
275
+ 67 84 5
276
+ 29 94 9
277
+ 60 73 6
278
+ 37 94 1
279
+ 10 11 9
280
+ 7 62 13
281
+ 49 50 9
282
+ 26 77 6
283
+ 29 98 6
284
+ 45 53 12
285
+ 19 74 2
286
+ 59 72 11
287
+ 59 62 3
288
+ 8 19 10
289
+ 45 55 15
290
+ 7 29 4
291
+ 37 38 9
292
+ 27 92 14
293
+ 29 34 7
294
+ 26 67 1
295
+ 86 100 14
296
+ 48 49 13
297
+ 63 75 2
298
+ 26 89 15
299
+ 10 14 10
300
+ 70 71 13
301
+ 90 91 5
302
+ 15 72 7
303
+ 31 32 5
304
+ 19 64 9
305
+ 26 27 10
306
+ 60 61 14
307
+ 28 29 3
308
+ 22 98 14
309
+ 35 71 10
310
+ 6 22 3
311
+ 74 91 15
312
+ 28 80 2
313
+ 6 87 13
314
+ 53 72 8
315
+ 50 51 9
316
+ 87 94 7
317
+ 67 68 3
318
+ 51 92 7
319
+ 8 9 14
320
+ 29 72 2
321
+ 26 64 15
322
+ 15 62 15
323
+ 7 98 6
324
+ 19 89 14
325
+ 47 48 6
326
+ 64 74 2
327
+ 8 67 1
328
+ 74 75 14
329
+ 22 29 12
330
+ 72 87 7
331
+ 4 63 4
332
+ 46 47 13
333
+ 50 62 15
334
+ 89 90 11
335
+ 21 22 15
336
+ 45 50 13
337
+ 86 87 8
338
+ 58 59 9
339
+ 17 100 3
340
+ 39 40 4
341
+ 40 67 6
342
+ 87 98 12
343
+ 4 95 3
344
+ 14 26 12
345
+ 64 67 1
346
+ 59 87 11
347
+ 10 91 5
348
+ 39 95 2
349
+ 34 67 14
350
+ 91 92 10
351
+ 29 84 8
352
+ 8 26 11
353
+ 43 44 3
354
+ 58 62 13
355
+ 17 18 3
356
+ 53 60 10
357
+ 8 89 13
358
+ 50 87 7
359
+ 85 86 15
360
+ 84 85 15
361
+ 61 62 9
362
+ 24 91 1
363
+ 68 69 7
364
+ 40 98 14
365
+ 38 51 12
366
+ 10 85 5
367
+ 45 87 14
368
+ 57 58 4
369
+ 51 63 2
370
+ 22 23 11
371
+ 23 29 4
372
+ 7 22 5
373
+ 79 80 1
374
+ 15 87 2
375
+ 6 7 13
376
+ 22 67 14
377
+ 94 95 12
378
+ 54 55 11
379
+ 48 50 7
380
+ 24 37 1
381
+ 6 84 12
382
+ 10 19 6
383
+ 39 79 6
384
+ 29 37 7
385
+ 56 57 3
386
+ 66 67 7
387
+ 45 82 10
388
+ 25 26 6
389
+ 4 39 14
390
+ 7 40 7
391
+ 61 86 2
392
+ 26 74 7
393
+ 6 55 11
394
+ 64 91 6
395
+ 25 61 6
396
+ 4 79 9
397
+ 53 59 5
398
+ 2 86 5
399
+ 25 86 11
400
+ 48 72 12
401
+ 67 74 15
402
+ 48 55 11
403
+ 40 64 12
404
+ 8 64 6
405
+ 19 40 4
406
+ 41 52 3
407
+ 15 50 7
408
+ 16 17 10
409
+ 26 91 2
410
+ 6 61 15
411
+ 50 55 10
412
+ 64 65 4
413
+ 35 72 15
414
+ 97 98 5
415
+ 14 67 14
416
+ 15 48 5
417
+ 8 100 11
418
+ 67 98 11
419
+ 77 78 8
420
+ 62 72 14
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo Amorim
@@ -119,6 +119,7 @@ files:
119
119
  - lib/graphos/weighted/node.rb
120
120
  - lib/graphos/weighted/text_factory.rb
121
121
  - test/dijsktra_test.rb
122
+ - test/fixtures/grafo_1.txt
122
123
  - test/fixtures/wgraph.txt
123
124
  - test/minitest_helper.rb
124
125
  - test/prim_test.rb
@@ -150,6 +151,7 @@ specification_version: 4
150
151
  summary: Educational gem to Graph Theory @ UFRJ
151
152
  test_files:
152
153
  - test/dijsktra_test.rb
154
+ - test/fixtures/grafo_1.txt
153
155
  - test/fixtures/wgraph.txt
154
156
  - test/minitest_helper.rb
155
157
  - test/prim_test.rb