alexgutteridge 19 years ago
parent
commit
205bb64410
4 changed files with 22 additions and 2 deletions
  1. +4
    -0
      Manifest.txt
  2. +1
    -0
      ext/cIGraph.h
  3. +16
    -0
      ext/cIGraph_utility.c
  4. +1
    -2
      ext/cIGraph_vertex_neighbourhood.c

+ 4
- 0
Manifest.txt View File

@@ -5,6 +5,7 @@ README.txt
ext/cIGraph.c
ext/cIGraph.h
ext/cIGraph_add_delete.c
ext/cIGraph_attribute_handler.c
ext/cIGraph_basic_properties.c
ext/cIGraph_basic_query.c
ext/cIGraph_error_handlers.c
@@ -13,7 +14,9 @@ ext/cIGraph_operators.c
ext/cIGraph_selectors.c
ext/cIGraph_shortest_paths.c
ext/cIGraph_utility.c
ext/cIGraph_vertex_neighbourhood.c
test/tc_add_delete.rb
test/tc_attributes.rb
test/tc_basic_properties.rb
test/tc_basic_query.rb
test/tc_create.rb
@@ -21,4 +24,5 @@ test/tc_error_handling.rb
test/tc_iterators.rb
test/tc_selectors.rb
test/tc_shortest_paths.rb
test/tc_vertex_neighbourhood.rb
test/test_all.rb

+ 1
- 0
ext/cIGraph.h View File

@@ -13,6 +13,7 @@ igraph_integer_t cIGraph_get_vertex_id(VALUE graph, VALUE v);
VALUE cIGraph_get_vertex_object(VALUE graph, igraph_integer_t n);
int cIGraph_vertex_arr_to_id_vec(VALUE graph, VALUE va, igraph_vector_t *nv);
VALUE cIGraph_include(VALUE self, VALUE v);
VALUE cIGraph_create_derived_graph(VALUE old_graph, igraph_t *new_graph);

//IGraph allocation, destruction and intialization
void Init_igraph(void);


+ 16
- 0
ext/cIGraph_utility.c View File

@@ -54,3 +54,19 @@ VALUE cIGraph_include(VALUE self, VALUE v){
VALUE vertex_h = rb_iv_get(self,"@object_ids");
return rb_funcall(vertex_h,rb_intern("has_key?"),1,v);
}

VALUE cIGraph_create_derived_graph(VALUE old_graph, igraph_t *new_graph){

VALUE new_graph_obj;

//Wrap new graph object
new_graph_obj = Data_Wrap_Struct(cIGraph, 0, cIGraph_free, new_graph);

//Go through hashes of old graph and copy across
//are vertex ids the same? If not we're bolloxed
rb_iv_set(new_graph_obj,"@object_ids",rb_iv_get(old_graph,"@object_ids"));
rb_iv_set(new_graph_obj,"@id_objects",rb_iv_get(old_graph,"@id_objects"));

return new_graph_obj;

}

+ 1
- 2
ext/cIGraph_vertex_neighbourhood.c View File

@@ -122,7 +122,6 @@ VALUE cIGraph_neighborhood_graphs(VALUE self, VALUE from, VALUE order, VALUE mod
igraph_vector_t vidv;
igraph_neimode_t pmode = NUM2INT(mode);
igraph_vector_ptr_t res;
igraph_vector_t *path_v;
int i;

VALUE result = rb_ary_new();
@@ -139,7 +138,7 @@ VALUE cIGraph_neighborhood_graphs(VALUE self, VALUE from, VALUE order, VALUE mod
igraph_neighborhood_graphs(graph,&res,vids,NUM2INT(order),pmode);

for(i=0; i<igraph_vector_ptr_size(&res); i++){
rb_ary_push(result,cIGraph_create_derived_graph(self,VECTOR(res)[i]);
rb_ary_push(result,cIGraph_create_derived_graph(self,VECTOR(res)[i]));
}

igraph_vector_destroy(&vidv);


Loading…
Cancel
Save