diff --git a/Manifest.txt b/Manifest.txt index 1116906..32d4e57 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -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 diff --git a/ext/cIGraph.h b/ext/cIGraph.h index 818f2c2..28cfdd8 100644 --- a/ext/cIGraph.h +++ b/ext/cIGraph.h @@ -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); diff --git a/ext/cIGraph_utility.c b/ext/cIGraph_utility.c index f479ebc..6f905b5 100644 --- a/ext/cIGraph_utility.c +++ b/ext/cIGraph_utility.c @@ -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; + +} diff --git a/ext/cIGraph_vertex_neighbourhood.c b/ext/cIGraph_vertex_neighbourhood.c index d571c9d..6281b48 100644 --- a/ext/cIGraph_vertex_neighbourhood.c +++ b/ext/cIGraph_vertex_neighbourhood.c @@ -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