【问题标题】:Unidrected graph representation in qucik graph快速图中的无向图表示
【发布时间】:2015-02-26 10:37:33
【问题描述】:

我正在使用QuickGraph .NET library,它是 boost (C++) 图形库的克隆,但我有一些问题,因为我对这个库完全陌生 1- 我将如何在 QucikGraph 中表示无向图?我发现您可以使用以下方法轻松完成提升: adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph; 2-我将如何为顶点分配值我有兴趣将整数值附加到顶点,但我不知道如何做到这一点:

AdjacencyGraph graph = new AdjacencyGraph(new VertexAndEdgeProvider(), false);//I'm not sure about the proper value of this boolean 
IVertex u = graph.AddVertex();// here I'm adding vertex to 'graph' but with no value 
IVertex v = graph.AddVertex();// here also I'm doing the same thing but without assigning any value to vertex v
graph.AddEdge(u, v);

【问题讨论】:

    标签: c# c++ boost boost-graph quickgraph


    【解决方案1】:

    这里是怎么做的:假设你的顶点vertex1vertex2的类型是T,你应该使用下面这段代码(注意:命名空间将是using QuickGraph;):

    AdjacencyGraph<T, Edge<T>> newGraphInstance = new AdjacencyGraph<int, Edge<int>>();
    newGraphInstance.AddVerticesAndEdge(new Edge<T>(vertex1, vertex2));
    

    这将添加顶点和相应的边。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      • 2018-12-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多