Changes to compile under IGraph 0.5.
git-svn-id: http://igraph.rubyforge.org/svn/trunk@70 71f48855-0bbf-4aa5-930d-4df415e86613
This commit is contained in:
parent
d94ad6f272
commit
0fa624cdb2
|
|
@ -3,7 +3,7 @@ require 'hoe'
|
|||
$LOAD_PATH.unshift("./ext")
|
||||
|
||||
class IGraph
|
||||
VERSION = "0.9.1"
|
||||
VERSION = "0.9.5"
|
||||
end
|
||||
|
||||
begin
|
||||
|
|
@ -14,7 +14,7 @@ end
|
|||
hoe = Hoe.new("igraph",IGraph::VERSION) do |p|
|
||||
|
||||
p.author = "Alex Gutteridge"
|
||||
p.email = "alexg@kuicr.kyoto-u.ac.jp"
|
||||
p.email = "ag357@cam.ac.uk"
|
||||
p.url = "http://igraph.rubyforge.org/"
|
||||
|
||||
p.description = p.paragraphs_of("README.txt",1..3)[0]
|
||||
|
|
|
|||
|
|
@ -546,7 +546,7 @@ void Init_igraph(){
|
|||
rb_include_module(cIGraph, cIGraph_community);
|
||||
|
||||
rb_define_method(cIGraph_community, "modularity", cIGraph_modularity, 1); /* in cIGraph_community.c */
|
||||
rb_define_method(cIGraph_community, "community_to_membership", cIGraph_community_to_membership, 2); /* in cIGraph_community.c */
|
||||
rb_define_method(cIGraph_community, "community_to_membership", cIGraph_community_to_membership, 3); /* in cIGraph_community.c */
|
||||
rb_define_method(cIGraph_community, "community_spinglass", cIGraph_community_spinglass, 8); /* in cIGraph_community.c */
|
||||
rb_define_method(cIGraph_community, "community_spinglass_single", cIGraph_community_spinglass_single, 5); /* in cIGraph_community.c */
|
||||
rb_define_method(cIGraph_community, "community_leading_eigenvector", cIGraph_community_leading_eigenvector, 1); /* in cIGraph_community.c */
|
||||
|
|
@ -624,7 +624,7 @@ void Init_igraph(){
|
|||
rb_define_method(cIGraphMatrix, "ncol", cIGraph_matrix_ncol, 0); /* in cIGraph_matrix.c */
|
||||
rb_define_method(cIGraphMatrix, "max", cIGraph_matrix_max, 0); /* in cIGraph_matrix.c */
|
||||
|
||||
rb_define_method(cIGraphMatrix, "*", cIGraph_matrix_multiply, 1); /* in cIGraph_matrix.c */
|
||||
rb_define_method(cIGraphMatrix, "*", cIGraph_matrix_scale, 1); /* in cIGraph_matrix.c */
|
||||
|
||||
rb_define_method(cIGraphMatrix, "to_a", cIGraph_matrix_toa, 0); /* in cIGraph_matrix.c */
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ VALUE cIGraph_cohesion(VALUE self);
|
|||
//Community
|
||||
VALUE cIGraph_modularity (VALUE self, VALUE groups);
|
||||
VALUE cIGraph_community_to_membership (VALUE self, VALUE merge,
|
||||
VALUE steps);
|
||||
VALUE steps, VALUE nodes);
|
||||
VALUE cIGraph_community_spinglass (VALUE self, VALUE weights,
|
||||
VALUE spins,
|
||||
VALUE parupdate,
|
||||
|
|
@ -390,7 +390,7 @@ VALUE cIGraph_matrix_nrow(VALUE self);
|
|||
VALUE cIGraph_matrix_ncol(VALUE self);
|
||||
VALUE cIGraph_matrix_max (VALUE self);
|
||||
|
||||
VALUE cIGraph_matrix_multiply(VALUE self, VALUE x);
|
||||
VALUE cIGraph_matrix_scale(VALUE self, VALUE x);
|
||||
|
||||
VALUE cIGraph_matrix_toa(VALUE self);
|
||||
|
||||
|
|
|
|||
|
|
@ -161,8 +161,8 @@ VALUE cIGraph_pagerank(VALUE self, VALUE vs, VALUE directed, VALUE niter, VALUE
|
|||
//create vertex selector from the vecotr of ids
|
||||
igraph_vs_vector(&vids,&vidv);
|
||||
|
||||
igraph_pagerank(graph,&res,vids,dir,
|
||||
NUM2INT(niter),NUM2DBL(eps),NUM2DBL(damping));
|
||||
igraph_pagerank_old(graph,&res,vids,dir,
|
||||
NUM2INT(niter),NUM2DBL(eps),NUM2DBL(damping),0);
|
||||
|
||||
for(i=0;i<igraph_vector_size(&res);i++){
|
||||
rb_ary_push(pagerank,rb_float_new(VECTOR(res)[i]));
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ VALUE cIGraph_modularity(VALUE self, VALUE groups){
|
|||
}
|
||||
}
|
||||
|
||||
igraph_modularity(graph,&membership,&value);
|
||||
igraph_modularity(graph,&membership,&value,NULL);
|
||||
|
||||
igraph_vector_destroy(&membership);
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ VALUE cIGraph_modularity(VALUE self, VALUE groups){
|
|||
*
|
||||
*/
|
||||
|
||||
VALUE cIGraph_community_to_membership(VALUE self, VALUE merge, VALUE steps){
|
||||
VALUE cIGraph_community_to_membership(VALUE self, VALUE merge, VALUE steps, VALUE nodes){
|
||||
|
||||
igraph_t *graph;
|
||||
igraph_matrix_t *merges;
|
||||
|
|
@ -69,7 +69,7 @@ VALUE cIGraph_community_to_membership(VALUE self, VALUE merge, VALUE steps){
|
|||
|
||||
igraph_vector_init(&membership,0);
|
||||
|
||||
igraph_community_to_membership(graph,merges,NUM2INT(steps),&membership,NULL);
|
||||
igraph_community_to_membership(merges,NUM2INT(nodes),NUM2INT(steps),&membership,NULL);
|
||||
|
||||
max_groupid = 0;
|
||||
for(i=0;i<igraph_vector_size(&membership);i++){
|
||||
|
|
@ -253,6 +253,9 @@ VALUE cIGraph_community_leading_eigenvector(VALUE self, VALUE steps){
|
|||
|
||||
igraph_vector_t membership;
|
||||
igraph_matrix_t *merges = malloc(sizeof(igraph_matrix_t));
|
||||
|
||||
igraph_arpack_options_t arpack_opt;
|
||||
igraph_arpack_options_init(&arpack_opt);
|
||||
|
||||
int i,groupid,max_groupid;
|
||||
|
||||
|
|
@ -264,7 +267,7 @@ VALUE cIGraph_community_leading_eigenvector(VALUE self, VALUE steps){
|
|||
igraph_vector_init(&membership,0);
|
||||
|
||||
igraph_community_leading_eigenvector(graph,merges,&membership,
|
||||
NUM2INT(steps));
|
||||
NUM2INT(steps),&arpack_opt);
|
||||
|
||||
max_groupid = 0;
|
||||
for(i=0;i<igraph_vector_size(&membership);i++){
|
||||
|
|
@ -316,6 +319,9 @@ VALUE cIGraph_community_leading_eigenvector_naive(VALUE self, VALUE steps){
|
|||
igraph_vector_t membership;
|
||||
igraph_matrix_t *merges = malloc(sizeof(igraph_matrix_t));
|
||||
|
||||
igraph_arpack_options_t arpack_opt;
|
||||
igraph_arpack_options_init(&arpack_opt);
|
||||
|
||||
int i,groupid,max_groupid;
|
||||
|
||||
VALUE groups, group, res;
|
||||
|
|
@ -326,7 +332,7 @@ VALUE cIGraph_community_leading_eigenvector_naive(VALUE self, VALUE steps){
|
|||
igraph_vector_init(&membership,0);
|
||||
|
||||
igraph_community_leading_eigenvector_naive(graph,merges,&membership,
|
||||
NUM2INT(steps));
|
||||
NUM2INT(steps), &arpack_opt);
|
||||
|
||||
max_groupid = 0;
|
||||
for(i=0;i<igraph_vector_size(&membership);i++){
|
||||
|
|
@ -380,6 +386,9 @@ VALUE cIGraph_community_leading_eigenvector_step(VALUE self, VALUE membership, V
|
|||
|
||||
int i,j,groupid,max_groupid,vid;
|
||||
|
||||
igraph_arpack_options_t arpack_opt;
|
||||
igraph_arpack_options_init(&arpack_opt);
|
||||
|
||||
VALUE groups, group, res, eigenvector_a, obj;
|
||||
|
||||
Data_Get_Struct(self, igraph_t, graph);
|
||||
|
|
@ -402,7 +411,7 @@ VALUE cIGraph_community_leading_eigenvector_step(VALUE self, VALUE membership, V
|
|||
|
||||
igraph_community_leading_eigenvector_step(graph,&membership_vec,
|
||||
NUM2INT(community),
|
||||
&split,&eigenvector,&eigenvalue);
|
||||
&split,&eigenvector,&eigenvalue,&arpack_opt,NULL);
|
||||
|
||||
max_groupid = 0;
|
||||
for(i=0;i<igraph_vector_size(&membership_vec);i++){
|
||||
|
|
@ -634,7 +643,7 @@ VALUE cIGraph_community_fastgreedy(VALUE self){
|
|||
igraph_matrix_init(merges,0,0);
|
||||
igraph_vector_init(&modularity,0);
|
||||
|
||||
igraph_community_fastgreedy(graph,
|
||||
igraph_community_fastgreedy(graph,NULL,
|
||||
merges,&modularity);
|
||||
|
||||
modularity_a = rb_ary_new();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ VALUE cIGraph_grg_game(VALUE self, VALUE nodes, VALUE radius, VALUE torus){
|
|||
|
||||
igraph_destroy(graph);
|
||||
igraph_grg_game(graph, NUM2INT(nodes), NUM2DBL(radius),
|
||||
torus == Qtrue ? 1: 0);
|
||||
torus == Qtrue ? 1: 0, NULL, NULL);
|
||||
|
||||
return new_graph;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ VALUE cIGraph_isomorphic(VALUE self, VALUE g){
|
|||
Data_Get_Struct(self, igraph_t, graph);
|
||||
Data_Get_Struct(g, igraph_t, graph2);
|
||||
|
||||
IGRAPH_CHECK(igraph_isomorphic(graph,graph2,&res));
|
||||
igraph_isomorphic(graph,graph2,&res);
|
||||
|
||||
return res == 0 ? Qfalse : Qtrue;
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ VALUE cIGraph_isomorphic_vf2(VALUE self, VALUE g){
|
|||
Data_Get_Struct(self, igraph_t, graph);
|
||||
Data_Get_Struct(g, igraph_t, graph2);
|
||||
|
||||
IGRAPH_CHECK(igraph_isomorphic_vf2(graph,graph2,&res));
|
||||
IGRAPH_CHECK(igraph_isomorphic_vf2(graph,graph2,&res,NULL,NULL));
|
||||
|
||||
return res == 0 ? Qfalse : Qtrue;
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ VALUE cIGraph_isomorphic_vf2(VALUE self, VALUE g){
|
|||
*/
|
||||
VALUE cIGraph_isoclass(VALUE self){
|
||||
|
||||
int res = 0;
|
||||
igraph_integer_t res = 0;
|
||||
igraph_t *graph;
|
||||
|
||||
Data_Get_Struct(self, igraph_t, graph);
|
||||
|
|
@ -92,7 +92,7 @@ VALUE cIGraph_isoclass(VALUE self){
|
|||
*/
|
||||
VALUE cIGraph_isoclass_subgraph(VALUE self, VALUE vs){
|
||||
|
||||
int res = 0;
|
||||
igraph_integer_t res = 0;
|
||||
igraph_t *graph;
|
||||
igraph_vector_t vidv;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ VALUE cIGraph_layout_fruchterman_reingold(VALUE self,
|
|||
NUM2DBL(area),
|
||||
NUM2DBL(coolexp),
|
||||
NUM2DBL(repulserad),
|
||||
use_seed == Qtrue ? 1: 0);
|
||||
use_seed == Qtrue ? 1: 0, NULL);
|
||||
|
||||
return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ VALUE cIGraph_layout_kamada_kawai(VALUE self,
|
|||
NUM2DBL(sigma),
|
||||
NUM2DBL(initemp),
|
||||
NUM2DBL(coolexp),
|
||||
NUM2DBL(kkconst));
|
||||
NUM2DBL(kkconst),0);
|
||||
|
||||
return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ VALUE cIGraph_layout_fruchterman_reingold_3d(VALUE self,
|
|||
NUM2DBL(volume),
|
||||
NUM2DBL(coolexp),
|
||||
NUM2DBL(repulserad),
|
||||
1);
|
||||
1, NULL);
|
||||
|
||||
return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ VALUE cIGraph_layout_kamada_kawai_3d(VALUE self,
|
|||
NUM2DBL(sigma),
|
||||
NUM2DBL(initemp),
|
||||
NUM2DBL(coolexp),
|
||||
NUM2DBL(kkconst));
|
||||
NUM2DBL(kkconst),0);
|
||||
|
||||
return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
|
||||
|
||||
|
|
|
|||
|
|
@ -191,11 +191,11 @@ VALUE cIGraph_matrix_max(VALUE self){
|
|||
}
|
||||
|
||||
/* call-seq:
|
||||
* matrix * matrix -> IGraphMatrix
|
||||
* matrix * num -> IGraphMatrix
|
||||
*
|
||||
* Multiples two IGraphMatrix objects together
|
||||
*/
|
||||
VALUE cIGraph_matrix_multiply(VALUE self, VALUE x){
|
||||
VALUE cIGraph_matrix_scale(VALUE self, VALUE x){
|
||||
|
||||
igraph_matrix_t *m;
|
||||
igraph_matrix_t *n = malloc(sizeof(igraph_matrix_t));
|
||||
|
|
@ -204,7 +204,7 @@ VALUE cIGraph_matrix_multiply(VALUE self, VALUE x){
|
|||
Data_Get_Struct(self, igraph_matrix_t, m);
|
||||
|
||||
igraph_matrix_copy(n,m);
|
||||
igraph_matrix_multiply(n, NUM2DBL(x));
|
||||
igraph_matrix_scale(n, NUM2DBL(x));
|
||||
|
||||
nobj = Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, n);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TestGraph < Test::Unit::TestCase
|
|||
end
|
||||
def test_pagerank
|
||||
g = IGraph.new(['A','B','C','D','E','B','F','B'],true)
|
||||
assert_equal 67, (g.pagerank(['B'],true,100,0.01,0.8)[0] * 100).to_i
|
||||
assert_equal 48, (g.pagerank(['B'],true,100,0.01,0.8)[0] * 100).to_i
|
||||
end
|
||||
def test_constraint
|
||||
g = IGraph.new(['A','B','C','D'],true)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class TestGraph < Test::Unit::TestCase
|
|||
end
|
||||
def test_largest_cliques
|
||||
g = IGraph.new(['A','B','C','D','A','E','B','E'],false)
|
||||
assert_equal [['A','B','E','B','E']], g.largest_cliques()
|
||||
assert_equal [['A','B','E']], g.largest_cliques()
|
||||
end
|
||||
def test_maximal_cliques
|
||||
g = IGraph.new(['A','B','C','D','A','E','B','E'],false)
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@ class TestGraph < Test::Unit::TestCase
|
|||
g.community_leading_eigenvector_step([['A','B','C','D','E','F']],0)
|
||||
assert_equal [['A','B','C'],['D','E','F']], groups
|
||||
assert split
|
||||
assert_in_delta 0.433, eigenvec[0], 0.001
|
||||
assert_in_delta 2.100, eigenval, 0.001
|
||||
assert_in_delta 0.433, eigenvec[0], 0.02
|
||||
assert_in_delta 1.730, eigenval, 0.02
|
||||
|
||||
end
|
||||
|
||||
def test_random_walk
|
||||
g = IGraph.new(['A','B','B','C','A','C','C','D','D','E','E','F','D','F'],false)
|
||||
merges,modularity = g.community_walktrap([],10)
|
||||
groups = g.community_to_membership(merges,4)
|
||||
groups = g.community_to_membership(merges,4,6)
|
||||
assert_equal [['A','B','C'],['D','E','F']], groups.sort
|
||||
assert_in_delta 0.19, modularity[3], 0.1
|
||||
end
|
||||
|
|
@ -48,14 +48,14 @@ class TestGraph < Test::Unit::TestCase
|
|||
|
||||
g = IGraph.new(['A','B','B','C','A','C','C','D','D','E','E','F','D','F'],false)
|
||||
merges,result,edge_betw,bridges = g.community_edge_betweenness(false)
|
||||
groups = g.community_to_membership(merges,4)
|
||||
groups = g.community_to_membership(merges,4,6)
|
||||
assert_equal [['A','B','C'],['D','E','F']], groups.sort
|
||||
assert_equal 3, result[0]
|
||||
assert_equal 9, edge_betw[0]
|
||||
assert_equal 7, bridges[0]
|
||||
|
||||
merges,bridges = g.community_eb_get_merges(result)
|
||||
groups = g.community_to_membership(merges,4)
|
||||
groups = g.community_to_membership(merges,4,6)
|
||||
assert_equal [['A','B','C'],['D','E','F']], groups.sort
|
||||
assert_equal 7, bridges[0]
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class TestGraph < Test::Unit::TestCase
|
|||
def test_fastgreedy
|
||||
g = IGraph.new(['A','B','B','C','A','C','C','D','D','E','E','F','D','F'],false)
|
||||
merges,mod = g.community_fastgreedy
|
||||
groups = g.community_to_membership(merges,4)
|
||||
groups = g.community_to_membership(merges,4,6)
|
||||
assert_equal [['A','B','C'],['D','E','F']], groups.sort
|
||||
assert_in_delta 0.19, mod[3], 0.1
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue