reverse_graph<BidirectionalGraph>
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; }The output is:
Parameter | Description |
---|---|
BidirectionalGraph | The graph type to be adapted. |
BidirectionalGraph and optionally VertexListGraph and PropertyGraph
reverse_graph(BidirectoinalGraph& g)Constructor. Create a reversed (transposed) view of the graph g.
templateHelper function for creating a reverse_graph.reverse_graph make_reverse_graph(BidirectionalGraph& g)
std::pair<vertex_iterator, vertex_iterator> vertices(const reverse_graph& g)Returns an iterator-range providing access to the vertex set of graph g.
std::pair<out_edge_iterator, out_edge_iterator> out_edges(vertex_descriptor v, const reverse_graph& g)Returns an iterator-range providing access to the out-edges of vertex v in graph g. These out-edges correspond to the in-edges of the adapted graph.
std::pair<in_edge_iterator, in_edge_iterator> in_edges(vertex_descriptor v, const reverse_graph& g)Returns an iterator-range providing access to the in-edges of vertex v in graph g. These in-edges correspond to the out edges of the adapted graph.
std::pair<adjacency_iterator, adjacency__iterator> adjacent_vertices(vertex_descriptor v, const reverse_graph& g)Returns an iterator-range providing access to the adjacent vertices of vertex v in graph g.
vertex_descriptor source(edge_descriptor e, const reverse_graph& g)Returns the source vertex of edge e.
vertex_descriptor target(edge_descriptor e, const reverse_graph& g)Returns the target vertex of edge e.
degree_size_type out_degree(vertex_descriptor u, const reverse_graph& g)Returns the number of edges leaving vertex u.
degree_size_type in_degree(vertex_descriptor u, const reverse_graph& g)Returns the number of edges entering vertex u. This operation is only available if bidirectionalS was specified for the Directed template parameter.
vertices_size_type num_vertices(const reverse_graph& g)Returns the number of vertices in the graph g.
vertex_descriptor vertex(vertices_size_type n, const reverse_graph& g)Returns the nth vertex in the graph's vertex list.
std::pair<edge_descriptor, bool> edge(vertex_descriptor u, vertex_descriptor v, const reverse_graph& g)Returns the edge connecting vertex u to vertex v in graph g.
template <class Property> property_map<reverse_graph, Property>::type get(Property, reverse_graph& g) template <class Property> property_map<reverse_graph, Tag>::const_type get(Property, const reverse_graph& g)Returns the property map object for the vertex property specified by Property. The Property must match one of the properties specified in the graph's VertexProperty template argument.
template <class Property, class X> typename property_traits<property_map<reverse_graph, Property>::const_type>::value_type get(Property, const reverse_graph& g, X x)This returns the property value for x, which is either a vertex or edge descriptor.
template <class Property, class X, class Value> void put(Property, const reverse_graph& g, X x, const Value& value)This sets the property value for x to value. x is either a vertex or edge descriptor. Value must be convertible to typename property_traits<property_map<reverse_graph, Property>::type>::value_type
template <class GraphProperties, class GraphProperty> typename property_value<GraphProperties, GraphProperty>::type& get_property(reverse_graph& g, GraphProperty);Return the property specified by GraphProperty that is attached to the graph object g. The property_value traits class is defined in boost/pending/property.hpp.
template <class GraphProperties, class GraphProperty> const typename property_value<GraphProperties, GraphProperty>::type& get_property(const reverse_graph& g, GraphProperty);Return the property specified by GraphProperty that is attached to the graph object g. The property_value traits class is defined in boost/pending/property.hpp.
Copyright © 2000 |
Dave Abrahams,
Univ.of Notre Dame (jsiek@lsc.nd.edu) Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu) |