rgraph 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rgraph/graph.rb CHANGED
@@ -108,7 +108,7 @@ class Graph
108
108
  i.upto(@nodes.size - 1).each do |j|
109
109
  next if i == j
110
110
  sp = shortest_path(i, j)
111
- tmp << sp if sp
111
+ tmp << sp unless sp.empty?
112
112
  end
113
113
  end
114
114
 
@@ -1,3 +1,3 @@
1
1
  module Rgraph
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
@@ -142,6 +142,11 @@ describe Graph do
142
142
  [3, 4], [3, 5],
143
143
  [4, 3, 5]].sort)
144
144
  end
145
+ it "doesn't return empty paths" do
146
+ g = Graph.new_from_string("source,target\n1,2\n3,4")
147
+ expect(g.shortest_paths).to eq([[0,1],[2,3]])
148
+ end
149
+
145
150
  it "calculates the betweenness of a single node" do
146
151
  expect(subject.between(0)).to eq(0 / 15.0)
147
152
  expect(subject.between(1)).to eq(2 / 15.0)
@@ -163,6 +168,10 @@ describe Graph do
163
168
  expect(subject.betweenness(normalized: true)).to eq(
164
169
  [0.0, 0.5, 0.5, 1.0, 0.5, 0.0])
165
170
  end
171
+ it "works with holes" do
172
+ g = Graph.new_from_string("source,target\n1,2\n3,4")
173
+ expect(g.betweenness.inject(:+)).to eq(0)
174
+ end
166
175
  it "calculates diameter" do
167
176
  expect(subject.diameter).to eq(3)
168
177
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: