Permalink
Browse files

Clean up vestigial code

  • Loading branch information...
jamesdabbs committed Apr 11, 2013
1 parent ebffcf8 commit 6fc562806d94cca38027b2e5d0808ce95d14af8e
Showing with 9 additions and 35 deletions.
  1. +5 −7 lib/steffi/edge.rb
  2. +1 −1 lib/steffi/edge_set.rb
  3. +0 −16 lib/steffi/metrics.rb
  4. +0 −10 lib/steffi/vector.rb
  5. +2 −0 lib/steffi/vertex.rb
  6. +1 −1 spec/steffi/graph_spec.rb
View
@@ -1,15 +1,13 @@
module Steffi
class Edge
- attr_accessor :graph, :from, :to
+ attr_reader :graph, :from, :to
- def initialize graph,from,to
- @graph = graph
- @from = from
- @to = to
+ def initialize graph, from, to
+ @graph, @from, @to = graph, from, to
end
- def to_s
- "(#{from},#{to})"
+ def to_pair
+ [@from, @to]
end
end
end
View
@@ -24,7 +24,7 @@ def [] n
from = FFI::MemoryPointer.new :int
to = FFI::MemoryPointer.new :int
Igraph.edge @graph.pointer, n, from, to
- [from.get_int(0), to.get_int(0)]
+ Edge.new @graph, from.get_int(0), to.get_int(0)
end
def each
View
@@ -13,21 +13,5 @@ def diameter
def stats
Hash[ %w{ diameter ecount vcount }.map { |n| [ n, send(n) ] } ]
end
-
- def edge i
- from = FFI::MemoryPointer.new :int
- to = FFI::MemoryPointer.new :int
- Igraph.edge ptr, i, from, to
- Edge.new self, from.get_int(0), to.get_int(0)
- end
-
- # def edges
- # 0.upto(ecount - 1).map { |i| edge i }
- # end
-
- # def vertices
- # 0.upto(vcount - 1).to_a
- # end
-
end
end
View
@@ -78,15 +78,5 @@ def sum
def product
Igraph.vector_prod @pointer
end
-
- # def to_s
- # to_a.to_s
- # end
-
- # def self.from_a ary
- # v = new
- # ary.each { |i| v << i }
- # v
- # end
end
end
View
@@ -1,5 +1,7 @@
module Steffi
class Vertex
+ attr_reader :graph, :id
+
def initialize graph, id
@graph, @id = graph, id
end
@@ -47,7 +47,7 @@
it 'can look up edges by id' do
g = Steffi::Graph.full 5
- g.edges.first.should == [0, 1]
+ g.edges.first.to_pair.should == [0, 1]
end
it 'can look up edges by vertex' do

0 comments on commit 6fc5628

Please sign in to comment.