mementus 0.5.12 → 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mementus/structure/incidence_list.rb +6 -4
- data/lib/mementus/version.rb +1 -1
- data/spec/graph_spec.rb +13 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 370fd832daecae6063fc22be3eb5cab1ca2708cb
|
4
|
+
data.tar.gz: 783911cfac6d8d59f3393ff9376957b15610b6e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62ea1f77ad1e71f6b441ff86ac928deccf75a46128dc1fe4090db668d51218c759f1c683a796baa4f85d9f50edc723187600e5bf6f1ebeba6f966a423ee5584b
|
7
|
+
data.tar.gz: be965f81ebe52be72f30a7055518cca83f60d5f51f70ca04f54f966508fcc9f1e18b8e45426164f54ab75d218a18783293aa3c8a96bc93a3833eb4dd059aa37f
|
@@ -31,10 +31,12 @@ module Mementus
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def has_edge?(edge,
|
35
|
-
if
|
36
|
-
return node(edge)
|
37
|
-
|
34
|
+
def has_edge?(edge, target=nil)
|
35
|
+
if target
|
36
|
+
return false unless source = node(edge)
|
37
|
+
|
38
|
+
return source.outgoing.any? do |candidate|
|
39
|
+
candidate.id == target
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
data/lib/mementus/version.rb
CHANGED
data/spec/graph_spec.rb
CHANGED
@@ -152,13 +152,25 @@ describe Mementus::Graph do
|
|
152
152
|
expect(graph.has_edge?(edge_1_2)).to be true
|
153
153
|
end
|
154
154
|
|
155
|
+
specify '!edge' do
|
156
|
+
expect(graph.has_edge?(Mementus::Edge.new(id: 11, from: 22, to: 33))).to be false
|
157
|
+
end
|
158
|
+
|
155
159
|
specify 'edge.id' do
|
156
160
|
expect(graph.has_edge?(edge_1_2.id)).to be true
|
157
161
|
end
|
158
162
|
|
159
|
-
specify '
|
163
|
+
specify '!edge.id' do
|
164
|
+
expect(graph.has_edge?(4)).to be false
|
165
|
+
end
|
166
|
+
|
167
|
+
specify 'from.id -> to.id' do
|
160
168
|
expect(graph.has_edge?(1, 2)).to be true
|
161
169
|
end
|
170
|
+
|
171
|
+
specify '!from.id -> !to.id' do
|
172
|
+
expect(graph.has_edge?(12, 21)).to be false
|
173
|
+
end
|
162
174
|
end
|
163
175
|
|
164
176
|
specify '#node(id)' do
|