igraph 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile.rb +1 -1
- data/ext/cIGraph.c +27 -2
- data/ext/cIGraph_file.c +3 -0
- data/test/tc_file_read_write.rb +84 -3
- data/test/test_all.rb +2 -0
- metadata +2 -2
data/Rakefile.rb
CHANGED
data/ext/cIGraph.c
CHANGED
@@ -164,6 +164,10 @@ VALUE cIGraph_initialize(int argc, VALUE *argv, VALUE self){
|
|
164
164
|
|
165
165
|
}
|
166
166
|
|
167
|
+
VALUE cIGraph_unavailable_method(int argc, VALUE *argv, VALUE self){
|
168
|
+
rb_raise(rb_eNoMethodError,"Method not available on OSX");
|
169
|
+
}
|
170
|
+
|
167
171
|
/* Interface to the iGraph[http://cneurocvs.rmki.kfki.hu/igraph/] library
|
168
172
|
* for graph and network computation.
|
169
173
|
*
|
@@ -453,6 +457,16 @@ void Init_igraph(){
|
|
453
457
|
cIGraph_fileread = rb_define_module_under(cIGraph, "FileRead");
|
454
458
|
rb_include_module(cIGraph, cIGraph_fileread);
|
455
459
|
|
460
|
+
#ifdef __APPLE__
|
461
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_edgelist", cIGraph_unavailable_method, -1);
|
462
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_graphml", cIGraph_unavailable_method, -1);
|
463
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_ncol", cIGraph_unavailable_method, -1);
|
464
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_lgl", cIGraph_unavailable_method, -1);
|
465
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_dimacs", cIGraph_unavailable_method, -1);
|
466
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_graphdb", cIGraph_unavailable_method, -1);
|
467
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_gml", cIGraph_unavailable_method, -1);
|
468
|
+
rb_define_singleton_method(cIGraph_fileread, "read_graph_pajek", cIGraph_unavailable_method, -1);
|
469
|
+
#else
|
456
470
|
rb_define_singleton_method(cIGraph_fileread, "read_graph_edgelist", cIGraph_read_graph_edgelist, 2); /* in cIGraph_file.c */
|
457
471
|
rb_define_singleton_method(cIGraph_fileread, "read_graph_graphml", cIGraph_read_graph_graphml, 2); /* in cIGraph_file.c */
|
458
472
|
rb_define_singleton_method(cIGraph_fileread, "read_graph_ncol", cIGraph_read_graph_ncol, 5); /* in cIGraph_file.c */
|
@@ -461,11 +475,21 @@ void Init_igraph(){
|
|
461
475
|
rb_define_singleton_method(cIGraph_fileread, "read_graph_graphdb", cIGraph_read_graph_graphdb, 2); /* in cIGraph_file.c */
|
462
476
|
rb_define_singleton_method(cIGraph_fileread, "read_graph_gml", cIGraph_read_graph_gml, 1); /* in cIGraph_file.c */
|
463
477
|
rb_define_singleton_method(cIGraph_fileread, "read_graph_pajek", cIGraph_read_graph_pajek, 2); /* in cIGraph_file.c */
|
464
|
-
|
478
|
+
#endif
|
479
|
+
|
465
480
|
/* Functions for writing graphs to files */
|
466
481
|
cIGraph_filewrite = rb_define_module_under(cIGraph, "FileWrite");
|
467
482
|
rb_include_module(cIGraph, cIGraph_filewrite);
|
468
483
|
|
484
|
+
#ifdef __APPLE__
|
485
|
+
rb_define_method(cIGraph_filewrite, "write_graph_edgelist", cIGraph_unavailable_method, -1);
|
486
|
+
rb_define_method(cIGraph_filewrite, "write_graph_graphml", cIGraph_unavailable_method, -1);
|
487
|
+
rb_define_method(cIGraph_filewrite, "write_graph_gml", cIGraph_unavailable_method, -1);
|
488
|
+
rb_define_method(cIGraph_filewrite, "write_graph_ncol", cIGraph_unavailable_method, -1);
|
489
|
+
rb_define_method(cIGraph_filewrite, "write_graph_lgl", cIGraph_unavailable_method, -1);
|
490
|
+
rb_define_method(cIGraph_filewrite, "write_graph_dimacs", cIGraph_unavailable_method, -1);
|
491
|
+
rb_define_method(cIGraph_filewrite, "write_graph_pajek", cIGraph_unavailable_method, -1);
|
492
|
+
#else
|
469
493
|
rb_define_method(cIGraph_filewrite, "write_graph_edgelist", cIGraph_write_graph_edgelist, 1); /* in cIGraph_file.c */
|
470
494
|
rb_define_method(cIGraph_filewrite, "write_graph_graphml", cIGraph_write_graph_graphml, 1); /* in cIGraph_file.c */
|
471
495
|
rb_define_method(cIGraph_filewrite, "write_graph_gml", cIGraph_write_graph_gml, 1); /* in cIGraph_file.c */
|
@@ -473,6 +497,7 @@ void Init_igraph(){
|
|
473
497
|
rb_define_method(cIGraph_filewrite, "write_graph_lgl", cIGraph_write_graph_lgl, 4); /* in cIGraph_file.c */
|
474
498
|
rb_define_method(cIGraph_filewrite, "write_graph_dimacs", cIGraph_write_graph_dimacs, 4); /* in cIGraph_file.c */
|
475
499
|
rb_define_method(cIGraph_filewrite, "write_graph_pajek", cIGraph_write_graph_pajek, 1); /* in cIGraph_file.c */
|
500
|
+
#endif
|
476
501
|
|
477
502
|
/* Graph layout functions */
|
478
503
|
cIGraph_layout = rb_define_module_under(cIGraph, "Layout");
|
@@ -531,7 +556,7 @@ void Init_igraph(){
|
|
531
556
|
rb_define_method(cIGraph_community, "community_eb_get_merges", cIGraph_community_eb_get_merges, 1); /* in cIGraph_community.c */
|
532
557
|
rb_define_method(cIGraph_community, "community_fastgreedy", cIGraph_community_fastgreedy, 0); /* in cIGraph_community.c */
|
533
558
|
|
534
|
-
rb_define_const(cIGraph, "VERSION", rb_str_new2("0.9.
|
559
|
+
rb_define_const(cIGraph, "VERSION", rb_str_new2("0.9.1"));
|
535
560
|
|
536
561
|
rb_define_const(cIGraph, "EDGEORDER_ID", INT2NUM(1));
|
537
562
|
rb_define_const(cIGraph, "EDGEORDER_FROM", INT2NUM(2));
|
data/ext/cIGraph_file.c
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
#include "ruby.h"
|
3
3
|
#include "cIGraph.h"
|
4
4
|
|
5
|
+
#ifdef __APPLE__
|
6
|
+
#else
|
5
7
|
/* call-seq:
|
6
8
|
* IGraph::FileRead.read_graph_edgelist(file,mode) -> IGraph
|
7
9
|
*
|
@@ -842,3 +844,4 @@ VALUE cIGraph_write_graph_pajek(VALUE self, VALUE file){
|
|
842
844
|
return e;
|
843
845
|
|
844
846
|
}
|
847
|
+
#endif
|
data/test/tc_file_read_write.rb
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'igraph'
|
3
3
|
require 'stringio'
|
4
|
+
require 'rbconfig'
|
5
|
+
include Config
|
4
6
|
|
5
7
|
class TestGraph < Test::Unit::TestCase
|
6
8
|
def test_edgelist_read
|
7
9
|
g = nil
|
10
|
+
if CONFIG['host'] =~ /apple/
|
11
|
+
assert_raises(NoMethodError){
|
12
|
+
IGraph::FileRead.read_graph_edgelist(StringIO.new("0 1 2 3"),true)
|
13
|
+
}
|
14
|
+
return
|
15
|
+
end
|
8
16
|
assert_nothing_raised{
|
9
17
|
g = IGraph::FileRead.read_graph_edgelist(StringIO.new("0 1 2 3"),true)
|
10
18
|
}
|
@@ -16,6 +24,12 @@ class TestGraph < Test::Unit::TestCase
|
|
16
24
|
def test_edgelist_write
|
17
25
|
g = IGraph.new([0,1,2,3])
|
18
26
|
s = StringIO.new("")
|
27
|
+
if CONFIG['host'] =~ /apple/
|
28
|
+
assert_raises(NoMethodError){
|
29
|
+
g.write_graph_edgelist(s)
|
30
|
+
}
|
31
|
+
return
|
32
|
+
end
|
19
33
|
str = g.write_graph_edgelist(s)
|
20
34
|
s.rewind
|
21
35
|
assert_equal "0 1\n2 3\n", s.read
|
@@ -23,9 +37,16 @@ class TestGraph < Test::Unit::TestCase
|
|
23
37
|
|
24
38
|
def test_ncol_read
|
25
39
|
g = nil
|
40
|
+
if CONFIG['host'] =~ /apple/
|
41
|
+
assert_raises(NoMethodError){
|
42
|
+
IGraph::FileRead.read_graph_ncol(StringIO.new("0 1\n2 3\n"),[],
|
43
|
+
false,false,false)
|
44
|
+
}
|
45
|
+
return
|
46
|
+
end
|
26
47
|
assert_nothing_raised{
|
27
48
|
g = IGraph::FileRead.read_graph_ncol(StringIO.new("0 1\n2 3\n"),[],
|
28
|
-
|
49
|
+
false,false,false)
|
29
50
|
}
|
30
51
|
assert_instance_of IGraph, g
|
31
52
|
assert_equal 4, g.vcount
|
@@ -33,7 +54,7 @@ class TestGraph < Test::Unit::TestCase
|
|
33
54
|
|
34
55
|
assert_nothing_raised{
|
35
56
|
g = IGraph::FileRead.read_graph_ncol(StringIO.new("A B\nC D\n"),[],
|
36
|
-
|
57
|
+
true,false,false)
|
37
58
|
}
|
38
59
|
assert_instance_of IGraph, g
|
39
60
|
assert_equal 4, g.vcount
|
@@ -52,6 +73,12 @@ class TestGraph < Test::Unit::TestCase
|
|
52
73
|
def test_ncol_write
|
53
74
|
g = IGraph.new(["A","B","C","D"],true,[1,2])
|
54
75
|
s = StringIO.new("")
|
76
|
+
if CONFIG['host'] =~ /apple/
|
77
|
+
assert_raises(NoMethodError){
|
78
|
+
g.write_graph_ncol(s,true,true)
|
79
|
+
}
|
80
|
+
return
|
81
|
+
end
|
55
82
|
str = g.write_graph_ncol(s,true,true)
|
56
83
|
s.rewind
|
57
84
|
assert_equal "A B 1.0\nC D 2.0\n", s.read
|
@@ -59,6 +86,12 @@ class TestGraph < Test::Unit::TestCase
|
|
59
86
|
|
60
87
|
def test_lgl_read
|
61
88
|
g = nil
|
89
|
+
if CONFIG['host'] =~ /apple/
|
90
|
+
assert_raises(NoMethodError){
|
91
|
+
IGraph::FileRead.read_graph_lgl(StringIO.new("#A\nB\n#C\nD\n"))
|
92
|
+
}
|
93
|
+
return
|
94
|
+
end
|
62
95
|
assert_nothing_raised{
|
63
96
|
g = IGraph::FileRead.read_graph_lgl(StringIO.new("#A\nB\n#C\nD\n"),
|
64
97
|
false,false)
|
@@ -80,15 +113,27 @@ class TestGraph < Test::Unit::TestCase
|
|
80
113
|
def test_lgl_write
|
81
114
|
g = IGraph.new(["A","B","C","D"],true,[1,2])
|
82
115
|
s = StringIO.new("")
|
116
|
+
if CONFIG['host'] =~ /apple/
|
117
|
+
assert_raises(NoMethodError){
|
118
|
+
g.write_graph_lgl(s,true,true,false)
|
119
|
+
}
|
120
|
+
return
|
121
|
+
end
|
83
122
|
str = g.write_graph_lgl(s,true,true,false)
|
84
123
|
s.rewind
|
85
124
|
assert_equal "# A\nB 1.0\n# C\nD 2.0\n", s.read
|
86
125
|
end
|
87
126
|
|
88
127
|
def test_dimacs_read
|
128
|
+
s = StringIO.new("c com\np min 4 2\nn 1 s\nn 2 t\na 1 2 1\na 3 4 2\n")
|
89
129
|
g = nil
|
130
|
+
if CONFIG['host'] =~ /apple/
|
131
|
+
assert_raises(NoMethodError){
|
132
|
+
IGraph::FileRead.read_graph_dimacs(s,false)
|
133
|
+
}
|
134
|
+
return
|
135
|
+
end
|
90
136
|
assert_nothing_raised{
|
91
|
-
s = StringIO.new("c com\np min 4 2\nn 1 s\nn 2 t\na 1 2 1\na 3 4 2\n")
|
92
137
|
g = IGraph::FileRead.read_graph_dimacs(s,
|
93
138
|
false)
|
94
139
|
}
|
@@ -103,12 +148,24 @@ class TestGraph < Test::Unit::TestCase
|
|
103
148
|
def test_dimacs_write
|
104
149
|
g = IGraph.new(["A","B","C","D"],true,[1,2])
|
105
150
|
s = StringIO.new("")
|
151
|
+
if CONFIG['host'] =~ /apple/
|
152
|
+
assert_raises(NoMethodError){
|
153
|
+
g.write_graph_dimacs(s,0,1,[1,2])
|
154
|
+
}
|
155
|
+
return
|
156
|
+
end
|
106
157
|
str = g.write_graph_dimacs(s,0,1,[1,2])
|
107
158
|
s.rewind
|
108
159
|
assert_equal "c created by igraph\np max 4 2\nn 1 s\nn 2 t\na 1 2 1\na 3 4 2\n", s.read
|
109
160
|
end
|
110
161
|
|
111
162
|
def test_graphml_read
|
163
|
+
if CONFIG['host'] =~ /apple/
|
164
|
+
assert_raises(NoMethodError){
|
165
|
+
IGraph::FileRead.read_graph_graphml(StringIO.new(Graphml),0)
|
166
|
+
}
|
167
|
+
return
|
168
|
+
end
|
112
169
|
g = nil
|
113
170
|
g = IGraph::FileRead.read_graph_graphml(StringIO.new(Graphml),0)
|
114
171
|
assert_instance_of IGraph, g
|
@@ -128,12 +185,24 @@ class TestGraph < Test::Unit::TestCase
|
|
128
185
|
{'eid'=>'e2'}])
|
129
186
|
g.attributes['date'] = 'Friday'
|
130
187
|
s = StringIO.new("")
|
188
|
+
if CONFIG['host'] =~ /apple/
|
189
|
+
assert_raises(NoMethodError){
|
190
|
+
g.write_graph_graphml(s)
|
191
|
+
}
|
192
|
+
return
|
193
|
+
end
|
131
194
|
str = g.write_graph_graphml(s)
|
132
195
|
s.rewind
|
133
196
|
assert_equal Graphml_out, s.read
|
134
197
|
end
|
135
198
|
|
136
199
|
def test_gml_read
|
200
|
+
if CONFIG['host'] =~ /apple/
|
201
|
+
assert_raises(NoMethodError){
|
202
|
+
IGraph::FileRead.read_graph_gml(StringIO.new(Gml))
|
203
|
+
}
|
204
|
+
return
|
205
|
+
end
|
137
206
|
g = IGraph::FileRead.read_graph_gml(StringIO.new(Gml))
|
138
207
|
assert_instance_of IGraph, g
|
139
208
|
end
|
@@ -148,6 +217,12 @@ class TestGraph < Test::Unit::TestCase
|
|
148
217
|
{'eid'=>'e2'}])
|
149
218
|
g.attributes['date'] = 'Friday'
|
150
219
|
s = StringIO.new("")
|
220
|
+
if CONFIG['host'] =~ /apple/
|
221
|
+
assert_raises(NoMethodError){
|
222
|
+
g.write_graph_gml(s)
|
223
|
+
}
|
224
|
+
return
|
225
|
+
end
|
151
226
|
str = g.write_graph_gml(s)
|
152
227
|
s.rewind
|
153
228
|
s = s.read
|
@@ -156,6 +231,12 @@ class TestGraph < Test::Unit::TestCase
|
|
156
231
|
end
|
157
232
|
|
158
233
|
def test_pajek_read_write
|
234
|
+
if CONFIG['host'] =~ /apple/
|
235
|
+
assert_raises(NoMethodError){
|
236
|
+
IGraph::FileRead.read_graph_pajek(StringIO.new(Pajek),0)
|
237
|
+
}
|
238
|
+
return
|
239
|
+
end
|
159
240
|
g = nil
|
160
241
|
g = IGraph::FileRead.read_graph_pajek(StringIO.new(Pajek),0)
|
161
242
|
assert_instance_of IGraph, g
|
data/test/test_all.rb
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: igraph
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 0.9.1
|
7
|
+
date: 2007-11-20 00:00:00 +09:00
|
8
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
9
|
require_paths:
|
10
10
|
- test
|