gratr19 0.4.4 → 0.4.4.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.
- data/lib/gratr/graph.rb +10 -5
- data/lib/gratr/labels.rb +12 -6
- data/lib/gratr/version.rb +1 -1
- metadata +3 -2
data/lib/gratr/graph.rb
CHANGED
@@ -267,8 +267,10 @@ module GRATR
|
|
267
267
|
def +(other)
|
268
268
|
result = self.class.new(self)
|
269
269
|
case other
|
270
|
-
when GRATR::Graph
|
271
|
-
|
270
|
+
when GRATR::Graph
|
271
|
+
result.merge(other)
|
272
|
+
when GRATR::Arc
|
273
|
+
result.add_edge!(other)
|
272
274
|
else result.add_vertex!(other)
|
273
275
|
end
|
274
276
|
end
|
@@ -276,9 +278,12 @@ module GRATR
|
|
276
278
|
# Remove all vertices in the specified right hand side graph
|
277
279
|
def -(other)
|
278
280
|
case other
|
279
|
-
when GRATR::Graph
|
280
|
-
|
281
|
-
|
281
|
+
when GRATR::Graph
|
282
|
+
induced_subgraph(vertices - other.vertices)
|
283
|
+
when GRATR::Arc
|
284
|
+
self.class.new(self).remove_edge!(other)
|
285
|
+
else
|
286
|
+
self.class.new(self).remove_vertex!(other)
|
282
287
|
end
|
283
288
|
end
|
284
289
|
|
data/lib/gratr/labels.rb
CHANGED
@@ -81,9 +81,12 @@ module GRATR
|
|
81
81
|
def cost(u,v=nil,weight=nil)
|
82
82
|
u.kind_of?(Arc) ? weight = v : u = edge_class[u,v]
|
83
83
|
case weight
|
84
|
-
when Proc
|
85
|
-
|
86
|
-
|
84
|
+
when Proc
|
85
|
+
weight.call(u)
|
86
|
+
when nil
|
87
|
+
self[u]
|
88
|
+
else
|
89
|
+
self[u][weight]
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
@@ -93,9 +96,12 @@ module GRATR
|
|
93
96
|
# A function to set properties specified by the user.
|
94
97
|
def property_set(u,name,value)
|
95
98
|
case name
|
96
|
-
when Proc
|
97
|
-
|
98
|
-
|
99
|
+
when Proc
|
100
|
+
name.call(value)
|
101
|
+
when nil
|
102
|
+
self[u] = value
|
103
|
+
else
|
104
|
+
self[u][name] = value
|
99
105
|
end
|
100
106
|
end
|
101
107
|
|
data/lib/gratr/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gratr19
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 125
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
9
|
- 4
|
10
|
-
|
10
|
+
- 1
|
11
|
+
version: 0.4.4.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Shawn Garbett
|