rgraph 0.0.10 → 0.0.11
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/rgraph/graph.rb +1 -1
 - data/lib/rgraph/version.rb +1 -1
 - data/spec/rgraph/graph_spec.rb +9 -0
 - metadata +1 -1
 
    
        data/lib/rgraph/graph.rb
    CHANGED
    
    
    
        data/lib/rgraph/version.rb
    CHANGED
    
    
    
        data/spec/rgraph/graph_spec.rb
    CHANGED
    
    | 
         @@ -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
         
     |