2011-11-08 6 views
3

にラベルを付けますブースト・グラフビズを使用していますが、ラベルは付いていません。私は、頂点間の接続を、Edge構造体にある確率でラベル付けし、Vertex構造体にある関連名でラベル付けされた頂点をラベル付けしたいと考えています。これを行うに私の最初の試みは、このコードを使用することでした:ブーストGraphvizのカスタム頂点は現在、私はいくつかの確率の木を表し、頂点とエッジタイプ用のカスタム構造体を使用するプロジェクトのために、次のコードを持って

std::ofstream outf("test.dot"); 
boost::dynamic_properties dp; 
dp.property("name", get(&Vertex::name, test)); 
dp.property("node_id", get(boost::vertex_index, test)); 
write_graphviz_dp(outf, test, dp); 

をしかし、これは、それは、出力頂点の名前をしないように私がやりたいことではないようです。私はここで何を変えるべきですか?

答えて

2

私はgraphvizを正しく理解していなかったからです。次のコードは期待通りに機能しました:

std::ofstream outf("test.dot"); 
boost::dynamic_properties dp; 
dp.property("label", boost::get(&Vertex::name, test)); 
dp.property("node_id", boost::get(boost::vertex_index, test)); 
dp.property("label", boost::get(&Edge::probability, test)); 
write_graphviz_dp(outf, test, dp); 
関連する問題