删除C的图中的边

删除C的图中的边,c,igraph,C,Igraph,我试图从一个名为“g”的igraph()图中删除随机选择的边 Igraph的“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);

我试图从一个名为“g”的igraph()图中删除随机选择的边

Igraph的“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
}
#包括
#包括
int main(){
igraph_t g;
igraph_向量_t v;
igraph_向量_t边;
igraph_vector_init(&edges,0);
igraph_向量_t指数;
igraph_vector_init(&索引,0);
IGRAPHE_鄂尔多斯_仁义_游戏(&g,IGRAPHE_鄂尔多斯_仁义_GNP,100,.10,IGRAPHE_无向,IGRAPHE_无循环);//创建一个随机图
igraph_get_edgelist(&g,&edges,0);//将图形的索引列表放在“edges”中
int r=rand()%igraph_vector_size(&edges);//获取随机边索引
igraph_vector_push_back(&index,r);//创建一个大小为1的向量,将上面找到的随机索引放入其中
igraph_delete_边(&g,igraph_es_向量(&index));//删除该边
}

这似乎不是使用igraph_delete_edges的方法(对于这样一个简单的操作来说,它确实非常冗长……)在igraph for C中使用igraph_delete_edges的正确方法是什么?

我怀疑,由于一个小时内没有活动,很少有人知道igraph_vector_t类型来自哪个包/库。(我当然不知道)也许你应该提供一个链接到它,或者展示它是如何定义的,或者什么的?不过,请阅读之前获取软件包的链接处的手册-文档中可能有一个示例。注意,MCVE()是可取的;我们看不到您是如何创建
edges
变量的。为什么不在创建图表之前从
边上删除一个条目呢?好的,我根据你的建议进行了编辑。干杯我的gal是删除一条随机边,在图形上做一些测试,添加另一条边,等等。“似乎不起作用”是什么意思?你的问题是什么,真的?我试着把问题弄清楚了。干杯
igraph\u vector\u size(&edges)
将为您提供两倍的边数,因为
edges
将为每条边提供两个元素—一个用于源,一个用于目标。使用
rand()%((int)igraph\u ecoount(&g))
来选择随机边。