1

ブースト (C++) グラフ ライブラリのクローンであるQuickGraph .NET ライブラリを使用していますが、このライブラリはまったく初めてなので、いくつか質問があります。次を使用してブーストで簡単に実行できることがわかりました: 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);
4

1 に答える 1

0

方法は次のとおりです: 頂点が タイプであるvertex1と仮定すると、次のコードを使用する必要があります (注: 名前空間は になります)。vertex2Tusing QuickGraph;

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

これにより、頂点と対応するエッジの両方が追加されます。

于 2016-04-13T18:36:28.473 に答える