我试图删除一个随机选择的边缘,形成一个名为" g"的igraph(http://igraph.org/c/)图。
Igraph的" igraph_delete_edges"手册功能就在这里:http://igraph.org/c/doc/igraph-Basic.html#igraph_delete_edges但是我还不足以弄明白。
我有这个:
#include <stdio.h>
#include <igraph/igraph.h>
int main() {
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, 100, .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() % igraph_vector_size(&edges); // 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
}
这似乎不是使用igraph_delete_edges的方式(对于这样一个简单的操作,它确实非常冗长......)在igraph中使用igraph_delete_edges的正确方法是什么?