You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cIGraph_basic_properties.c 698 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "igraph.h"
  2. #include "ruby.h"
  3. #include "cIGraph.h"
  4. /* call-seq:
  5. * graph.are_connected?(from,to) -> true/false
  6. *
  7. * Returns a boolean specifying whether the two vertices specified are
  8. * connected by an edge.
  9. *
  10. * Example:
  11. *
  12. * IGraph.new([1,2,3,4],true)
  13. * graph.are_connected?(1,2) #returns true
  14. *
  15. */
  16. VALUE cIGraph_are_connected(VALUE self, VALUE from, VALUE to){
  17. igraph_t *graph;
  18. igraph_integer_t from_i;
  19. igraph_integer_t to_i;
  20. igraph_bool_t res;
  21. Data_Get_Struct(self, igraph_t, graph);
  22. from_i = cIGraph_get_vertex_id(self,from);
  23. to_i = cIGraph_get_vertex_id(self,to);
  24. igraph_are_connected(graph,from_i,to_i,&res);
  25. return res ? Qtrue : Qfalse;
  26. }

Ruby binding for the igraph library.