Permalink
Browse files

Add enum for neighbor mode

  • Loading branch information...
1 parent 507ebf4 commit 00cc294af3459941fc9e9c72186a218092f9f0ba @jamesdabbs committed Apr 11, 2013
Showing with 12 additions and 12 deletions.
  1. +4 −2 lib/steffi/ffi.rb
  2. +8 −10 lib/steffi/vertex.rb
View
@@ -33,6 +33,8 @@ def self.method_missing name, *args, &block
send :"igraph_#{name}", *args, &block
end
end
+
+ enum :neimode, [:out, 1, :in, 2, :all, 3, :total, 3]
# 4.2.1 Graph constructors and deconstructors
bind :empty, [:pointer, :int, :bool]
@@ -50,8 +52,8 @@ def self.method_missing name, *args, &block
# graph, &[edge #]. &[pairs], &[path], directed?, error?
bind :get_eids_multi, [:pointer, :pointer, :pointer, :pointer, :bool, :bool]
- bind :neighbors, [:pointer, :pointer, :int, :int]
- bind :incident, [:pointer, :pointer, :int, :int]
+ bind :neighbors, [:pointer, :pointer, :int, :neimode]
+ bind :incident, [:pointer, :pointer, :int, :neimode]
bind :is_directed, [:pointer], :bool
# graph, &[results], vids, mode, loops?
View
@@ -4,18 +4,16 @@ def initialize graph, id
@graph, @id = graph, id
end
- def neighbors
- mode = 3 # IGRAPH_ALL / FIXME: define and use enum
- v = Vector.null
- Igraph.neighbors @graph.pointer, v.pointer, @id, mode
- v.to_a
+ def neighbors mode=:all
+ Vector.null.tap do |v|
+ Igraph.neighbors @graph.pointer, v.pointer, @id, mode
+ end.to_a
end
- def incident
- mode = 3 # IGRAPH_ALL / FIXME: define and use enum
- v = Vector.null
- Igraph.incident @graph.pointer, v.pointer, @id, mode
- v.map &:to_i
+ def incident mode=:all
+ Vector.null.tap do |v|
+ Igraph.incident @graph.pointer, v.pointer, @id, mode
+ end.map &:to_i
end
end
end

0 comments on commit 00cc294

Please sign in to comment.