Ashwin Venkateshan
2017-10-23 00:01:13 UTC
Dear Sir/ Madam,
I am writing to you in regard with a query. I am trying to randomly delete
edges of a random network(Erdos Renyi) using Igraph C. I am using Cywing on
windows and gcc & g++ as the compilers. I have scoured through forums and I
am not sure where I am going wrong. I have attached the code. This is for a
personal project. Any advice is appreciated.
Thank you,
Sincerely,
Ashwin
#include <stdio.h>#include <igraph/igraph.h>
int main() {
int edgeCount=0;igraph_t g;igraph_vector_t v;
igraph_vector_t edges;
igraph_vector_init(&edges,0);
igraph_vector_t indices;
igraph_vector_init(&indices, 0);
igraph_erdos_renyi_game(&g, IGRAPH_ERDOS_RENYI_GNP, 500,
.10,IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS); // Create a random graph
igraph_get_edgelist(&g, &edges, 0); // Put the graph's list of indices
in "edges"
int r = rand() % ((int)igraph_ecount(&g)); // Get a random edge index
igraph_vector_push_back(&indices, r); // create a vector of size 1 in
which to put the random index found above
igraph_delete_edges(&g, igraph_es_vector(&indices)); // Delete that edge
return igraph_ecount(&g);}
I am writing to you in regard with a query. I am trying to randomly delete
edges of a random network(Erdos Renyi) using Igraph C. I am using Cywing on
windows and gcc & g++ as the compilers. I have scoured through forums and I
am not sure where I am going wrong. I have attached the code. This is for a
personal project. Any advice is appreciated.
Thank you,
Sincerely,
Ashwin
#include <stdio.h>#include <igraph/igraph.h>
int main() {
int edgeCount=0;igraph_t g;igraph_vector_t v;
igraph_vector_t edges;
igraph_vector_init(&edges,0);
igraph_vector_t indices;
igraph_vector_init(&indices, 0);
igraph_erdos_renyi_game(&g, IGRAPH_ERDOS_RENYI_GNP, 500,
.10,IGRAPH_UNDIRECTED, IGRAPH_NO_LOOPS); // Create a random graph
igraph_get_edgelist(&g, &edges, 0); // Put the graph's list of indices
in "edges"
int r = rand() % ((int)igraph_ecount(&g)); // Get a random edge index
igraph_vector_push_back(&indices, r); // create a vector of size 1 in
which to put the random index found above
igraph_delete_edges(&g, igraph_es_vector(&indices)); // Delete that edge
return igraph_ecount(&g);}