ruby-igraph 0.0.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.
- checksums.yaml +7 -0
- data/README.md +73 -0
- data/lib/igraph/libigraph/bipartite.rb +13 -0
- data/lib/igraph/libigraph/centrality.rb +31 -0
- data/lib/igraph/libigraph/constants.rb +82 -0
- data/lib/igraph/libigraph/constructors.rb +34 -0
- data/lib/igraph/libigraph/datatype.rb +22 -0
- data/lib/igraph/libigraph/error.rb +34 -0
- data/lib/igraph/libigraph/games.rb +30 -0
- data/lib/igraph/libigraph/interface.rb +73 -0
- data/lib/igraph/libigraph/matrix.rb +48 -0
- data/lib/igraph/libigraph/operators.rb +22 -0
- data/lib/igraph/libigraph/paths.rb +24 -0
- data/lib/igraph/libigraph/structural.rb +58 -0
- data/lib/igraph/libigraph/topology.rb +17 -0
- data/lib/igraph/libigraph/transitivity.rb +19 -0
- data/lib/igraph/libigraph/vector.rb +87 -0
- data/lib/igraph/libigraph.rb +44 -0
- data/lib/igraph/version.rb +3 -0
- data/lib/igraph.rb +50 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6c8d42e6329374a6359c9deb97da1e291b0f84c1cce87b3f8c73fcbf3ac7e61c
|
4
|
+
data.tar.gz: 5c6b774458e03ed53839816b2176f7842048bbed670b1fc021937c51cda19521
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 237622ee6be6276813a854ac7c25c51c6be5a7c1815c4c3e70db9c2d01512b7e9845d07f848b2b080c6e09f61ef70f6fdfabae191e6187757eacf00b9dd28b30
|
7
|
+
data.tar.gz: 0f35eec9240147790701f796f8be3b299f6704db28335715b0b6f5006cb4e743c003b681dcf22d03400d580eebee431b06fa2c2437bfda0e5212c2a696218ec3
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# ruby-igraph
|
2
|
+
|
3
|
+
[](https://github.com/kojix2/ruby-igraph/actions/workflows/test.yml)
|
4
|
+
[](https://tokei.kojix2.net/github/kojix2/ruby-igraph)
|
5
|
+
|
6
|
+
Ruby bindings for the igraph library - a collection of network analysis tools.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Install the igraph C library first:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
# macOS
|
14
|
+
brew install igraph
|
15
|
+
|
16
|
+
# Ubuntu/Debian
|
17
|
+
sudo apt-get install libigraph-dev
|
18
|
+
|
19
|
+
# Other systems: see https://igraph.org/c/doc/igraph-Installation.html
|
20
|
+
```
|
21
|
+
|
22
|
+
Then install the gem:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
gem install ruby-igraph
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'igraph'
|
32
|
+
|
33
|
+
# Create a simple graph
|
34
|
+
graph = IGraph::LibIGraph::Graph.new
|
35
|
+
IGraph::LibIGraph.igraph_empty(graph.pointer, 3, false)
|
36
|
+
|
37
|
+
# Add edges
|
38
|
+
edges = IGraph::LibIGraph::VectorIntStruct.new
|
39
|
+
IGraph::LibIGraph.igraph_vector_int_init(edges.pointer, 4)
|
40
|
+
IGraph::LibIGraph.igraph_vector_int_set(edges.pointer, 0, 0)
|
41
|
+
IGraph::LibIGraph.igraph_vector_int_set(edges.pointer, 1, 1)
|
42
|
+
IGraph::LibIGraph.igraph_vector_int_set(edges.pointer, 2, 1)
|
43
|
+
IGraph::LibIGraph.igraph_vector_int_set(edges.pointer, 3, 2)
|
44
|
+
|
45
|
+
IGraph::LibIGraph.igraph_create(graph.pointer, edges.pointer, 3, false)
|
46
|
+
|
47
|
+
# Get basic properties
|
48
|
+
vcount = IGraph::LibIGraph.igraph_vcount(graph.pointer) # => 3
|
49
|
+
ecount = IGraph::LibIGraph.igraph_ecount(graph.pointer) # => 2
|
50
|
+
|
51
|
+
# Clean up
|
52
|
+
IGraph::LibIGraph.igraph_vector_int_destroy(edges.pointer)
|
53
|
+
IGraph::LibIGraph.igraph_destroy(graph.pointer)
|
54
|
+
```
|
55
|
+
|
56
|
+
## Development
|
57
|
+
|
58
|
+
```bash
|
59
|
+
git clone https://github.com/kojix2/ruby-igraph
|
60
|
+
cd ruby-igraph
|
61
|
+
bundle install
|
62
|
+
rake test
|
63
|
+
```
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
Bug reports and pull requests are welcome on GitHub.
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
This project was built with love using the vibe coding method.
|
72
|
+
|
73
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_is_bipartite(const igraph_t *graph, igraph_bool_t *res, igraph_vector_bool_t *type);
|
8
|
+
attach_function :igraph_is_bipartite, %i[pointer pointer pointer], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_maximum_bipartite_matching(const igraph_t* graph, const igraph_vector_bool_t* types, igraph_integer_t* matching_size, igraph_real_t* matching_weight, igraph_vector_int_t* matching, const igraph_vector_t* weights, igraph_real_t eps);
|
11
|
+
attach_function :igraph_maximum_bipartite_matching, %i[pointer pointer pointer pointer pointer pointer double], :int
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_betweenness(const igraph_t *graph, igraph_vector_t *res, const igraph_vs_t vids, igraph_bool_t directed, const igraph_vector_t *weights);
|
8
|
+
attach_function :igraph_betweenness, %i[pointer pointer pointer bool pointer], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_pagerank(const igraph_t *graph, igraph_pagerank_algo_t algo, igraph_vector_t *vector, igraph_real_t *value, const igraph_vs_t vids, igraph_bool_t directed, igraph_real_t damping, const igraph_vector_t *weights, igraph_arpack_options_t *options);
|
11
|
+
attach_function :igraph_pagerank, %i[pointer int pointer pointer pointer bool double pointer pointer], :int
|
12
|
+
|
13
|
+
# igraph_error_t igraph_closeness(const igraph_t *graph, igraph_vector_t *res, igraph_vector_int_t *reachable_count, igraph_bool_t *all_reachable, const igraph_vs_t vids, igraph_neimode_t mode, const igraph_vector_t *weights, igraph_bool_t normalized);
|
14
|
+
attach_function :igraph_closeness, %i[pointer pointer pointer pointer pointer int pointer bool], :int
|
15
|
+
|
16
|
+
# igraph_error_t igraph_eigenvector_centrality(const igraph_t *graph, igraph_vector_t *vector, igraph_real_t *value, igraph_bool_t directed, igraph_bool_t scale, const igraph_vector_t *weights, igraph_arpack_options_t *options);
|
17
|
+
attach_function :igraph_eigenvector_centrality, %i[pointer pointer pointer bool bool pointer pointer], :int
|
18
|
+
|
19
|
+
# igraph_error_t igraph_hub_and_authority_scores(const igraph_t *graph, igraph_vector_t *hub_vector, igraph_vector_t *authority_vector, igraph_real_t *value, igraph_bool_t scale, const igraph_vector_t *weights, igraph_arpack_options_t *options);
|
20
|
+
attach_function :igraph_hub_and_authority_scores, %i[pointer pointer pointer pointer bool pointer pointer], :int
|
21
|
+
|
22
|
+
# igraph_error_t igraph_harmonic_centrality(const igraph_t *graph, igraph_vector_t *res, const igraph_vs_t vids, igraph_neimode_t mode, const igraph_vector_t *weights, igraph_bool_t normalized);
|
23
|
+
attach_function :igraph_harmonic_centrality, %i[pointer pointer pointer int pointer bool], :int
|
24
|
+
|
25
|
+
# igraph_error_t igraph_hub_score(const igraph_t *graph, igraph_vector_t *vector, igraph_real_t *value, igraph_bool_t scale, const igraph_vector_t *weights, igraph_arpack_options_t *options);
|
26
|
+
attach_function :igraph_hub_score, %i[pointer pointer pointer bool pointer pointer], :int
|
27
|
+
|
28
|
+
# igraph_error_t igraph_authority_score(const igraph_t *graph, igraph_vector_t *vector, igraph_real_t *value, igraph_bool_t scale, const igraph_vector_t *weights, igraph_arpack_options_t *options);
|
29
|
+
attach_function :igraph_authority_score, %i[pointer pointer pointer bool pointer pointer], :int
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module IGraph
|
2
|
+
module LibIGraph
|
3
|
+
# Graph directedness
|
4
|
+
IGRAPH_UNDIRECTED = 0
|
5
|
+
IGRAPH_DIRECTED = 1
|
6
|
+
|
7
|
+
# Loop handling
|
8
|
+
IGRAPH_NO_LOOPS = 0
|
9
|
+
IGRAPH_LOOPS = 1
|
10
|
+
IGRAPH_LOOPS_TWICE = 1
|
11
|
+
IGRAPH_LOOPS_ONCE = 2
|
12
|
+
|
13
|
+
# Multiple edges
|
14
|
+
IGRAPH_NO_MULTIPLE = 0
|
15
|
+
IGRAPH_MULTIPLE = 1
|
16
|
+
|
17
|
+
# Ordering
|
18
|
+
IGRAPH_ASCENDING = 0
|
19
|
+
IGRAPH_DESCENDING = 1
|
20
|
+
|
21
|
+
# Optimization
|
22
|
+
IGRAPH_MINIMUM = 0
|
23
|
+
IGRAPH_MAXIMUM = 1
|
24
|
+
|
25
|
+
# Neighbor modes
|
26
|
+
IGRAPH_OUT = 1
|
27
|
+
IGRAPH_IN = 2
|
28
|
+
IGRAPH_ALL = 3
|
29
|
+
|
30
|
+
# Connectedness
|
31
|
+
IGRAPH_WEAK = 1
|
32
|
+
IGRAPH_STRONG = 2
|
33
|
+
|
34
|
+
# Adjacency matrix modes
|
35
|
+
IGRAPH_ADJ_DIRECTED = 0
|
36
|
+
IGRAPH_ADJ_UNDIRECTED = 1
|
37
|
+
IGRAPH_ADJ_UPPER = 2
|
38
|
+
IGRAPH_ADJ_LOWER = 3
|
39
|
+
IGRAPH_ADJ_MIN = 4
|
40
|
+
IGRAPH_ADJ_PLUS = 5
|
41
|
+
IGRAPH_ADJ_MAX = 6
|
42
|
+
|
43
|
+
# Star graph modes
|
44
|
+
IGRAPH_STAR_OUT = 0
|
45
|
+
IGRAPH_STAR_IN = 1
|
46
|
+
IGRAPH_STAR_UNDIRECTED = 2
|
47
|
+
IGRAPH_STAR_MUTUAL = 3
|
48
|
+
|
49
|
+
# Tree modes
|
50
|
+
IGRAPH_TREE_OUT = 0
|
51
|
+
IGRAPH_TREE_IN = 1
|
52
|
+
IGRAPH_TREE_UNDIRECTED = 2
|
53
|
+
|
54
|
+
# Matrix storage
|
55
|
+
IGRAPH_ROW_MAJOR = 0
|
56
|
+
IGRAPH_COLUMN_MAJOR = 1
|
57
|
+
|
58
|
+
# Vertex selector types
|
59
|
+
IGRAPH_VS_ALL = 0
|
60
|
+
IGRAPH_VS_ADJ = 1
|
61
|
+
IGRAPH_VS_NONE = 2
|
62
|
+
IGRAPH_VS_1 = 3
|
63
|
+
IGRAPH_VS_VECTORPTR = 4
|
64
|
+
IGRAPH_VS_VECTOR = 5
|
65
|
+
IGRAPH_VS_RANGE = 6
|
66
|
+
IGRAPH_VS_NONADJ = 7
|
67
|
+
|
68
|
+
# Edge selector types
|
69
|
+
IGRAPH_ES_ALL = 0
|
70
|
+
IGRAPH_ES_ALLFROM = 1
|
71
|
+
IGRAPH_ES_ALLTO = 2
|
72
|
+
IGRAPH_ES_INCIDENT = 3
|
73
|
+
IGRAPH_ES_NONE = 4
|
74
|
+
IGRAPH_ES_1 = 5
|
75
|
+
IGRAPH_ES_VECTORPTR = 6
|
76
|
+
IGRAPH_ES_VECTOR = 7
|
77
|
+
IGRAPH_ES_RANGE = 8
|
78
|
+
IGRAPH_ES_PAIRS = 9
|
79
|
+
IGRAPH_ES_PATH = 10
|
80
|
+
IGRAPH_ES_ALL_BETWEEN = 12
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_create(igraph_t *graph, const igraph_vector_int_t *edges, igraph_integer_t n, igraph_bool_t directed);
|
8
|
+
attach_function :igraph_create, %i[pointer pointer long_long bool], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_full(igraph_t *graph, igraph_integer_t n, igraph_bool_t directed, igraph_bool_t loops);
|
11
|
+
attach_function :igraph_full, %i[pointer long_long bool bool], :int
|
12
|
+
|
13
|
+
# igraph_error_t igraph_star(igraph_t *graph, igraph_integer_t n, igraph_star_mode_t mode, igraph_integer_t center);
|
14
|
+
attach_function :igraph_star, %i[pointer long_long int long_long], :int
|
15
|
+
|
16
|
+
# igraph_error_t igraph_ring(igraph_t *graph, igraph_integer_t n, igraph_bool_t directed, igraph_bool_t mutual, igraph_bool_t circular);
|
17
|
+
attach_function :igraph_ring, %i[pointer long_long bool bool bool], :int
|
18
|
+
|
19
|
+
# igraph_error_t igraph_adjacency(igraph_t *graph, const igraph_matrix_t *adjmatrix, igraph_adjacency_t mode, igraph_loops_t loops);
|
20
|
+
attach_function :igraph_adjacency, %i[pointer pointer int int], :int
|
21
|
+
|
22
|
+
# igraph_error_t igraph_small(igraph_t *graph, igraph_integer_t n, igraph_bool_t directed, int first, ...);
|
23
|
+
attach_function :igraph_small, %i[pointer long_long bool int varargs], :int
|
24
|
+
|
25
|
+
# igraph_error_t igraph_wheel(igraph_t *graph, igraph_integer_t n, igraph_wheel_mode_t mode, igraph_integer_t center);
|
26
|
+
attach_function :igraph_wheel, %i[pointer long_long int long_long], :int
|
27
|
+
|
28
|
+
# igraph_error_t igraph_kary_tree(igraph_t *graph, igraph_integer_t n, igraph_integer_t children, igraph_tree_mode_t type);
|
29
|
+
attach_function :igraph_kary_tree, %i[pointer long_long long_long int], :int
|
30
|
+
|
31
|
+
# igraph_error_t igraph_atlas(igraph_t *graph, igraph_integer_t number);
|
32
|
+
attach_function :igraph_atlas, %i[pointer long_long], :int
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "ffi"
|
2
|
+
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
class Graph < FFI::Struct
|
8
|
+
layout(
|
9
|
+
:n, :long_long, # igraph_integer_t
|
10
|
+
:directed, :bool, # igraph_bool_t (bool)
|
11
|
+
:from, VectorIntStruct, # igraph_vector_int_t (embedded)
|
12
|
+
:to, VectorIntStruct, # igraph_vector_int_t (embedded)
|
13
|
+
:oi, VectorIntStruct, # igraph_vector_int_t (embedded)
|
14
|
+
:ii, VectorIntStruct, # igraph_vector_int_t (embedded)
|
15
|
+
:os, VectorIntStruct, # igraph_vector_int_t (embedded)
|
16
|
+
:is, VectorIntStruct, # igraph_vector_int_t (embedded)
|
17
|
+
:attr, :pointer, # void*
|
18
|
+
:cache, :pointer # igraph_i_property_cache_t*
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module IGraph
|
2
|
+
module LibIGraph
|
3
|
+
# Error codes
|
4
|
+
IGRAPH_SUCCESS = 0
|
5
|
+
IGRAPH_FAILURE = 1
|
6
|
+
IGRAPH_ENOMEM = 2
|
7
|
+
IGRAPH_PARSEERROR = 3
|
8
|
+
IGRAPH_EINVAL = 4
|
9
|
+
IGRAPH_EXISTS = 5
|
10
|
+
IGRAPH_EINVEVECTOR = 6
|
11
|
+
IGRAPH_EINVVID = 7
|
12
|
+
IGRAPH_NONSQUARE = 8
|
13
|
+
IGRAPH_EINVMODE = 9
|
14
|
+
IGRAPH_EFILE = 10
|
15
|
+
IGRAPH_UNIMPLEMENTED = 12
|
16
|
+
IGRAPH_INTERRUPTED = 13
|
17
|
+
IGRAPH_DIVERGED = 14
|
18
|
+
IGRAPH_ENEGLOOP = 37
|
19
|
+
IGRAPH_EINTERNAL = 38
|
20
|
+
IGRAPH_EDIVZERO = 42
|
21
|
+
IGRAPH_EOVERFLOW = 55
|
22
|
+
IGRAPH_EUNDERFLOW = 58
|
23
|
+
IGRAPH_ERWSTUCK = 59
|
24
|
+
IGRAPH_STOP = 60
|
25
|
+
IGRAPH_ERANGE = 61
|
26
|
+
IGRAPH_ENOSOL = 62
|
27
|
+
|
28
|
+
# const char *igraph_strerror(const igraph_error_t igraph_errno);
|
29
|
+
attach_function :igraph_strerror, [:int], :string
|
30
|
+
|
31
|
+
# igraph_error_t igraph_error(const char *reason, const char *file, int line, igraph_error_t igraph_errno);
|
32
|
+
attach_function :igraph_error, %i[string string int int], :int
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_erdos_renyi_game_gnp(igraph_t *graph, igraph_integer_t n, igraph_real_t p, igraph_bool_t directed, igraph_bool_t loops);
|
8
|
+
attach_function :igraph_erdos_renyi_game_gnp, %i[pointer long_long double bool bool], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_erdos_renyi_game_gnm(igraph_t *graph, igraph_integer_t n, igraph_integer_t m, igraph_bool_t directed, igraph_bool_t loops);
|
11
|
+
attach_function :igraph_erdos_renyi_game_gnm, %i[pointer long_long long_long bool bool], :int
|
12
|
+
|
13
|
+
# igraph_error_t igraph_barabasi_game(igraph_t *graph, igraph_integer_t n, igraph_real_t power, igraph_integer_t m, const igraph_vector_int_t *outseq, igraph_bool_t outpref, igraph_real_t A, igraph_bool_t directed, igraph_barabasi_algorithm_t algo, const igraph_t *start_from);
|
14
|
+
attach_function :igraph_barabasi_game,
|
15
|
+
%i[pointer long_long double long_long pointer bool double bool int pointer], :int
|
16
|
+
|
17
|
+
# igraph_error_t igraph_watts_strogatz_game(igraph_t *graph, igraph_integer_t dim, igraph_integer_t size, igraph_integer_t nei, igraph_real_t p, igraph_bool_t loops, igraph_bool_t multiple);
|
18
|
+
attach_function :igraph_watts_strogatz_game, %i[pointer long_long long_long long_long double bool bool],
|
19
|
+
:int
|
20
|
+
|
21
|
+
# igraph_error_t igraph_k_regular_game(igraph_t *graph, igraph_integer_t no_of_nodes, igraph_integer_t k, igraph_bool_t directed, igraph_bool_t multiple);
|
22
|
+
attach_function :igraph_k_regular_game, %i[pointer long_long long_long bool bool], :int
|
23
|
+
|
24
|
+
# igraph_error_t igraph_growing_random_game(igraph_t *graph, igraph_integer_t n, igraph_integer_t m, igraph_bool_t directed, igraph_bool_t citation);
|
25
|
+
attach_function :igraph_growing_random_game, %i[pointer long_long long_long bool bool], :int
|
26
|
+
|
27
|
+
# igraph_error_t igraph_tree_game(igraph_t *graph, igraph_integer_t n, igraph_bool_t directed, igraph_random_tree_t method);
|
28
|
+
attach_function :igraph_tree_game, %i[pointer long_long bool int], :int
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_vs_t structure for vertex selectors
|
8
|
+
# Simplified definition - union data treated as opaque bytes
|
9
|
+
# Actual C structure:
|
10
|
+
# typedef struct igraph_vs_t {
|
11
|
+
# igraph_vs_type_t type;
|
12
|
+
# union { ... } data; // 16 bytes on 64-bit systems
|
13
|
+
# } igraph_vs_t;
|
14
|
+
class VertexSelector < FFI::Struct
|
15
|
+
layout(
|
16
|
+
:type, :int, # igraph_vs_type_t (4 bytes)
|
17
|
+
:padding, [:uint8, 4], # Padding to align to 8-byte boundary
|
18
|
+
:data, [:uint8, 16] # Union data (16 bytes)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
# igraph_error_t igraph_empty(igraph_t *graph, igraph_integer_t n, igraph_bool_t directed);
|
22
|
+
attach_function :igraph_empty, %i[pointer long_long bool], :int
|
23
|
+
|
24
|
+
# void igraph_destroy(igraph_t *graph);
|
25
|
+
attach_function :igraph_destroy, [:pointer], :void
|
26
|
+
|
27
|
+
# igraph_integer_t igraph_vcount(const igraph_t *graph);
|
28
|
+
attach_function :igraph_vcount, [:pointer], :long_long
|
29
|
+
|
30
|
+
# igraph_integer_t igraph_ecount(const igraph_t *graph);
|
31
|
+
attach_function :igraph_ecount, [:pointer], :long_long
|
32
|
+
|
33
|
+
# igraph_bool_t igraph_is_directed(const igraph_t *graph);
|
34
|
+
attach_function :igraph_is_directed, [:pointer], :bool
|
35
|
+
|
36
|
+
# igraph_error_t igraph_add_edges(igraph_t *graph, const igraph_vector_int_t *edges, void *attr);
|
37
|
+
attach_function :igraph_add_edges, %i[pointer pointer pointer], :int
|
38
|
+
|
39
|
+
# igraph_error_t igraph_add_vertices(igraph_t *graph, igraph_integer_t nv, void *attr);
|
40
|
+
attach_function :igraph_add_vertices, %i[pointer long_long pointer], :int
|
41
|
+
|
42
|
+
# igraph_error_t igraph_neighbors(const igraph_t *graph, igraph_vector_int_t *neis, igraph_integer_t vid, igraph_neimode_t mode);
|
43
|
+
attach_function :igraph_neighbors, %i[pointer pointer long_long int], :int
|
44
|
+
|
45
|
+
# Vertex selector functions
|
46
|
+
# igraph_error_t igraph_vs_all(igraph_vs_t *vs);
|
47
|
+
attach_function :igraph_vs_all, [:pointer], :int
|
48
|
+
|
49
|
+
# void igraph_vs_destroy(igraph_vs_t *vs);
|
50
|
+
attach_function :igraph_vs_destroy, [:pointer], :void
|
51
|
+
|
52
|
+
# igraph_error_t igraph_degree(const igraph_t *graph, igraph_vector_int_t *res, const igraph_vs_t vids, igraph_neimode_t mode, igraph_bool_t loops);
|
53
|
+
attach_function :igraph_degree, [:pointer, :pointer, VertexSelector.by_value, :int, :bool], :int
|
54
|
+
|
55
|
+
# igraph_error_t igraph_delete_edges(igraph_t *graph, igraph_es_t edges);
|
56
|
+
attach_function :igraph_delete_edges, %i[pointer int], :int
|
57
|
+
|
58
|
+
# igraph_error_t igraph_delete_vertices(igraph_t *graph, const igraph_vs_t vertices);
|
59
|
+
attach_function :igraph_delete_vertices, [:pointer, VertexSelector.by_value], :int
|
60
|
+
|
61
|
+
# igraph_error_t igraph_edge(const igraph_t *graph, igraph_integer_t eid, igraph_integer_t *from, igraph_integer_t *to);
|
62
|
+
attach_function :igraph_edge, %i[pointer long_long pointer pointer], :int
|
63
|
+
|
64
|
+
# igraph_error_t igraph_edges(const igraph_t *graph, igraph_es_t eids, igraph_vector_int_t *edges);
|
65
|
+
attach_function :igraph_edges, %i[pointer int pointer], :int
|
66
|
+
|
67
|
+
# igraph_error_t igraph_get_eid(const igraph_t *graph, igraph_integer_t *eid, igraph_integer_t from, igraph_integer_t to, igraph_bool_t directed, igraph_bool_t error);
|
68
|
+
attach_function :igraph_get_eid, %i[pointer pointer long_long long_long bool bool], :int
|
69
|
+
|
70
|
+
# igraph_error_t igraph_incident(const igraph_t *graph, igraph_vector_int_t *eids, igraph_integer_t vid, igraph_neimode_t mode);
|
71
|
+
attach_function :igraph_incident, %i[pointer pointer long_long int], :int
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "vector"
|
3
|
+
|
4
|
+
module IGraph
|
5
|
+
module LibIGraph
|
6
|
+
# igraph_matrix_t structure (embedded, not pointer)
|
7
|
+
class MatrixStruct < FFI::Struct
|
8
|
+
layout(
|
9
|
+
:data, VectorStruct, # igraph_vector (embedded)
|
10
|
+
:nrow, :long_long, # igraph_integer_t
|
11
|
+
:ncol, :long_long # igraph_integer_t
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
# For standalone matrix operations
|
16
|
+
class Matrix < FFI::Struct
|
17
|
+
layout(
|
18
|
+
:data, VectorStruct, # igraph_vector (embedded)
|
19
|
+
:nrow, :long_long, # igraph_integer_t
|
20
|
+
:ncol, :long_long # igraph_integer_t
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
# igraph_error_t igraph_matrix_init(igraph_matrix_t *m, igraph_integer_t nrow, igraph_integer_t ncol);
|
25
|
+
attach_function :igraph_matrix_init, %i[pointer long_long long_long], :int
|
26
|
+
|
27
|
+
# void igraph_matrix_destroy(igraph_matrix_t *m);
|
28
|
+
attach_function :igraph_matrix_destroy, [:pointer], :void
|
29
|
+
|
30
|
+
# igraph_integer_t igraph_matrix_nrow(const igraph_matrix_t *m);
|
31
|
+
attach_function :igraph_matrix_nrow, [:pointer], :long_long
|
32
|
+
|
33
|
+
# igraph_integer_t igraph_matrix_ncol(const igraph_matrix_t *m);
|
34
|
+
attach_function :igraph_matrix_ncol, [:pointer], :long_long
|
35
|
+
|
36
|
+
# double igraph_matrix_get(const igraph_matrix_t *m, igraph_integer_t row, igraph_integer_t col);
|
37
|
+
attach_function :igraph_matrix_get, %i[pointer long_long long_long], :double
|
38
|
+
|
39
|
+
# void igraph_matrix_set(igraph_matrix_t *m, igraph_integer_t row, igraph_integer_t col, double value);
|
40
|
+
attach_function :igraph_matrix_set, %i[pointer long_long long_long double], :void
|
41
|
+
|
42
|
+
# void igraph_matrix_null(igraph_matrix_t *m);
|
43
|
+
attach_function :igraph_matrix_null, [:pointer], :void
|
44
|
+
|
45
|
+
# void igraph_matrix_fill(igraph_matrix_t *m, double e);
|
46
|
+
attach_function :igraph_matrix_fill, %i[pointer double], :void
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_disjoint_union(igraph_t *res, const igraph_t *left, const igraph_t *right);
|
8
|
+
attach_function :igraph_disjoint_union, %i[pointer pointer pointer], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_union(igraph_t *res, const igraph_t *left, const igraph_t *right, igraph_vector_int_t *edge_map1, igraph_vector_int_t *edge_map2);
|
11
|
+
attach_function :igraph_union, %i[pointer pointer pointer pointer pointer], :int
|
12
|
+
|
13
|
+
# igraph_error_t igraph_intersection(igraph_t *res, const igraph_t *left, const igraph_t *right, igraph_vector_int_t *edge_map1, igraph_vector_int_t *edge_map2);
|
14
|
+
attach_function :igraph_intersection, %i[pointer pointer pointer pointer pointer], :int
|
15
|
+
|
16
|
+
# igraph_error_t igraph_difference(igraph_t *res, const igraph_t *orig, const igraph_t *sub);
|
17
|
+
attach_function :igraph_difference, %i[pointer pointer pointer], :int
|
18
|
+
|
19
|
+
# igraph_error_t igraph_complementer(igraph_t *res, const igraph_t *graph, igraph_bool_t loops);
|
20
|
+
attach_function :igraph_complementer, %i[pointer pointer bool], :int
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
require_relative "matrix"
|
5
|
+
|
6
|
+
module IGraph
|
7
|
+
module LibIGraph
|
8
|
+
# igraph_error_t igraph_distances(const igraph_t *graph, igraph_matrix_t *res, const igraph_vs_t from, const igraph_vs_t to, igraph_neimode_t mode);
|
9
|
+
attach_function :igraph_distances, %i[pointer pointer int int int], :int
|
10
|
+
|
11
|
+
# igraph_error_t igraph_get_shortest_paths_dijkstra(const igraph_t *graph, igraph_vector_int_list_t *vertices, igraph_vector_int_list_t *edges, igraph_integer_t from, const igraph_vs_t to, const igraph_vector_t *weights, igraph_neimode_t mode, igraph_vector_int_t *predecessors, igraph_vector_int_t *inbound_edges);
|
12
|
+
attach_function :igraph_get_shortest_paths_dijkstra,
|
13
|
+
%i[pointer pointer pointer long_long int pointer int pointer pointer], :int
|
14
|
+
|
15
|
+
# igraph_error_t igraph_diameter(const igraph_t *graph, igraph_real_t *res, igraph_integer_t *from, igraph_integer_t *to, igraph_bool_t directed, igraph_bool_t unconn);
|
16
|
+
attach_function :igraph_diameter, %i[pointer pointer pointer pointer bool bool], :int
|
17
|
+
|
18
|
+
# igraph_error_t igraph_radius(const igraph_t *graph, igraph_real_t *radius, igraph_neimode_t mode);
|
19
|
+
attach_function :igraph_radius, %i[pointer pointer int], :int
|
20
|
+
|
21
|
+
# igraph_error_t igraph_eccentricity(const igraph_t *graph, igraph_vector_t *res, const igraph_vs_t vids, igraph_neimode_t mode);
|
22
|
+
attach_function :igraph_eccentricity, %i[pointer pointer int int], :int
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_density(const igraph_t *graph, igraph_real_t *res, igraph_bool_t loops);
|
8
|
+
attach_function :igraph_density, %i[pointer pointer bool], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_girth(const igraph_t *graph, igraph_real_t *girth, igraph_vector_int_t *circle);
|
11
|
+
attach_function :igraph_girth, %i[pointer pointer pointer], :int
|
12
|
+
|
13
|
+
# igraph_error_t igraph_has_loop(const igraph_t *graph, igraph_bool_t *res);
|
14
|
+
attach_function :igraph_has_loop, %i[pointer pointer], :int
|
15
|
+
|
16
|
+
# igraph_error_t igraph_has_multiple(const igraph_t *graph, igraph_bool_t *res);
|
17
|
+
attach_function :igraph_has_multiple, %i[pointer pointer], :int
|
18
|
+
|
19
|
+
# igraph_error_t igraph_count_loops(const igraph_t *graph, igraph_integer_t *loop_count);
|
20
|
+
attach_function :igraph_count_loops, %i[pointer pointer], :int
|
21
|
+
|
22
|
+
# igraph_error_t igraph_is_simple(const igraph_t *graph, igraph_bool_t *res);
|
23
|
+
attach_function :igraph_is_simple, %i[pointer pointer], :int
|
24
|
+
|
25
|
+
# igraph_error_t igraph_is_tree(const igraph_t *graph, igraph_bool_t *res, igraph_integer_t *root, igraph_neimode_t mode);
|
26
|
+
attach_function :igraph_is_tree, %i[pointer pointer pointer int], :int
|
27
|
+
|
28
|
+
# igraph_error_t igraph_is_acyclic(const igraph_t *graph, igraph_bool_t *res);
|
29
|
+
attach_function :igraph_is_acyclic, %i[pointer pointer], :int
|
30
|
+
|
31
|
+
# igraph_error_t igraph_is_forest(const igraph_t *graph, igraph_bool_t *res, igraph_vector_int_t *roots, igraph_neimode_t mode);
|
32
|
+
attach_function :igraph_is_forest, %i[pointer pointer pointer int], :int
|
33
|
+
|
34
|
+
# igraph_error_t igraph_maxdegree(const igraph_t *graph, igraph_integer_t *res, igraph_vs_t vids, igraph_neimode_t mode, igraph_bool_t loops);
|
35
|
+
attach_function :igraph_maxdegree, %i[pointer pointer int int bool], :int
|
36
|
+
|
37
|
+
# igraph_error_t igraph_mean_degree(const igraph_t *graph, igraph_real_t *res, igraph_bool_t loops);
|
38
|
+
attach_function :igraph_mean_degree, %i[pointer pointer bool], :int
|
39
|
+
|
40
|
+
# igraph_error_t igraph_reciprocity(const igraph_t *graph, igraph_real_t *res, igraph_bool_t ignore_loops, igraph_reciprocity_t mode);
|
41
|
+
attach_function :igraph_reciprocity, %i[pointer pointer bool int], :int
|
42
|
+
|
43
|
+
# igraph_error_t igraph_is_complete(const igraph_t *graph, igraph_bool_t *res);
|
44
|
+
attach_function :igraph_is_complete, %i[pointer pointer], :int
|
45
|
+
|
46
|
+
# igraph_error_t igraph_are_adjacent(const igraph_t *graph, igraph_integer_t v1, igraph_integer_t v2, igraph_bool_t *res);
|
47
|
+
attach_function :igraph_are_adjacent, %i[pointer long_long long_long pointer], :int
|
48
|
+
|
49
|
+
# igraph_error_t igraph_is_connected(const igraph_t *graph, igraph_bool_t *res, igraph_connectedness_t mode);
|
50
|
+
attach_function :igraph_is_connected, %i[pointer pointer int], :int
|
51
|
+
|
52
|
+
# igraph_error_t igraph_average_path_length(const igraph_t *graph, igraph_real_t *res, igraph_real_t *unconn_pairs, igraph_bool_t directed, igraph_bool_t unconn);
|
53
|
+
attach_function :igraph_average_path_length, %i[pointer pointer pointer bool bool], :int
|
54
|
+
|
55
|
+
# igraph_error_t igraph_constraint(const igraph_t *graph, igraph_vector_t *res, igraph_vs_t vids, const igraph_vector_t *weights);
|
56
|
+
attach_function :igraph_constraint, %i[pointer pointer int pointer], :int
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_topological_sorting(const igraph_t *graph, igraph_vector_int_t *res, igraph_neimode_t mode);
|
8
|
+
attach_function :igraph_topological_sorting, %i[pointer pointer int], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_isomorphic(const igraph_t *graph1, const igraph_t *graph2, igraph_bool_t *iso);
|
11
|
+
attach_function :igraph_isomorphic, %i[pointer pointer pointer], :int
|
12
|
+
|
13
|
+
# igraph_error_t igraph_isomorphic_vf2(const igraph_t *graph1, const igraph_t *graph2, const igraph_vector_int_t *vertex_color1, const igraph_vector_int_t *vertex_color2, const igraph_vector_int_t *edge_color1, const igraph_vector_int_t *edge_color2, igraph_bool_t *iso, igraph_vector_int_t *map12, igraph_vector_int_t *map21, igraph_isohandler_t *isohandler, igraph_isocompat_t *node_compat_fn, igraph_isocompat_t *edge_compat_fn, void *arg);
|
14
|
+
attach_function :igraph_isomorphic_vf2,
|
15
|
+
%i[pointer pointer pointer pointer pointer pointer pointer pointer pointer pointer pointer pointer pointer], :int
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "ffi"
|
2
|
+
require_relative "datatype"
|
3
|
+
require_relative "vector"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
module LibIGraph
|
7
|
+
# igraph_error_t igraph_transitivity_undirected(const igraph_t *graph, igraph_real_t *res, igraph_transitivity_mode_t mode);
|
8
|
+
attach_function :igraph_transitivity_undirected, %i[pointer pointer int], :int
|
9
|
+
|
10
|
+
# igraph_error_t igraph_transitivity_local_undirected(const igraph_t *graph, igraph_vector_t *res, const igraph_vs_t vids, igraph_transitivity_mode_t mode);
|
11
|
+
attach_function :igraph_transitivity_local_undirected, %i[pointer pointer int int], :int
|
12
|
+
|
13
|
+
# igraph_error_t igraph_transitivity_avglocal_undirected(const igraph_t *graph, igraph_real_t *res, igraph_transitivity_mode_t mode);
|
14
|
+
attach_function :igraph_transitivity_avglocal_undirected, %i[pointer pointer int], :int
|
15
|
+
|
16
|
+
# igraph_error_t igraph_transitivity_barrat(const igraph_t *graph, igraph_vector_t *res, const igraph_vs_t vids, const igraph_vector_t *weights, const igraph_transitivity_mode_t mode);
|
17
|
+
attach_function :igraph_transitivity_barrat, %i[pointer pointer int pointer int], :int
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "ffi"
|
2
|
+
|
3
|
+
module IGraph
|
4
|
+
module LibIGraph
|
5
|
+
# igraph_vector_t structure (double vector)
|
6
|
+
class VectorStruct < FFI::Struct
|
7
|
+
layout(
|
8
|
+
:stor_begin, :pointer, # double*
|
9
|
+
:stor_end, :pointer, # double*
|
10
|
+
:end, :pointer # double*
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
# igraph_vector_int_t structure (int vector)
|
15
|
+
class VectorIntStruct < FFI::Struct
|
16
|
+
layout(
|
17
|
+
:stor_begin, :pointer, # int*
|
18
|
+
:stor_end, :pointer, # int*
|
19
|
+
:end, :pointer # int*
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
# igraph_vector_bool_t structure (bool vector)
|
24
|
+
class VectorBoolStruct < FFI::Struct
|
25
|
+
layout(
|
26
|
+
:stor_begin, :pointer, # bool*
|
27
|
+
:stor_end, :pointer, # bool*
|
28
|
+
:end, :pointer # bool*
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
class VectorInt < FFI::Struct
|
33
|
+
layout(
|
34
|
+
:stor_begin, :pointer, # int*
|
35
|
+
:stor_end, :pointer, # int*
|
36
|
+
:end, :pointer # int*
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# igraph_error_t igraph_vector_int_init(igraph_vector_int_t *v, igraph_integer_t size);
|
41
|
+
attach_function :igraph_vector_int_init, %i[pointer long_long], :int
|
42
|
+
|
43
|
+
# void igraph_vector_int_destroy(igraph_vector_int_t *v);
|
44
|
+
attach_function :igraph_vector_int_destroy, [:pointer], :void
|
45
|
+
|
46
|
+
# igraph_integer_t igraph_vector_int_size(const igraph_vector_int_t *v);
|
47
|
+
attach_function :igraph_vector_int_size, [:pointer], :long_long
|
48
|
+
|
49
|
+
# int igraph_vector_int_get(const igraph_vector_int_t *v, igraph_integer_t pos);
|
50
|
+
attach_function :igraph_vector_int_get, %i[pointer long_long], :int
|
51
|
+
|
52
|
+
# void igraph_vector_int_set(igraph_vector_int_t *v, igraph_integer_t pos, int value);
|
53
|
+
attach_function :igraph_vector_int_set, %i[pointer long_long int], :void
|
54
|
+
|
55
|
+
# igraph_vector_t (double vector) functions
|
56
|
+
# igraph_error_t igraph_vector_init(igraph_vector_t *v, igraph_integer_t size);
|
57
|
+
attach_function :igraph_vector_init, %i[pointer long_long], :int
|
58
|
+
|
59
|
+
# void igraph_vector_destroy(igraph_vector_t *v);
|
60
|
+
attach_function :igraph_vector_destroy, [:pointer], :void
|
61
|
+
|
62
|
+
# igraph_integer_t igraph_vector_size(const igraph_vector_t *v);
|
63
|
+
attach_function :igraph_vector_size, [:pointer], :long_long
|
64
|
+
|
65
|
+
# double igraph_vector_get(const igraph_vector_t *v, igraph_integer_t pos);
|
66
|
+
attach_function :igraph_vector_get, %i[pointer long_long], :double
|
67
|
+
|
68
|
+
# void igraph_vector_set(igraph_vector_t *v, igraph_integer_t pos, double value);
|
69
|
+
attach_function :igraph_vector_set, %i[pointer long_long double], :void
|
70
|
+
|
71
|
+
# igraph_vector_bool_t functions
|
72
|
+
# igraph_error_t igraph_vector_bool_init(igraph_vector_bool_t *v, igraph_integer_t size);
|
73
|
+
attach_function :igraph_vector_bool_init, %i[pointer long_long], :int
|
74
|
+
|
75
|
+
# void igraph_vector_bool_destroy(igraph_vector_bool_t *v);
|
76
|
+
attach_function :igraph_vector_bool_destroy, [:pointer], :void
|
77
|
+
|
78
|
+
# igraph_integer_t igraph_vector_bool_size(const igraph_vector_bool_t *v);
|
79
|
+
attach_function :igraph_vector_bool_size, [:pointer], :long_long
|
80
|
+
|
81
|
+
# bool igraph_vector_bool_get(const igraph_vector_bool_t *v, igraph_integer_t pos);
|
82
|
+
attach_function :igraph_vector_bool_get, %i[pointer long_long], :bool
|
83
|
+
|
84
|
+
# void igraph_vector_bool_set(igraph_vector_bool_t *v, igraph_integer_t pos, bool value);
|
85
|
+
attach_function :igraph_vector_bool_set, %i[pointer long_long bool], :void
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module IGraph
|
2
|
+
module LibIGraph
|
3
|
+
extend FFI::Library
|
4
|
+
|
5
|
+
begin
|
6
|
+
ffi_lib IGraph.lib_path
|
7
|
+
rescue LoadError => e
|
8
|
+
raise LoadError, "#{e}\nCould not find #{IGraph.lib_path}"
|
9
|
+
end
|
10
|
+
|
11
|
+
# @!macro attach_function
|
12
|
+
# @!scope class
|
13
|
+
# @!method $1(${2--2})
|
14
|
+
# @return [${-1}] the return value of $0
|
15
|
+
def self.attach_function(*)
|
16
|
+
super
|
17
|
+
rescue FFI::NotFoundError => e
|
18
|
+
warn e.message if $VERBOSE
|
19
|
+
end
|
20
|
+
|
21
|
+
# IGRAPH_EXPORT void IGraphconst char **version_string,
|
22
|
+
# int *major,
|
23
|
+
# int *minor,
|
24
|
+
# int *subminor);
|
25
|
+
attach_function :igraph_version, %i[pointer pointer pointer pointer], :void
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Load all binding modules
|
30
|
+
require_relative "libigraph/constants"
|
31
|
+
require_relative "libigraph/error"
|
32
|
+
require_relative "libigraph/datatype"
|
33
|
+
require_relative "libigraph/vector"
|
34
|
+
require_relative "libigraph/matrix"
|
35
|
+
require_relative "libigraph/constructors"
|
36
|
+
require_relative "libigraph/interface"
|
37
|
+
require_relative "libigraph/games"
|
38
|
+
require_relative "libigraph/structural"
|
39
|
+
require_relative "libigraph/paths"
|
40
|
+
require_relative "libigraph/centrality"
|
41
|
+
require_relative "libigraph/bipartite"
|
42
|
+
require_relative "libigraph/topology"
|
43
|
+
require_relative "libigraph/operators"
|
44
|
+
require_relative "libigraph/transitivity"
|
data/lib/igraph.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require "ffi"
|
2
|
+
|
3
|
+
require_relative "igraph/version"
|
4
|
+
|
5
|
+
module IGraph
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :lib_path
|
10
|
+
|
11
|
+
def search_igraph(name = nil)
|
12
|
+
name ||= "libigraph.#{FFI::Platform::LIBSUFFIX}"
|
13
|
+
lib_path = if ENV["IGRAPHDIR"]
|
14
|
+
File.expand_path(name, ENV["IGRAPHDIR"])
|
15
|
+
else
|
16
|
+
File.expand_path("../vendor/#{name}", __dir__)
|
17
|
+
end
|
18
|
+
return lib_path if File.exist?(lib_path)
|
19
|
+
|
20
|
+
begin
|
21
|
+
require "pkg-config"
|
22
|
+
lib_dir = PKGConfig.variable("igraph", "libdir")
|
23
|
+
lib_path = File.expand_path(name, lib_dir)
|
24
|
+
rescue PackageConfig::NotFoundError
|
25
|
+
warn "igraph.pc was not found in the pkg-config search path."
|
26
|
+
end
|
27
|
+
return lib_path if File.exist?(lib_path)
|
28
|
+
|
29
|
+
warn "igraph shared library '#{name}' not found."
|
30
|
+
end
|
31
|
+
|
32
|
+
def search_igraph_windows
|
33
|
+
ENV["IGRAPHDIR"] ||= [
|
34
|
+
RubyInstaller::Runtime.msys2_installation.msys_path,
|
35
|
+
RubyInstaller::Runtime.msys2_installation.mingwarch
|
36
|
+
].join(File::ALT_SEPARATOR)
|
37
|
+
path = File.expand_path("bin/libigraph.dll", ENV["IGRAPHDIR"])
|
38
|
+
RubyInstaller::Runtime.add_dll_directory(File.dirname(path))
|
39
|
+
path
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
self.lib_path = if Object.const_defined?(:RubyInstaller)
|
44
|
+
search_igraph_windows
|
45
|
+
else
|
46
|
+
search_igraph
|
47
|
+
end
|
48
|
+
|
49
|
+
autoload :LibIGraph, "igraph/libigraph"
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-igraph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kojix2
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: ffi
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: pkg-config
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
email:
|
41
|
+
- 2xijok@gmail.com
|
42
|
+
executables: []
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- README.md
|
47
|
+
- lib/igraph.rb
|
48
|
+
- lib/igraph/libigraph.rb
|
49
|
+
- lib/igraph/libigraph/bipartite.rb
|
50
|
+
- lib/igraph/libigraph/centrality.rb
|
51
|
+
- lib/igraph/libigraph/constants.rb
|
52
|
+
- lib/igraph/libigraph/constructors.rb
|
53
|
+
- lib/igraph/libigraph/datatype.rb
|
54
|
+
- lib/igraph/libigraph/error.rb
|
55
|
+
- lib/igraph/libigraph/games.rb
|
56
|
+
- lib/igraph/libigraph/interface.rb
|
57
|
+
- lib/igraph/libigraph/matrix.rb
|
58
|
+
- lib/igraph/libigraph/operators.rb
|
59
|
+
- lib/igraph/libigraph/paths.rb
|
60
|
+
- lib/igraph/libigraph/structural.rb
|
61
|
+
- lib/igraph/libigraph/topology.rb
|
62
|
+
- lib/igraph/libigraph/transitivity.rb
|
63
|
+
- lib/igraph/libigraph/vector.rb
|
64
|
+
- lib/igraph/version.rb
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
msys2_mingw_dependencies: igraph
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 3.2.0
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubygems_version: 3.6.9
|
84
|
+
specification_version: 4
|
85
|
+
summary: Library for the analysis of networks
|
86
|
+
test_files: []
|