12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #include "io.h"
- #include "operations.h"
- #include "graph.h"
- void graph_union(graph_t *result, igraph_vector_ptr_t *glist) {
- igraph_union_many(result->graph, glist);
- result->initialised = 1;
- }
- void graph_intersection(graph_t *result, igraph_vector_ptr_t *glist) {
- igraph_intersection_many(result->graph, glist);
- result->initialised = 1;
- }
- void graph_xor(graph_t *result, igraph_vector_ptr_t *glist) {
- if(igraph_vector_ptr_size(glist) < 2) return;
- igraph_t prev, res_left, res_right, res_union;
- igraph_copy(&prev, igraph_vector_ptr_e(glist, 0));
- long int n;
- for(n = 1; n < igraph_vector_ptr_size(glist); ++n) {
- igraph_difference(&res_left, &prev, igraph_vector_ptr_e(glist, n));
- igraph_difference(&res_right, igraph_vector_ptr_e(glist, n), &prev);
- igraph_union(&res_union, &res_left, &res_right);
- igraph_destroy(&prev);
- igraph_copy(&prev, &res_union);
- igraph_destroy(&res_left);
- igraph_destroy(&res_right);
- igraph_destroy(&res_union);
- }
- result->initialised = 1;
- igraph_copy(result->graph, &prev);
- igraph_destroy(&prev);
- }
- void graph_noop(graph_t *result, igraph_vector_ptr_t *glist) {
- // Dummy function in case we just want to convert an input graph to a different format.
- }
- void graph_operation_error(graph_t *result, igraph_vector_ptr_t *glist) {
- fprintf(ost, "Unknown graph operation specified.\n");
- }
|