Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add clique and independence numbers

  • Loading branch information...
commit c2e8d1e638f38073e6a4a7280bda7ae5eec3c7be 1 parent 777def2
James Dabbs authored
12 lib/steffi/ffi/cliques.rb
View
@@ -1,15 +1,15 @@
module Steffi
module Igraph
# 15.1 Cliques
- bind :cliques, [:pointer, :pointer, :int, :int]
- bind :largest_cliques, [:pointer, :pointer]
- bind :maximal_cliques, [:pointer, :pointer, :int, :int]
+ # bind :cliques, [:pointer, :pointer, :int, :int]
+ # bind :largest_cliques, [:pointer, :pointer]
+ # bind :maximal_cliques, [:pointer, :pointer, :int, :int]
bind :clique_number, [:pointer, :pointer]
# 15.2 Independent vertex sets
- bind :independent_vertex_sets, [:pointer, :pointer, :int, :int]
- bind :largest_independent_vertex_sets, [:pointer, :pointer]
- bind :maximal_independent_vertex_sets, [:pointer, :pointer]
+ # bind :independent_vertex_sets, [:pointer, :pointer, :int, :int]
+ # bind :largest_independent_vertex_sets, [:pointer, :pointer]
+ # bind :maximal_independent_vertex_sets, [:pointer, :pointer]
bind :independence_number, [:pointer, :pointer]
end
end
1  lib/steffi/graph.rb
View
@@ -1,5 +1,6 @@
require 'steffi/graph/constructors'
require 'steffi/graph/file'
+require 'steffi/graph/cliques'
module Steffi
15 lib/steffi/graph/cliques.rb
View
@@ -0,0 +1,15 @@
+module Steffi
+ class Graph
+ def clique_number
+ FFI::MemoryPointer.new(:int).tap do |result|
+ Igraph.clique_number @pointer, result
+ end.get_int(0)
+ end
+
+ def independence_number
+ FFI::MemoryPointer.new(:int).tap do |result|
+ Igraph.independence_number @pointer, result
+ end.get_int(0)
+ end
+ end
+end
8 spec/steffi/cliques_spec.rb
View
@@ -0,0 +1,8 @@
+require 'helper'
+
+describe 'Cliques' do
+ subject { Steffi::Graph.famous 'zachary' }
+
+ its(:clique_number) { should == 5 }
+ its(:independence_number) { should == 20 }
+end
Please sign in to comment.
Something went wrong with that request. Please try again.