(1) template < typename VertexListGraph > void write_graphviz(std::ostream& out, const VertexListGraph& g); (2) template < typename VertexListGraph, typename VertexPropertyWriter > void write_graphviz(std::ostream& out, const VertexListGraph& g, VertexPropertyWriter vpw); (3) template < typename VertexListGraph, typename VertexPropertyWriter, typename EdgePropertyWriter > void write_graphviz(std::ostream& out, const VertexListGraph& g, VertexPropertyWriter vpw, EdgePropertyWriter epw); (4) template < typename VertexListGraph, typename VertexPropertyWriter, typename EdgePropertyWriter, typename GraphPropertyWriter > void write_graphviz(std::ostream& out, const VertexListGraph& g, VertexPropertyWriter vpw, EdgePropertyWriter epw, GraphPropertyWriter gpw);
これは BGL グラフオブジェクトを graphviz dot フォーマットで出力ストリームに書き出すためのものである。 ユーザは素晴らしいレイアウトの画像を描くのに AT&T graphviz を使用できるようになる。
二つのパラメータを持つ最初のバージョンは、グラフを std::ostream へと書き出す。 頂点は数値の頂点IDで表される。 グラフの各々の頂点に対して内部ないし外部プロパティを持っているならば、 上記の二つ目のバージョンが それらのプロパティを gaphviz フォーマットのファイルに出力する方法を提供している。 例えば、グラフの各頂点がプロパティマップオブジェクト name を通じてラベルを持っているなら、 ユーザは二つ目のバージョンを用いて:
write_graph(out, g, make_label_writer(name));とすることができる。 ユーティリティ関数 make_label_writer は、頂点ラベル用に定義済みの PropertyWriter を返す。 同様に、三つ目のバージョンと四つ目のバージョンは辺の PropertyWriter 、グラフの PropertyWriter をそれぞれ必要とする。
頂点または辺のための PropertyWriter は ファンクタである。 このファンクタは、空白やコンマで区切られた "name=value" か、角括弧で囲まれた セミコロンの連続を std::ostream に出力する。 以下のファンクタは頂点または辺のための PropertyWriter の例である。 各頂点ないし辺のラベルを出力するのに用いられる。
template < class Name > class label_writer { public: label_writer(Name _name) : name(_name) {} templatevoid operator()(std::ostream& out, const VertexOrEdge& v) const { out << "[label=\"" << name[v] << "\"]"; } private: Name name; };
グラフのための PropertyWriter はファンクタである。 このファンクタはグラフのプロパティの連続を std::ostream に出力する。 以下のコードはグラフのための PropertyWriter の例を抜粋する。
struct sample_graph_writer { void operator()(std::ostream& out) const { out << "graph [bgcolor=lightgrey]" << std::endl; out << "node [shape=circle color=white]" << std::endl; out << "edge [style=dashed]" << std::endl; } }; }
OUT: std::ostream& out
標準 std::ostream オブジェクト。IN: VertexListGraph& g
有向または無向グラフ。 グラフの型は VertexListGraph モデルでなければならない。バージョン 2:
OUT: std::ostream& out
標準 std::ostream オブジェクト。IN: VertexListGraph& g
有向または無向グラフ。 グラフの型は VertexListGraph モデルでなければならない。IN: VertexPropertyWriter vpw
PropertyWriterコンセプトでモデル化された、 頂点のプロパティを出力するファンクタ。バージョン 3:
OUT: std::ostream& out
標準 std::ostream オブジェクト。IN: VertexListGraph& g
有向または無向グラフ。 グラフの型は VertexListGraph モデルでなければならない。IN: VertexPropertyWriter vpw
PropertyWriterコンセプトでモデル化された、 頂点のプロパティを出力するファンクタ。IN: EdgePropertyWriter vpw
PropertyWriterコンセプトでモデル化された、 辺のプロパティを出力するファンクタ。バージョン 4:
OUT: std::ostream& out
標準 std::ostream オブジェクト。IN: VertexListGraph& g
有向または無向グラフ。 グラフの型は VertexListGraph モデルでなければならない。IN: VertexPropertyWriter vpw
PropertyWriterコンセプトでモデル化された、 頂点のプロパティを出力するファンクタ。IN: EdgePropertyWriter vpw
PropertyWriterコンセプトでモデル化された、 辺のプロパティを出力するファンクタ。IN: GraphPropertyWriter vpw
PropertyWriterコンセプトでモデル化された、 グラフのプロパティを出力するファンクタ。
enum files_e { dax_h, yow_h, boz_h, zow_h, foo_cpp, foo_o, bar_cpp, bar_o, libfoobar_a, zig_cpp, zig_o, zag_cpp, zag_o, libzigzag_a, killerapp, N }; const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp", "foo.o", "bar.cpp", "bar.o", "libfoobar.a", "zig.cpp", "zig.o", "zag.cpp", "zag.o", "libzigzag.a", "killerapp" }; int main(int,char*[]) { typedef pair出力は次のようになる:Edge; Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp), Edge(boz_h, bar_cpp), Edge(boz_h, zig_cpp), Edge(boz_h, zag_cpp), Edge(zow_h, foo_cpp), Edge(foo_cpp, foo_o), Edge(foo_o, libfoobar_a), Edge(bar_cpp, bar_o), Edge(bar_o, libfoobar_a), Edge(libfoobar_a, libzigzag_a), Edge(zig_cpp, zig_o), Edge(zig_o, libzigzag_a), Edge(zag_cpp, zag_o), Edge(zag_o, libzigzag_a), Edge(libzigzag_a, killerapp) }; const int nedges = sizeof(used_by)/sizeof(Edge); int weights[nedges]; fill(weights, weights + nedges, 1); typedef adjacency_list< vecS, vecS, directedS, property< vertex_color_t, default_color_type >, property< edge_weight_t, int > > Graph; Graph g(N, used_by, used_by + nedges, weights); write_graphviz(std::cout, g, make_label_writer(name)); }
digraph G { 0 -> 4; 0 -> 6; 0 -> 1; 0 [label="dax.h"]; 1 -> 6; 1 -> 11; 1 [label="yow.h"]; 2 -> 6; 2 -> 9; 2 -> 11; 2 [label="boz.h"]; 3 -> 4; 3 [label="zow.h"]; 4 -> 5; 4 [label="foo.cpp"]; 5 -> 8; 5 [label="foo.o"]; 6 -> 7; 6 [label="bar.cpp"]; 7 -> 8; 7 [label="bar.o"]; 8 -> 13; 8 [label="libfoobar.a"]; 9 -> 10; 9 [label="zig.cpp"]; 10 -> 13; 10 [label="zig.o"]; 11 -> 12; 11 [label="zag.cpp"]; 12 -> 13; 12 [label="zag.o"]; 13 -> 14; 13 [label="libzigzag.a"]; 14; 14 [label="killerapp"]; edge[style="dotted"]; 6 -> 0; }
Copyright © 2000-2001 |
Lie-Quan Lee, Indiana University (llee@cs.indiana.edu) Jeremy Siek, Indiana University (jsiek@osl.iu.edu) |
Japanese Translation Copyright © 2003 Kent.N
オリジナルの、及びこの著作権表示が全ての複製の中に現れる限り、この文書の複製、利用、変更、販売そして配布を認める。このドキュメントは「あるがまま」に提供されており、いかなる明示的、暗黙的保証も行わない。また、いかなる目的に対しても、その利用が適していることを関知しない。
このドキュメントの対象: Boost Version 1.29.0
最新版ドキュメント (英語)