#include #include #include //#include "biconnected_components_fix.hpp" #include using namespace boost; struct edge_component_t { typedef edge_property_tag kind; }; typedef adjacency_list< vecS, vecS, directedS, no_property, property< edge_component_t, std::size_t > > Graph; // my_visitor, simply writes to stdout which edge it comes across struct my_visitor : public default_dfs_visitor { template< typename Edge, typename Graph > void tree_edge( const Edge& e, const Graph& g ) { std::cout << "tree: " << source( e, g ) << " -> " << target( e, g ) << "\n"; } template< typename Edge, typename Graph > void forward_or_cross_edge( const Edge& e, const Graph& g ) { std::cout << "forw: " << source( e, g ) << " -> " << target( e, g ) << "\n"; } template< typename Edge, typename Graph > void back_edge( const Edge& e, const Graph& g ) { std::cout << "back: " << source( e, g ) << " -> " << target( e, g ) << "\n"; } }; int main ( int argc, char* argv[] ) { // Create graph Graph g(4); add_edge( 0,1,g); add_edge( 1,0,g); add_edge( 1,2,g); add_edge( 2,1,g); add_edge( 2,3,g); add_edge( 3,2,g); add_edge( 3,0,g); add_edge( 0,3,g); // Print the graph to be sure print_graph( g ); // component map property_map< Graph, edge_component_t >::type component = get( edge_component_t(), g ); // compute biconnected components with our interior visitor biconnected_components( g, component, visitor( my_visitor() ) ); return 0; }