mpath_graph 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mpath_graph.rb +29 -0
- data/lib/mpath_graph/version.rb +1 -1
- data/test/test_mpath_graph.rb +26 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f3784e16dd4d77ac7d5807f57e3cb23576160ae
|
4
|
+
data.tar.gz: a19ca64b2b62264a83492640588e33969c57f75e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b8e837bc5b616e12699bf0d63f3e201ac23a5e153cf3ba77db478106a8bd47f972998a629fa2a63b6267ac378b68271b8cd118b3a8542f0d1779f7f128583f
|
7
|
+
data.tar.gz: 528876979ca88371ddee480494b4590fbbf623b072ed65a8b11b3de54a04f96ab1d43762909a378af8fa9b453b78f7250d293d8aed4e9f350b55fc1acce92e8c
|
data/lib/mpath_graph.rb
CHANGED
@@ -190,6 +190,35 @@ module MPathGraph
|
|
190
190
|
paths
|
191
191
|
end
|
192
192
|
|
193
|
+
def self.share_inner_vertices?(path_a, path_b)
|
194
|
+
raise ArgumentError, "Path must have same lenght" if path_a.size != path_b.size
|
195
|
+
|
196
|
+
path_a[1..-2].each { |a| path_b.each { |b| return true if a == b } }
|
197
|
+
path_b[1..-2].each { |b| return true if b == path_a[0] || b == path_a[-1] }
|
198
|
+
false
|
199
|
+
end
|
200
|
+
|
201
|
+
def self.gen_mpath_graph_from_paths(paths)
|
202
|
+
mp_graph_edges = []
|
203
|
+
|
204
|
+
pbar = ProgressBar.create(
|
205
|
+
title: "Computing mPath graph",
|
206
|
+
output: STDERR,
|
207
|
+
format: "%t [%B] [%c/%C - %P%%]",
|
208
|
+
total: paths.size-1)
|
209
|
+
|
210
|
+
(0..paths.size-2).each do |i|
|
211
|
+
((i+1)...paths.size).each do |j|
|
212
|
+
share = MPathGraph::share_inner_vertices?(paths[i],paths[j])
|
213
|
+
mp_graph_edges << [i,j] if share
|
214
|
+
end
|
215
|
+
pbar.increment
|
216
|
+
end
|
217
|
+
pbar.finish
|
218
|
+
|
219
|
+
mp_graph_edges
|
220
|
+
end
|
221
|
+
|
193
222
|
module OddHole
|
194
223
|
def self.equivalents(hole)
|
195
224
|
perms = [hole.reverse]
|
data/lib/mpath_graph/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'mpath_graph'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/unit'
|
4
|
+
|
5
|
+
# Author:: Israel Buitron (mailto:ibuitron@computacion.cs.cinvestav.mx)
|
6
|
+
class TestMPathGraph < MiniTest::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_gen_mpath_graph_from_paths
|
12
|
+
paths = [[1,2,3,4],[5,6,7,8],[0,1,8,4]]
|
13
|
+
|
14
|
+
assert_equal [[0,2],[1,2]], MPathGraph::gen_mpath_graph_from_paths(paths)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_share_inner_vertices
|
18
|
+
assert_raises(ArgumentError) {MPathGraph::share_inner_vertices?([],[1])}
|
19
|
+
|
20
|
+
refute MPathGraph::share_inner_vertices?([1,2,3,4,5,6],[0,7,8,9,10,11])
|
21
|
+
refute MPathGraph::share_inner_vertices?([1,2,3,4,5,6],[1,7,8,9,10,11])
|
22
|
+
assert MPathGraph::share_inner_vertices?([1,2,3,4,5,6],[0,1,8,9,10,11])
|
23
|
+
assert MPathGraph::share_inner_vertices?([1,2,3,4,5,6],[2,7,8,9,10,11])
|
24
|
+
assert MPathGraph::share_inner_vertices?([1,2,3,4,5,6],[6,7,8,4,9,0])
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpath_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Israel Buitron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-progressbar
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/mpath_graph.rb
|
84
84
|
- lib/mpath_graph/version.rb
|
85
85
|
- mpath_graph.gemspec
|
86
|
+
- test/test_mpath_graph.rb
|
86
87
|
- test/test_mpath_graph_odd_hole.rb
|
87
88
|
homepage: ''
|
88
89
|
licenses:
|
@@ -109,4 +110,5 @@ signing_key:
|
|
109
110
|
specification_version: 4
|
110
111
|
summary: m-Path graphs library
|
111
112
|
test_files:
|
113
|
+
- test/test_mpath_graph.rb
|
112
114
|
- test/test_mpath_graph_odd_hole.rb
|