我使用Boost库来处理C++中的图表。你知道吗
boost::adjacency_list <boost::vecS, boost::vecS, boost::bidirectionalS> DiGraph;
DiGraph graph;
boost::add_edge(10000, 20000, graph);
graph
包含20001个顶点和一条边。然而,我只需要有两个顶点10000
和20000
。你知道吗
一种可能的方法是将数据与节点相关联(例如,从this example);然而,可能有一种更简单的方法来实现这一点。如果顶点不是(0,1),我怎么能有一个有两个顶点和一条边的图呢?你知道吗
在python networkx
中,我将简单地使用graph.add_edge(10000, 20000)
,并获得所需的行为。有什么线索在C++中如何做到这一点?你知道吗
应该为顶点集合使用基于节点的容器选择器。你知道吗
例如,使用
listS
:请注意,
vertex_index
现在不是免费的(您必须为所有算法手动传递/维护它)。你知道吗另一方面,迭代器和描述符是稳定的(除非删除)。你知道吗
相关问题 更多 >
编程相关推荐