2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-28 19:22:11 +00:00

Biconnected components support

[SVN r27557]
This commit is contained in:
Douglas Gregor
2005-03-04 23:47:10 +00:00
parent 4167abcb5d
commit f237b9feee
5 changed files with 128 additions and 3 deletions

View File

@@ -354,10 +354,40 @@ add_edge(typename basic_graph<DirectedS>::vertex_descriptor u,
typename basic_graph<DirectedS>::vertex_descriptor v,
basic_graph<DirectedS>& g)
{ return std::make_pair(g.add_edge(u, v), true); }
template<typename DirectedS>
void export_basic_graph(const char* name);
template<typename DirectedS>
typename basic_graph<DirectedS>::VertexIndexMap
get(vertex_index_t, const basic_graph<DirectedS>& g)
{ return g.get_vertex_index_map(); }
template<typename DirectedS>
typename basic_graph<DirectedS>::EdgeIndexMap
get(edge_index_t, const basic_graph<DirectedS>& g)
{ return g.get_edge_index_map(); }
} } } // end namespace boost::graph::python
#if 0
namespace boost {
template<typename DirectedS>
struct property_map<graph::python::basic_graph<DirectedS>, vertex_index_t>
{
typedef typename graph::python::basic_graph<DirectedS>::VertexIndexMap
type;
typedef type const_type;
};
template<typename DirectedS>
struct property_map<graph::python::basic_graph<DirectedS>, edge_index_t>
{
typedef typename graph::python::basic_graph<DirectedS>::EdgeIndexMap
type;
typedef type const_type;
};
}
#endif
#endif // BOOST_GRAPH_BASIC_GRAPH_HPP

View File

@@ -0,0 +1,69 @@
// Copyright 2005 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Authors: Douglas Gregor
// Andrew Lumsdaine
#include <boost/graph/biconnected_components.hpp>
#include "graph.hpp"
#include "digraph.hpp"
#include <boost/python.hpp>
#include <list>
#include <iterator>
namespace boost { namespace graph { namespace python {
template<typename Graph>
boost::python::list
biconnected_components
(Graph& g,
const vector_property_map<int, typename Graph::EdgeIndexMap>* in_component)
{
typedef vector_property_map<int, typename Graph::EdgeIndexMap> ComponentMap;
ComponentMap component =
in_component? *in_component : g.template get_edge_map<int>("bicomponent");
std::list<typename Graph::Vertex> art_points;
boost::biconnected_components(g, component, std::back_inserter(art_points),
g.get_vertex_index_map());
boost::python::list result;
for (typename std::list<typename Graph::Vertex>::iterator i
= art_points.begin(); i != art_points.end(); ++i)
result.append(*i);
return result;
}
template<typename Graph>
boost::python::list
articulation_points(const Graph& g)
{
std::list<typename Graph::Vertex> art_points;
boost::python::list result;
boost::articulation_points(g, std::back_inserter(art_points));
for (typename std::list<typename Graph::Vertex>::iterator i
= art_points.begin(); i != art_points.end(); ++i)
result.append(*i);
return result;
}
void export_biconnected_components()
{
using boost::python::arg;
def("biconnected_components", &biconnected_components<Graph>,
(arg("graph"),
arg("component_map") =
(vector_property_map<int, Graph::EdgeIndexMap>*)0));
def("articulation_points", &articulation_points<Graph>, (arg("graph")));
def("biconnected_components", &biconnected_components<Digraph>,
(arg("graph"),
arg("component_map") =
(vector_property_map<int, Digraph::EdgeIndexMap>*)0));
def("articulation_points", &articulation_points<Digraph>, (arg("graph")));
}
} } } // end namespace boost::graph::python

View File

@@ -10,7 +10,7 @@
#include "graph.hpp"
#include "digraph.hpp"
#include <boost/python.hpp>
#include "point2d.hpp"
// #include "point2d.hpp"
namespace boost { namespace graph { namespace python {
@@ -23,6 +23,7 @@ extern void export_breadth_first_search();
extern void export_dijkstra_shortest_paths();
template<typename Graph> void export_breadth_first_search_in_graph();
template<typename Graph> void export_dijkstra_shortest_paths_in_graph();
extern void export_biconnected_components();
template<typename Graph>
void export_in_graph()
@@ -44,10 +45,12 @@ BOOST_PYTHON_MODULE(bgl)
.value("black", color_traits<default_color_type>::black())
;
enum_<point2d>("Point2D")
#if 0
class_<point2d>("Point2D")
.def("x", &point2d::x)
.def("y", &point2d::y)
;
#endif
export_Graph();
export_Digraph();
@@ -56,6 +59,7 @@ BOOST_PYTHON_MODULE(bgl)
export_done();
export_breadth_first_search();
export_dijkstra_shortest_paths();
export_biconnected_components();
}
template void export_in_graph<Graph>();