igraph 0.9.1 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'hoe'
3
3
  $LOAD_PATH.unshift("./ext")
4
4
 
5
5
  class IGraph
6
- VERSION = "0.9.1"
6
+ VERSION = "0.9.5"
7
7
  end
8
8
 
9
9
  begin
@@ -14,7 +14,7 @@ end
14
14
  hoe = Hoe.new("igraph",IGraph::VERSION) do |p|
15
15
 
16
16
  p.author = "Alex Gutteridge"
17
- p.email = "alexg@kuicr.kyoto-u.ac.jp"
17
+ p.email = "ag357@cam.ac.uk"
18
18
  p.url = "http://igraph.rubyforge.org/"
19
19
 
20
20
  p.description = p.paragraphs_of("README.txt",1..3)[0]
@@ -546,7 +546,7 @@ void Init_igraph(){
546
546
  rb_include_module(cIGraph, cIGraph_community);
547
547
 
548
548
  rb_define_method(cIGraph_community, "modularity", cIGraph_modularity, 1); /* in cIGraph_community.c */
549
- rb_define_method(cIGraph_community, "community_to_membership", cIGraph_community_to_membership, 2); /* in cIGraph_community.c */
549
+ rb_define_method(cIGraph_community, "community_to_membership", cIGraph_community_to_membership, 3); /* in cIGraph_community.c */
550
550
  rb_define_method(cIGraph_community, "community_spinglass", cIGraph_community_spinglass, 8); /* in cIGraph_community.c */
551
551
  rb_define_method(cIGraph_community, "community_spinglass_single", cIGraph_community_spinglass_single, 5); /* in cIGraph_community.c */
552
552
  rb_define_method(cIGraph_community, "community_leading_eigenvector", cIGraph_community_leading_eigenvector, 1); /* in cIGraph_community.c */
@@ -556,7 +556,7 @@ void Init_igraph(){
556
556
  rb_define_method(cIGraph_community, "community_eb_get_merges", cIGraph_community_eb_get_merges, 1); /* in cIGraph_community.c */
557
557
  rb_define_method(cIGraph_community, "community_fastgreedy", cIGraph_community_fastgreedy, 0); /* in cIGraph_community.c */
558
558
 
559
- rb_define_const(cIGraph, "VERSION", rb_str_new2("0.9.1"));
559
+ rb_define_const(cIGraph, "VERSION", rb_str_new2("0.9.5"));
560
560
 
561
561
  rb_define_const(cIGraph, "EDGEORDER_ID", INT2NUM(1));
562
562
  rb_define_const(cIGraph, "EDGEORDER_FROM", INT2NUM(2));
@@ -624,7 +624,7 @@ void Init_igraph(){
624
624
  rb_define_method(cIGraphMatrix, "ncol", cIGraph_matrix_ncol, 0); /* in cIGraph_matrix.c */
625
625
  rb_define_method(cIGraphMatrix, "max", cIGraph_matrix_max, 0); /* in cIGraph_matrix.c */
626
626
 
627
- rb_define_method(cIGraphMatrix, "*", cIGraph_matrix_multiply, 1); /* in cIGraph_matrix.c */
627
+ rb_define_method(cIGraphMatrix, "*", cIGraph_matrix_scale, 1); /* in cIGraph_matrix.c */
628
628
 
629
629
  rb_define_method(cIGraphMatrix, "to_a", cIGraph_matrix_toa, 0); /* in cIGraph_matrix.c */
630
630
 
@@ -287,7 +287,7 @@ VALUE cIGraph_cohesion(VALUE self);
287
287
  //Community
288
288
  VALUE cIGraph_modularity (VALUE self, VALUE groups);
289
289
  VALUE cIGraph_community_to_membership (VALUE self, VALUE merge,
290
- VALUE steps);
290
+ VALUE steps, VALUE nodes);
291
291
  VALUE cIGraph_community_spinglass (VALUE self, VALUE weights,
292
292
  VALUE spins,
293
293
  VALUE parupdate,
@@ -390,7 +390,7 @@ VALUE cIGraph_matrix_nrow(VALUE self);
390
390
  VALUE cIGraph_matrix_ncol(VALUE self);
391
391
  VALUE cIGraph_matrix_max (VALUE self);
392
392
 
393
- VALUE cIGraph_matrix_multiply(VALUE self, VALUE x);
393
+ VALUE cIGraph_matrix_scale(VALUE self, VALUE x);
394
394
 
395
395
  VALUE cIGraph_matrix_toa(VALUE self);
396
396
 
@@ -161,8 +161,8 @@ VALUE cIGraph_pagerank(VALUE self, VALUE vs, VALUE directed, VALUE niter, VALUE
161
161
  //create vertex selector from the vecotr of ids
162
162
  igraph_vs_vector(&vids,&vidv);
163
163
 
164
- igraph_pagerank(graph,&res,vids,dir,
165
- NUM2INT(niter),NUM2DBL(eps),NUM2DBL(damping));
164
+ igraph_pagerank_old(graph,&res,vids,dir,
165
+ NUM2INT(niter),NUM2DBL(eps),NUM2DBL(damping),0);
166
166
 
167
167
  for(i=0;i<igraph_vector_size(&res);i++){
168
168
  rb_ary_push(pagerank,rb_float_new(VECTOR(res)[i]));
@@ -34,7 +34,7 @@ VALUE cIGraph_modularity(VALUE self, VALUE groups){
34
34
  }
35
35
  }
36
36
 
37
- igraph_modularity(graph,&membership,&value);
37
+ igraph_modularity(graph,&membership,&value,NULL);
38
38
 
39
39
  igraph_vector_destroy(&membership);
40
40
 
@@ -53,7 +53,7 @@ VALUE cIGraph_modularity(VALUE self, VALUE groups){
53
53
  *
54
54
  */
55
55
 
56
- VALUE cIGraph_community_to_membership(VALUE self, VALUE merge, VALUE steps){
56
+ VALUE cIGraph_community_to_membership(VALUE self, VALUE merge, VALUE steps, VALUE nodes){
57
57
 
58
58
  igraph_t *graph;
59
59
  igraph_matrix_t *merges;
@@ -69,7 +69,7 @@ VALUE cIGraph_community_to_membership(VALUE self, VALUE merge, VALUE steps){
69
69
 
70
70
  igraph_vector_init(&membership,0);
71
71
 
72
- igraph_community_to_membership(graph,merges,NUM2INT(steps),&membership,NULL);
72
+ igraph_community_to_membership(merges,NUM2INT(nodes),NUM2INT(steps),&membership,NULL);
73
73
 
74
74
  max_groupid = 0;
75
75
  for(i=0;i<igraph_vector_size(&membership);i++){
@@ -253,6 +253,9 @@ VALUE cIGraph_community_leading_eigenvector(VALUE self, VALUE steps){
253
253
 
254
254
  igraph_vector_t membership;
255
255
  igraph_matrix_t *merges = malloc(sizeof(igraph_matrix_t));
256
+
257
+ igraph_arpack_options_t arpack_opt;
258
+ igraph_arpack_options_init(&arpack_opt);
256
259
 
257
260
  int i,groupid,max_groupid;
258
261
 
@@ -264,7 +267,7 @@ VALUE cIGraph_community_leading_eigenvector(VALUE self, VALUE steps){
264
267
  igraph_vector_init(&membership,0);
265
268
 
266
269
  igraph_community_leading_eigenvector(graph,merges,&membership,
267
- NUM2INT(steps));
270
+ NUM2INT(steps),&arpack_opt);
268
271
 
269
272
  max_groupid = 0;
270
273
  for(i=0;i<igraph_vector_size(&membership);i++){
@@ -316,6 +319,9 @@ VALUE cIGraph_community_leading_eigenvector_naive(VALUE self, VALUE steps){
316
319
  igraph_vector_t membership;
317
320
  igraph_matrix_t *merges = malloc(sizeof(igraph_matrix_t));
318
321
 
322
+ igraph_arpack_options_t arpack_opt;
323
+ igraph_arpack_options_init(&arpack_opt);
324
+
319
325
  int i,groupid,max_groupid;
320
326
 
321
327
  VALUE groups, group, res;
@@ -326,7 +332,7 @@ VALUE cIGraph_community_leading_eigenvector_naive(VALUE self, VALUE steps){
326
332
  igraph_vector_init(&membership,0);
327
333
 
328
334
  igraph_community_leading_eigenvector_naive(graph,merges,&membership,
329
- NUM2INT(steps));
335
+ NUM2INT(steps), &arpack_opt);
330
336
 
331
337
  max_groupid = 0;
332
338
  for(i=0;i<igraph_vector_size(&membership);i++){
@@ -380,6 +386,9 @@ VALUE cIGraph_community_leading_eigenvector_step(VALUE self, VALUE membership, V
380
386
 
381
387
  int i,j,groupid,max_groupid,vid;
382
388
 
389
+ igraph_arpack_options_t arpack_opt;
390
+ igraph_arpack_options_init(&arpack_opt);
391
+
383
392
  VALUE groups, group, res, eigenvector_a, obj;
384
393
 
385
394
  Data_Get_Struct(self, igraph_t, graph);
@@ -402,7 +411,7 @@ VALUE cIGraph_community_leading_eigenvector_step(VALUE self, VALUE membership, V
402
411
 
403
412
  igraph_community_leading_eigenvector_step(graph,&membership_vec,
404
413
  NUM2INT(community),
405
- &split,&eigenvector,&eigenvalue);
414
+ &split,&eigenvector,&eigenvalue,&arpack_opt,NULL);
406
415
 
407
416
  max_groupid = 0;
408
417
  for(i=0;i<igraph_vector_size(&membership_vec);i++){
@@ -634,7 +643,7 @@ VALUE cIGraph_community_fastgreedy(VALUE self){
634
643
  igraph_matrix_init(merges,0,0);
635
644
  igraph_vector_init(&modularity,0);
636
645
 
637
- igraph_community_fastgreedy(graph,
646
+ igraph_community_fastgreedy(graph,NULL,
638
647
  merges,&modularity);
639
648
 
640
649
  modularity_a = rb_ary_new();
@@ -26,7 +26,7 @@ VALUE cIGraph_grg_game(VALUE self, VALUE nodes, VALUE radius, VALUE torus){
26
26
 
27
27
  igraph_destroy(graph);
28
28
  igraph_grg_game(graph, NUM2INT(nodes), NUM2DBL(radius),
29
- torus == Qtrue ? 1: 0);
29
+ torus == Qtrue ? 1: 0, NULL, NULL);
30
30
 
31
31
  return new_graph;
32
32
 
@@ -21,7 +21,7 @@ VALUE cIGraph_isomorphic(VALUE self, VALUE g){
21
21
  Data_Get_Struct(self, igraph_t, graph);
22
22
  Data_Get_Struct(g, igraph_t, graph2);
23
23
 
24
- IGRAPH_CHECK(igraph_isomorphic(graph,graph2,&res));
24
+ igraph_isomorphic(graph,graph2,&res);
25
25
 
26
26
  return res == 0 ? Qfalse : Qtrue;
27
27
 
@@ -46,7 +46,7 @@ VALUE cIGraph_isomorphic_vf2(VALUE self, VALUE g){
46
46
  Data_Get_Struct(self, igraph_t, graph);
47
47
  Data_Get_Struct(g, igraph_t, graph2);
48
48
 
49
- IGRAPH_CHECK(igraph_isomorphic_vf2(graph,graph2,&res));
49
+ IGRAPH_CHECK(igraph_isomorphic_vf2(graph,graph2,&res,NULL,NULL));
50
50
 
51
51
  return res == 0 ? Qfalse : Qtrue;
52
52
 
@@ -72,7 +72,7 @@ VALUE cIGraph_isomorphic_vf2(VALUE self, VALUE g){
72
72
  */
73
73
  VALUE cIGraph_isoclass(VALUE self){
74
74
 
75
- int res = 0;
75
+ igraph_integer_t res = 0;
76
76
  igraph_t *graph;
77
77
 
78
78
  Data_Get_Struct(self, igraph_t, graph);
@@ -92,7 +92,7 @@ VALUE cIGraph_isoclass(VALUE self){
92
92
  */
93
93
  VALUE cIGraph_isoclass_subgraph(VALUE self, VALUE vs){
94
94
 
95
- int res = 0;
95
+ igraph_integer_t res = 0;
96
96
  igraph_t *graph;
97
97
  igraph_vector_t vidv;
98
98
 
@@ -70,7 +70,7 @@ VALUE cIGraph_layout_fruchterman_reingold(VALUE self,
70
70
  NUM2DBL(area),
71
71
  NUM2DBL(coolexp),
72
72
  NUM2DBL(repulserad),
73
- use_seed == Qtrue ? 1: 0);
73
+ use_seed == Qtrue ? 1: 0, NULL);
74
74
 
75
75
  return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
76
76
 
@@ -103,7 +103,7 @@ VALUE cIGraph_layout_kamada_kawai(VALUE self,
103
103
  NUM2DBL(sigma),
104
104
  NUM2DBL(initemp),
105
105
  NUM2DBL(coolexp),
106
- NUM2DBL(kkconst));
106
+ NUM2DBL(kkconst),0);
107
107
 
108
108
  return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
109
109
 
@@ -79,7 +79,7 @@ VALUE cIGraph_layout_fruchterman_reingold_3d(VALUE self,
79
79
  NUM2DBL(volume),
80
80
  NUM2DBL(coolexp),
81
81
  NUM2DBL(repulserad),
82
- 1);
82
+ 1, NULL);
83
83
 
84
84
  return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
85
85
 
@@ -112,7 +112,7 @@ VALUE cIGraph_layout_kamada_kawai_3d(VALUE self,
112
112
  NUM2DBL(sigma),
113
113
  NUM2DBL(initemp),
114
114
  NUM2DBL(coolexp),
115
- NUM2DBL(kkconst));
115
+ NUM2DBL(kkconst),0);
116
116
 
117
117
  return Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, res);
118
118
 
@@ -191,11 +191,11 @@ VALUE cIGraph_matrix_max(VALUE self){
191
191
  }
192
192
 
193
193
  /* call-seq:
194
- * matrix * matrix -> IGraphMatrix
194
+ * matrix * num -> IGraphMatrix
195
195
  *
196
196
  * Multiples two IGraphMatrix objects together
197
197
  */
198
- VALUE cIGraph_matrix_multiply(VALUE self, VALUE x){
198
+ VALUE cIGraph_matrix_scale(VALUE self, VALUE x){
199
199
 
200
200
  igraph_matrix_t *m;
201
201
  igraph_matrix_t *n = malloc(sizeof(igraph_matrix_t));
@@ -204,7 +204,7 @@ VALUE cIGraph_matrix_multiply(VALUE self, VALUE x){
204
204
  Data_Get_Struct(self, igraph_matrix_t, m);
205
205
 
206
206
  igraph_matrix_copy(n,m);
207
- igraph_matrix_multiply(n, NUM2DBL(x));
207
+ igraph_matrix_scale(n, NUM2DBL(x));
208
208
 
209
209
  nobj = Data_Wrap_Struct(cIGraphMatrix, 0, cIGraph_matrix_free, n);
210
210
 
File without changes
@@ -16,7 +16,7 @@ class TestGraph < Test::Unit::TestCase
16
16
  end
17
17
  def test_pagerank
18
18
  g = IGraph.new(['A','B','C','D','E','B','F','B'],true)
19
- assert_equal 67, (g.pagerank(['B'],true,100,0.01,0.8)[0] * 100).to_i
19
+ assert_equal 48, (g.pagerank(['B'],true,100,0.01,0.8)[0] * 100).to_i
20
20
  end
21
21
  def test_constraint
22
22
  g = IGraph.new(['A','B','C','D'],true)
@@ -8,7 +8,7 @@ class TestGraph < Test::Unit::TestCase
8
8
  end
9
9
  def test_largest_cliques
10
10
  g = IGraph.new(['A','B','C','D','A','E','B','E'],false)
11
- assert_equal [['A','B','E','B','E']], g.largest_cliques()
11
+ assert_equal [['A','B','E']], g.largest_cliques()
12
12
  end
13
13
  def test_maximal_cliques
14
14
  g = IGraph.new(['A','B','C','D','A','E','B','E'],false)
@@ -31,15 +31,15 @@ class TestGraph < Test::Unit::TestCase
31
31
  g.community_leading_eigenvector_step([['A','B','C','D','E','F']],0)
32
32
  assert_equal [['A','B','C'],['D','E','F']], groups
33
33
  assert split
34
- assert_in_delta 0.433, eigenvec[0], 0.001
35
- assert_in_delta 2.100, eigenval, 0.001
34
+ assert_in_delta 0.433, eigenvec[0], 0.02
35
+ assert_in_delta 1.730, eigenval, 0.02
36
36
 
37
37
  end
38
38
 
39
39
  def test_random_walk
40
40
  g = IGraph.new(['A','B','B','C','A','C','C','D','D','E','E','F','D','F'],false)
41
41
  merges,modularity = g.community_walktrap([],10)
42
- groups = g.community_to_membership(merges,4)
42
+ groups = g.community_to_membership(merges,4,6)
43
43
  assert_equal [['A','B','C'],['D','E','F']], groups.sort
44
44
  assert_in_delta 0.19, modularity[3], 0.1
45
45
  end
@@ -48,14 +48,14 @@ class TestGraph < Test::Unit::TestCase
48
48
 
49
49
  g = IGraph.new(['A','B','B','C','A','C','C','D','D','E','E','F','D','F'],false)
50
50
  merges,result,edge_betw,bridges = g.community_edge_betweenness(false)
51
- groups = g.community_to_membership(merges,4)
51
+ groups = g.community_to_membership(merges,4,6)
52
52
  assert_equal [['A','B','C'],['D','E','F']], groups.sort
53
53
  assert_equal 3, result[0]
54
54
  assert_equal 9, edge_betw[0]
55
55
  assert_equal 7, bridges[0]
56
56
 
57
57
  merges,bridges = g.community_eb_get_merges(result)
58
- groups = g.community_to_membership(merges,4)
58
+ groups = g.community_to_membership(merges,4,6)
59
59
  assert_equal [['A','B','C'],['D','E','F']], groups.sort
60
60
  assert_equal 7, bridges[0]
61
61
 
@@ -64,7 +64,7 @@ class TestGraph < Test::Unit::TestCase
64
64
  def test_fastgreedy
65
65
  g = IGraph.new(['A','B','B','C','A','C','C','D','D','E','E','F','D','F'],false)
66
66
  merges,mod = g.community_fastgreedy
67
- groups = g.community_to_membership(merges,4)
67
+ groups = g.community_to_membership(merges,4,6)
68
68
  assert_equal [['A','B','C'],['D','E','F']], groups.sort
69
69
  assert_in_delta 0.19, mod[3], 0.1
70
70
  end
@@ -167,7 +167,11 @@ class TestGraph < Test::Unit::TestCase
167
167
  return
168
168
  end
169
169
  g = nil
170
+ err = StringIO.open('','w')
171
+ $stderr = err
170
172
  g = IGraph::FileRead.read_graph_graphml(StringIO.new(Graphml),0)
173
+ assert_equal "warning: unknown attribute key in GraphML file, ignoring attribute\n", err.string.sub(/.*?:\d+: /,'')
174
+ $stderr = STDERR
171
175
  assert_instance_of IGraph, g
172
176
  assert_equal '2006-11-12', g.attributes['date']
173
177
  h = g.dup
File without changes
metadata CHANGED
@@ -1,33 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: igraph
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.9.1
7
- date: 2007-11-20 00:00:00 +09:00
8
- summary: IGraph is a Ruby extension for interfacing with the C igraph library (http://cneurocvs.rmki.kfki.hu/igraph/). igraph is a library for creating and manipulating graphs with a particular emphasis on network analysis functions.
9
- require_paths:
10
- - test
11
- email: alexg@kuicr.kyoto-u.ac.jp
12
- homepage: http://igraph.rubyforge.org/
13
- rubyforge_project: igraph
14
- description: IGraph is a Ruby extension for interfacing with the C igraph library (http://cneurocvs.rmki.kfki.hu/igraph/). igraph is a library for creating and manipulating graphs with a particular emphasis on network analysis functions.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.9.5
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Alex Gutteridge
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-04-25 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: IGraph is a Ruby extension for interfacing with the C igraph library (http://cneurocvs.rmki.kfki.hu/igraph/). igraph is a library for creating and manipulating graphs with a particular emphasis on network analysis functions.
17
+ email: ag357@cam.ac.uk
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/extconf.rb
22
+ extra_rdoc_files:
23
+ - README.txt
24
+ - History.txt
25
+ - License.txt
31
26
  files:
32
27
  - History.txt
33
28
  - License.txt
@@ -110,23 +105,35 @@ files:
110
105
  - test/tc_transitivity.rb
111
106
  - test/tc_vertex_neighbourhood.rb
112
107
  - test/test_all.rb
113
- test_files:
114
- - test/test_all.rb
108
+ has_rdoc: true
109
+ homepage: http://igraph.rubyforge.org/
110
+ post_install_message:
115
111
  rdoc_options:
116
112
  - --exclude
117
113
  - test/*
118
114
  - --main
119
115
  - README.txt
120
116
  - --inline-source
121
- extra_rdoc_files:
122
- - README.txt
123
- - History.txt
124
- - License.txt
125
- executables: []
126
-
127
- extensions:
128
- - ext/extconf.rb
117
+ require_paths:
118
+ - test
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ version:
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: "0"
130
+ version:
129
131
  requirements: []
130
132
 
131
- dependencies: []
132
-
133
+ rubyforge_project: igraph
134
+ rubygems_version: 1.1.0
135
+ signing_key:
136
+ specification_version: 2
137
+ summary: IGraph is a Ruby extension for interfacing with the C igraph library (http://cneurocvs.rmki.kfki.hu/igraph/). igraph is a library for creating and manipulating graphs with a particular emphasis on network analysis functions.
138
+ test_files:
139
+ - test/test_all.rb