reverse_graph<BidirectionalGraph, GraphReference>reverse_graph アダプタは BidirectionalGraph の入辺と出辺を交換し、事実上グラフを転置する。reverse_graph の 構築は定数時間で、グラフの転置された眺めを手に入れるための非常に効率的な 方法を提供する。
int main() { typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, > Graph; Graph G(5); boost::add_edge(0, 2, G); boost::add_edge(1, 1, G); boost::add_edge(1, 3, G); boost::add_edge(1, 4, G); boost::add_edge(2, 1, G); boost::add_edge(2, 3, G); boost::add_edge(2, 4, G); boost::add_edge(3, 1, G); boost::add_edge(3, 4, G); boost::add_edge(4, 0, G); boost::add_edge(4, 1, G); std::cout << "original graph:" << std::endl; boost::print_graph(G, boost::get(boost::vertex_index, G)); std::cout << std::endl << "reversed graph:" << std::endl; boost::print_graph(boost::make_reverse_graph(G), boost::get(boost::vertex_index, G)); return 0; }出力は:
original graph: 0 --> 2 1 --> 1 3 4 2 --> 1 3 4 3 --> 1 4 4 --> 0 1 reversed graph: 0 --> 4 1 --> 1 2 3 4 2 --> 0 3 --> 1 2 4 --> 1 2 3
パラメータ | 説明 | デフォルト |
---|---|---|
BidirectionalGraph | 適合されるグラフの型。 | |
GraphReference | もし const の逆グラフ (reverse graph) を作成したいなら型は const BidirectionalGraph& であるべきで、もし非 const の逆グラフ を作成したいなら型は BidirectionalGraph& であるべきである。 | const BidirectionalGraph& |
BidirectionalGraph と、任意に VertexListGraph と PropertyGraph
reverse_graph(BidirectoinalGraph& g)コンストラクタ。グラフ g の逆にされた (転置された) 眺めを 作成する。
templatereverse_graph を作成するためのヘルパ関数。reverse_graph make_reverse_graph(BidirectionalGraph& g)
std::pair<vertex_iterator, vertex_iterator> vertices(const reverse_graph& g)グラフ g の頂点集合へのアクセスを提供するイテレータ範囲を返す。
std::pair<out_edge_iterator, out_edge_iterator> out_edges(vertex_descriptor v, const reverse_graph& g)グラフ g 中の頂点 v の出辺へのアクセスを提供する イテレータ範囲を返す。これらの出辺は適合されたグラフの入辺に相当する。
std::pair<in_edge_iterator, in_edge_iterator> in_edges(vertex_descriptor v, const reverse_graph& g)グラフ g 中の頂点 v の入辺へのアクセスを提供する イテレータ範囲を返す。これらの入辺は適合されたグラフの出辺に相当する。
std::pair<adjacency_iterator, adjacency__iterator> adjacent_vertices(vertex_descriptor v, const reverse_graph& g)グラフ g 中の頂点 v の隣接頂点へのアクセスを提供する イテレータ範囲を返す。
vertex_descriptor source(edge_descriptor e, const reverse_graph& g)辺 e の始点を返す。
vertex_descriptor target(edge_descriptor e, const reverse_graph& g)辺 e の終点を返す。
degree_size_type out_degree(vertex_descriptor u, const reverse_graph& g)頂点 u を出て行く辺数を返す。
degree_size_type in_degree(vertex_descriptor u, const reverse_graph& g)頂点 u に入ってくる辺数を返す。この操作は Directed テンプレート・パラメータのために bidirectionalS が指定された 場合にのみ使用できる。
vertices_size_type num_vertices(const reverse_graph& g)グラフ g 中の頂点数を返す。
vertex_descriptor vertex(vertices_size_type n, const reverse_graph& g)グラフの頂点リスト中の n 番目の頂点を返す。
std::pair<edge_descriptor, bool> edge(vertex_descriptor u, vertex_descriptor v, const reverse_graph& g)グラフ g 中の頂点 u から頂点 v へと接続する辺を 返す。
template <class PropertyTag> property_map<reverse_graph, PropertyTag>::type get(PropertyTag, reverse_graph& g) template <class PropertyTag> property_map<reverse_graph, Tag>::const_type get(PropertyTag, const reverse_graph& g)PropertyTag によって指定される頂点プロパティのためのプロパティ・ マップ・オブジェクトを返す。PropertyTag はグラフの VertexProperty テンプレート引数中で指定されるプロパティの一つに 一致しなければならない。
template <class PropertyTag, class X> typename property_traits<property_map<reverse_graph, PropertyTag>::const_type>::value_type get(PropertyTag, const reverse_graph& g, X x)これは x のためのプロパティ値を返し、ここで x は頂点記述子 または辺記述子のどちらか一方である。
template <class PropertyTag, class X, class Value> void put(PropertyTag, const reverse_graph& g, X x, const Value& value)これは x のためのプロパティ値を value にする。 x は頂点記述子または辺記述子のどちらか一方である。Value は typename property_traits<property_map<reverse_graph, PropertyTag>::type>::value_type に変更可能でなければならない。
template <class GraphProperties, class GraphPropertyTag> typename property_value<GraphProperties, GraphPropertyTag>::type& get_property(reverse_graph& g, GraphPropertyTag);グラフ・オブジェクト g に結びつけられた GraphPropertyTag によって指定されるプロパティを返す。property_value 特性クラスは boost/pending/property.hpp 中で定義される。
template <class GraphProperties, class GraphPropertyTag> const typename property_value<GraphProperties, GraphPropertyTag>::type& get_property(const reverse_graph& g, GraphPropertyTag);グラフ・オブジェクト g に結びつけられた GraphPropertyTag によって指定されるプロパティを返す。property_value 特性クラスは boost/pending/property.hpp 中で定義される。
Copyright © 2000-2001 |
Dave Abrahams
(david.abrahams@rcn.com) Jeremy Siek, Indiana University (jsiek@osl.iu.edu) |
Japanese Translation Copyright © 2003 Takashi Itou
オリジナルの、及びこの著作権表示が全ての複製の中に現れる限り、この文書の複製、利用、変更、販売そして配布を認める。このドキュメントは「あるがまま」に提供されており、いかなる明示的、暗黙的保証も行わない。また、いかなる目的に対しても、その利用が適していることを関知しない。
このドキュメントの対象: Boost Version 1.29.0
最新版ドキュメント (英語)