igraph 0.3.3 → 0.9.0
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/History.txt +5 -0
- data/Manifest.txt +12 -1
- data/README.txt +50 -10
- data/Rakefile.rb +1 -1
- data/ext/cIGraph.c +347 -110
- data/ext/cIGraph.h +98 -0
- data/ext/cIGraph_attribute_handler.c +23 -13
- data/ext/cIGraph_community.c +654 -0
- data/ext/cIGraph_connectivity.c +230 -0
- data/ext/cIGraph_file.c +634 -3
- data/ext/cIGraph_generators_deterministic.c +324 -0
- data/ext/cIGraph_generators_random.c +718 -0
- data/ext/cIGraph_layout.c +43 -0
- data/ext/cIGraph_layout3d.c +119 -0
- data/ext/cIGraph_min_cuts.c +195 -0
- data/ext/cIGraph_randomisation.c +57 -0
- data/ext/cIGraph_utility.c +2 -0
- data/test/tc_add_delete.rb +21 -0
- data/test/tc_community.rb +72 -0
- data/test/tc_connectivity.rb +22 -0
- data/test/tc_file_read_write.rb +193 -3
- data/test/tc_generators_deterministic.rb +61 -0
- data/test/tc_generators_random.rb +82 -8
- data/test/tc_isomorphic.rb +1 -1
- data/test/tc_layout.rb +10 -0
- data/test/tc_layout3d.rb +34 -0
- data/test/tc_mincuts.rb +20 -0
- data/test/tc_randomisation.rb +15 -0
- data/test/test_all.rb +6 -0
- metadata +15 -4
- data/test/test_draw.rb +0 -61
data/test/tc_isomorphic.rb
CHANGED
@@ -27,7 +27,7 @@ class TestGraph < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
def test_igraph_isoclass_create
|
29
29
|
g = IGraph.new([1,2,3,4],false)
|
30
|
-
h = IGraph.isoclass_create(4,g.isoclass,false)
|
30
|
+
h = IGraph::Generate.isoclass_create(4,g.isoclass,false)
|
31
31
|
assert_equal g.isoclass, h.isoclass
|
32
32
|
end
|
33
33
|
end
|
data/test/tc_layout.rb
CHANGED
@@ -58,4 +58,14 @@ class TestGraph < Test::Unit::TestCase
|
|
58
58
|
assert_equal g.vcount, l.nrow
|
59
59
|
assert_equal 2, l.ncol
|
60
60
|
end
|
61
|
+
def test_merge
|
62
|
+
g = IGraph.new([1,2,3,4],true)
|
63
|
+
l = g.layout_lgl(10,1,1,2,1,1,1)
|
64
|
+
h = IGraph.new([1,2,3,4],true)
|
65
|
+
m = h.layout_lgl(10,1,1,2,1,1,1)
|
66
|
+
f = IGraph::Layout.layout_merge_dla([g,h],[l,m])
|
67
|
+
assert_instance_of IGraphMatrix, f
|
68
|
+
assert_equal g.vcount + h.vcount, f.nrow
|
69
|
+
assert_equal 2, f.ncol
|
70
|
+
end
|
61
71
|
end
|
data/test/tc_layout3d.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'igraph'
|
3
|
+
|
4
|
+
class TestGraph < Test::Unit::TestCase
|
5
|
+
def test_random_3d
|
6
|
+
g = IGraph.new([1,2,3,4],true)
|
7
|
+
l = g.layout_random_3d
|
8
|
+
assert_instance_of IGraphMatrix, l
|
9
|
+
assert_equal g.vcount, l.nrow
|
10
|
+
assert_equal 3, l.ncol
|
11
|
+
end
|
12
|
+
def test_sphere
|
13
|
+
g = IGraph.new([1,2,3,4],true)
|
14
|
+
l = g.layout_sphere
|
15
|
+
assert_instance_of IGraphMatrix, l
|
16
|
+
assert_equal g.vcount, l.nrow
|
17
|
+
assert_equal 3, l.ncol
|
18
|
+
end
|
19
|
+
def test_fruchterman_reingold_3d
|
20
|
+
g = IGraph.new([1,2,3,4],true)
|
21
|
+
l = g.layout_fruchterman_reingold_3d(10,1,1,2,1)
|
22
|
+
assert_instance_of IGraphMatrix, l
|
23
|
+
assert_equal g.vcount, l.nrow
|
24
|
+
assert_equal 3, l.ncol
|
25
|
+
end
|
26
|
+
def test_kamada_kawai_3d
|
27
|
+
g = IGraph.new([1,2,3,4],true)
|
28
|
+
l = g.layout_kamada_kawai_3d(10,1,1,2,1)
|
29
|
+
assert_instance_of IGraphMatrix, l
|
30
|
+
assert_equal g.vcount, l.nrow
|
31
|
+
assert_equal 3, l.ncol
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/test/tc_mincuts.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'igraph'
|
3
|
+
|
4
|
+
class TestGraph < Test::Unit::TestCase
|
5
|
+
def test_maxflow_mincut
|
6
|
+
g = IGraph.new([1,2,2,3,3,4])
|
7
|
+
assert_equal 3, g.maxflow_value(1,4,[5,4,3])
|
8
|
+
assert_equal 3, g.st_mincut_value(1,4,[5,4,3])
|
9
|
+
end
|
10
|
+
def test_mincut
|
11
|
+
g = IGraph.new([1,2,2,3,3,4,2,1,3,2,4,3],true)
|
12
|
+
assert_equal 3, g.mincut_value([5,4,3,3,4,5])
|
13
|
+
g = IGraph.new([1,2,2,3,1,3,3,4,4,5,4,6,5,6],false)
|
14
|
+
val,p1,p2,cut_eid = g.mincut(Array.new(7,1))
|
15
|
+
assert_equal 1, val
|
16
|
+
assert_equal [1,2,3], p2.sort
|
17
|
+
assert_equal [4,5,6], p1.sort
|
18
|
+
assert_equal [3], cut_eid
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'igraph'
|
3
|
+
|
4
|
+
class TestGraph < Test::Unit::TestCase
|
5
|
+
def test_rewire_edges
|
6
|
+
g = IGraph::GenerateRandom.grg_game(10,0.1,false)
|
7
|
+
h = g.rewire_edges(0.5)
|
8
|
+
assert_equal 10, h.to_a.size
|
9
|
+
end
|
10
|
+
def test_rewire
|
11
|
+
g = IGraph::GenerateRandom.grg_game(10,0.1,false)
|
12
|
+
h = g.rewire(0.5)
|
13
|
+
assert_equal 10, h.to_a.size
|
14
|
+
end
|
15
|
+
end
|
data/test/test_all.rb
CHANGED
@@ -9,21 +9,27 @@ require 'tc_add_delete'
|
|
9
9
|
require 'tc_basic_query'
|
10
10
|
require 'tc_basic_properties'
|
11
11
|
require 'tc_centrality'
|
12
|
+
require 'tc_community'
|
12
13
|
require 'tc_components'
|
14
|
+
require 'tc_connectivity'
|
13
15
|
require 'tc_copy'
|
14
16
|
require 'tc_cores'
|
15
17
|
require 'tc_dijkstra'
|
16
18
|
require 'tc_directedness'
|
17
19
|
require 'tc_error_handling'
|
18
20
|
require 'tc_file_read_write'
|
21
|
+
require 'tc_generators_deterministic'
|
19
22
|
require 'tc_generators_random'
|
20
23
|
require 'tc_independent_vertex_sets'
|
21
24
|
require 'tc_isomorphic'
|
22
25
|
require 'tc_iterators'
|
23
26
|
require 'tc_layout'
|
27
|
+
require 'tc_layout3d'
|
24
28
|
require 'tc_matrix'
|
29
|
+
require 'tc_mincuts'
|
25
30
|
require 'tc_motif'
|
26
31
|
require 'tc_other_ops'
|
32
|
+
require 'tc_randomisation'
|
27
33
|
require 'tc_selectors'
|
28
34
|
require 'tc_shortest_paths'
|
29
35
|
require 'tc_spanning'
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: igraph
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.9.0
|
7
|
+
date: 2007-11-19 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
|
@@ -42,21 +42,27 @@ files:
|
|
42
42
|
- ext/cIGraph_basic_query.c
|
43
43
|
- ext/cIGraph_centrality.c
|
44
44
|
- ext/cIGraph_cliques.c
|
45
|
+
- ext/cIGraph_community.c
|
45
46
|
- ext/cIGraph_components.c
|
47
|
+
- ext/cIGraph_connectivity.c
|
46
48
|
- ext/cIGraph_dijkstra.c
|
47
49
|
- ext/cIGraph_direction.c
|
48
50
|
- ext/cIGraph_error_handlers.c
|
49
51
|
- ext/cIGraph_file.c
|
52
|
+
- ext/cIGraph_generators_deterministic.c
|
50
53
|
- ext/cIGraph_generators_random.c
|
51
54
|
- ext/cIGraph_independent_vertex_sets.c
|
52
55
|
- ext/cIGraph_isomorphism.c
|
53
56
|
- ext/cIGraph_iterators.c
|
54
57
|
- ext/cIGraph_kcores.c
|
55
58
|
- ext/cIGraph_layout.c
|
59
|
+
- ext/cIGraph_layout3d.c
|
56
60
|
- ext/cIGraph_matrix.c
|
61
|
+
- ext/cIGraph_min_cuts.c
|
57
62
|
- ext/cIGraph_motif.c
|
58
63
|
- ext/cIGraph_operators.c
|
59
64
|
- ext/cIGraph_other_ops.c
|
65
|
+
- ext/cIGraph_randomisation.c
|
60
66
|
- ext/cIGraph_selectors.c
|
61
67
|
- ext/cIGraph_shortest_paths.c
|
62
68
|
- ext/cIGraph_spanning.c
|
@@ -73,7 +79,9 @@ files:
|
|
73
79
|
- test/tc_basic_query.rb
|
74
80
|
- test/tc_centrality.rb
|
75
81
|
- test/tc_cliques.rb
|
82
|
+
- test/tc_community.rb
|
76
83
|
- test/tc_components.rb
|
84
|
+
- test/tc_connectivity.rb
|
77
85
|
- test/tc_copy.rb
|
78
86
|
- test/tc_cores.rb
|
79
87
|
- test/tc_create.rb
|
@@ -81,14 +89,18 @@ files:
|
|
81
89
|
- test/tc_directedness.rb
|
82
90
|
- test/tc_error_handling.rb
|
83
91
|
- test/tc_file_read_write.rb
|
92
|
+
- test/tc_generators_deterministic.rb
|
84
93
|
- test/tc_generators_random.rb
|
85
94
|
- test/tc_independent_vertex_sets.rb
|
86
95
|
- test/tc_isomorphic.rb
|
87
96
|
- test/tc_iterators.rb
|
88
97
|
- test/tc_layout.rb
|
98
|
+
- test/tc_layout3d.rb
|
89
99
|
- test/tc_matrix.rb
|
100
|
+
- test/tc_mincuts.rb
|
90
101
|
- test/tc_motif.rb
|
91
102
|
- test/tc_other_ops.rb
|
103
|
+
- test/tc_randomisation.rb
|
92
104
|
- test/tc_selectors.rb
|
93
105
|
- test/tc_shortest_paths.rb
|
94
106
|
- test/tc_spanning.rb
|
@@ -98,7 +110,6 @@ files:
|
|
98
110
|
- test/tc_transitivity.rb
|
99
111
|
- test/tc_vertex_neighbourhood.rb
|
100
112
|
- test/test_all.rb
|
101
|
-
- test/test_draw.rb
|
102
113
|
test_files:
|
103
114
|
- test/test_all.rb
|
104
115
|
rdoc_options:
|
data/test/test_draw.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'igraph'
|
2
|
-
require 'cairo'
|
3
|
-
|
4
|
-
g = IGraph.barabasi_game(100,3,false,false)
|
5
|
-
|
6
|
-
vertices = g.to_a
|
7
|
-
layout = g.send(ARGV.shift.to_sym,*ARGV.map{|a| eval(a)}).to_a
|
8
|
-
|
9
|
-
format = Cairo::FORMAT_ARGB32
|
10
|
-
width = 1000
|
11
|
-
height = 1000
|
12
|
-
|
13
|
-
surface = Cairo::ImageSurface.new(format, width, height)
|
14
|
-
cr = Cairo::Context.new(surface)
|
15
|
-
|
16
|
-
# fill background with white
|
17
|
-
cr.set_source_rgba(1.0, 1.0, 1.0, 0.8)
|
18
|
-
cr.paint
|
19
|
-
|
20
|
-
max_x = layout.map{|a| a[0]}.max
|
21
|
-
min_x = layout.map{|a| a[0]}.min
|
22
|
-
max_y = layout.map{|a| a[1]}.max
|
23
|
-
min_y = layout.map{|a| a[1]}.min
|
24
|
-
|
25
|
-
x_var = max_x - min_x
|
26
|
-
y_var = max_y - min_y
|
27
|
-
|
28
|
-
max_var = [x_var,y_var].max
|
29
|
-
|
30
|
-
layout.each_with_index do |a,i|
|
31
|
-
x,y = *a
|
32
|
-
|
33
|
-
x = (x - min_x)/max_var
|
34
|
-
y = (y - min_y)/max_var
|
35
|
-
x *= (width)
|
36
|
-
y *= (height)
|
37
|
-
|
38
|
-
layout[i] = [x,y]
|
39
|
-
|
40
|
-
puts "#{x} #{y}"
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
layout.each_with_index do |a,i|
|
45
|
-
|
46
|
-
v = vertices[i]
|
47
|
-
x,y = *a
|
48
|
-
|
49
|
-
cr.set_source_rgba(rand,rand,rand,0.5)
|
50
|
-
cr.circle(x,y,1).fill
|
51
|
-
|
52
|
-
g.adjacent_vertices(v,IGraph::OUT).each do |w|
|
53
|
-
cr.move_to(x,y)
|
54
|
-
wx,wy = *layout[vertices.index(w)]
|
55
|
-
cr.line_to(wx,wy)
|
56
|
-
cr.stroke
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
cr.target.write_to_png("test.png")
|