2
0
mirror of https://github.com/boostorg/graph.git synced 2026-01-28 07:12:14 +00:00

boost/graph/cuthill_mckee_ordering.hpp, boost/graph/king_ordering.hpp:

- Remove use of connected components, so we need only one color map
    running around
  - Provide simple overloads, requiring only the graph and the output iterator.

boost/graph/detail/sparse_ordering.hpp:
  - Move out_degree_property_map here

boost/graph/fruchterman_reingold.hpp:
  - Fix enumeration of pairs in grid_force_pairs to repulse vertices in
    adjacent grid cells (in addition to the current cell), so we don't get
    vertices forming crosses on grid lines.
  - Round up the number of rows/columns.

libs/graph/doc/cuthill_mckee_ordering.html, libs/graph/doc/king_ordering.html:
  - Document new overloads

libs/graph/doc/gursoy_atun_layout.html:
  - Add missing semicolon

libs/graph/src/python/cuthill_mckee_ordering.cpp,
libs/graph/test/cuthill_mckee_ordering.cpp:
  - Test and use the new overloads

libs/graph/build/python/Jamfile, libs/graph/src/python/module.cpp,
libs/graph/src/python/king_ordering.cpp:
  - Support King's ordering algorithm from Python

libs/graph/example/python/vis.py:
  - By default, do a "progressive" Fruchterman-Reingold layout

libs/graph/test/king_ordering.cpp:
  - Test new overload


[SVN r28306]
This commit is contained in:
Douglas Gregor
2005-04-17 23:50:43 +00:00
parent ea6d11a47e
commit 4bc19a1621
14 changed files with 274 additions and 194 deletions

View File

@@ -15,47 +15,14 @@
namespace boost { namespace graph { namespace python {
template <typename Graph>
class out_degree_property_map
: public put_get_helper<typename graph_traits<Graph>::degree_size_type,
out_degree_property_map<Graph> >
{
public:
typedef typename graph_traits<Graph>::vertex_descriptor key_type;
typedef typename graph_traits<Graph>::degree_size_type value_type;
typedef value_type reference;
typedef readable_property_map_tag category;
out_degree_property_map(const Graph& g) : m_g(g) { }
value_type operator[](const key_type& v) const {
return out_degree(v, m_g);
}
private:
const Graph& m_g;
};
template <typename Graph>
inline out_degree_property_map<Graph>
make_out_degree_map(const Graph& g) {
return out_degree_property_map<Graph>(g);
}
template<typename Graph>
boost::python::list
cuthill_mckee_ordering
(const Graph& g,
const vector_property_map<default_color_type,
typename Graph::VertexIndexMap>* in_color)
cuthill_mckee_ordering(const Graph& g)
{
typedef vector_property_map<default_color_type,
typename Graph::VertexIndexMap> ColorMap;
ColorMap color =
in_color? *in_color : ColorMap(g.num_vertices(), g.get_vertex_index_map());
std::list<typename Graph::Vertex> ordering;
boost::python::list result;
boost::cuthill_mckee_ordering(g, std::back_inserter(ordering),
color, make_out_degree_map(g));
g.get_vertex_index_map());
for (typename std::list<typename Graph::Vertex>::iterator i
= ordering.begin(); i != ordering.end(); ++i)
result.append(*i);
@@ -66,15 +33,7 @@ void export_cuthill_mckee_ordering()
{
using boost::python::arg;
using boost::python::def;
def("cuthill_mckee_ordering", &cuthill_mckee_ordering<Graph>,
(arg("graph"),
arg("color_map") =
(vector_property_map<default_color_type, Graph::VertexIndexMap>*)0));
def("cuthill_mckee_ordering", &cuthill_mckee_ordering<Digraph>,
(arg("graph"),
arg("color_map") =
(vector_property_map<default_color_type, Digraph::VertexIndexMap>*)0));
def("cuthill_mckee_ordering", &cuthill_mckee_ordering<Graph>, arg("graph"));
}
} } } // end namespace boost::graph::python

View File

@@ -0,0 +1,39 @@
// 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/king_ordering.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
king_ordering(const Graph& g)
{
std::list<typename Graph::Vertex> ordering;
boost::python::list result;
boost::king_ordering(g, std::back_inserter(ordering),
g.get_vertex_index_map());
for (typename std::list<typename Graph::Vertex>::iterator i
= ordering.begin(); i != ordering.end(); ++i)
result.append(*i);
return result;
}
void export_king_ordering()
{
using boost::python::arg;
using boost::python::def;
def("king_ordering", &king_ordering<Graph>, arg("graph"));
}
} } } // end namespace boost::graph::python

View File

@@ -36,6 +36,7 @@ extern void export_biconnected_components();
extern void export_incremental_components();
extern void export_topological_sort();
extern void export_cuthill_mckee_ordering();
extern void export_king_ordering();
//extern void export_minimum_degree_ordering();
extern void export_sequential_vertex_coloring();
extern void export_betweenness_centrality();
@@ -119,6 +120,7 @@ BOOST_PYTHON_MODULE(bgl)
// Sparse Matrix Ordering
export_cuthill_mckee_ordering();
export_king_ordering();
// export_minimum_degree_ordering();
// Other algorithms