mirror of
https://github.com/boostorg/graph.git
synced 2026-02-26 16:52:12 +00:00
Merged r75066, r75067, r75124, r75140, r75165, r75861, r75862, r75863, r75878, r75906, r75970, r75973, r75974, and r76394 from trunk
[SVN r76536]
This commit is contained in:
@@ -36,19 +36,21 @@ namespace boost
|
||||
(ComponentMap comp, std::size_t& c, DiscoverTimeMap dtm,
|
||||
std::size_t& dfs_time, LowPointMap lowpt, PredecessorMap pred,
|
||||
OutputIterator out, Stack& S, DFSVisitor vis)
|
||||
: comp(comp), c(c), dtm(dtm), dfs_time(dfs_time), lowpt(lowpt),
|
||||
: comp(comp), c(c), children_of_root(0), dtm(dtm),
|
||||
dfs_time(dfs_time), lowpt(lowpt),
|
||||
pred(pred), out(out), S(S), vis(vis) { }
|
||||
|
||||
template <typename Vertex, typename Graph>
|
||||
void initialize_vertex(const Vertex& u, Graph& g)
|
||||
{
|
||||
put(pred, u, u);
|
||||
vis.initialize_vertex(u, g);
|
||||
}
|
||||
|
||||
template <typename Vertex, typename Graph>
|
||||
void start_vertex(const Vertex& u, Graph& g)
|
||||
{
|
||||
put(pred, u, u);
|
||||
children_of_root = 0;
|
||||
vis.start_vertex(u, g);
|
||||
}
|
||||
|
||||
@@ -69,8 +71,14 @@ namespace boost
|
||||
template <typename Edge, typename Graph>
|
||||
void tree_edge(const Edge& e, Graph& g)
|
||||
{
|
||||
typename boost::graph_traits<Graph>::vertex_descriptor src = source(e, g);
|
||||
typename boost::graph_traits<Graph>::vertex_descriptor tgt = target(e, g);
|
||||
|
||||
S.push(e);
|
||||
put(pred, target(e, g), source(e, g));
|
||||
put(pred, tgt, src);
|
||||
if ( get(pred, src) == src ) {
|
||||
++children_of_root;
|
||||
}
|
||||
vis.tree_edge(e, g);
|
||||
}
|
||||
|
||||
@@ -79,11 +87,14 @@ namespace boost
|
||||
{
|
||||
BOOST_USING_STD_MIN();
|
||||
|
||||
if ( target(e, g) != get(pred, source(e, g)) ) {
|
||||
typename boost::graph_traits<Graph>::vertex_descriptor src = source(e, g);
|
||||
typename boost::graph_traits<Graph>::vertex_descriptor tgt = target(e, g);
|
||||
if ( ( tgt != get(pred, src) || get(pred, src) == src ) &&
|
||||
get(dtm, tgt) < get(dtm, src) ) {
|
||||
S.push(e);
|
||||
put(lowpt, source(e, g),
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION(get(lowpt, source(e, g)),
|
||||
get(dtm, target(e, g))));
|
||||
put(lowpt, src,
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION(get(lowpt, src),
|
||||
get(dtm, tgt)));
|
||||
}
|
||||
vis.back_edge(e, g);
|
||||
}
|
||||
@@ -99,49 +110,35 @@ namespace boost
|
||||
{
|
||||
BOOST_USING_STD_MIN();
|
||||
Vertex parent = get(pred, u);
|
||||
const std::size_t dtm_of_dubious_parent = get(dtm, parent);
|
||||
bool is_art_point = false;
|
||||
if ( dtm_of_dubious_parent > get(dtm, u) ) {
|
||||
parent = get(pred, parent);
|
||||
is_art_point = true;
|
||||
put(pred, get(pred, u), u);
|
||||
put(pred, u, parent);
|
||||
}
|
||||
|
||||
if ( parent == u ) { // at top
|
||||
if ( get(dtm, u) + 1 == dtm_of_dubious_parent )
|
||||
is_art_point = false;
|
||||
} else {
|
||||
put(lowpt, parent,
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION(get(lowpt, parent),
|
||||
get(lowpt, u)));
|
||||
|
||||
if (get(lowpt, u) >= get(dtm, parent)) {
|
||||
if ( get(dtm, parent) > get(dtm, get(pred, parent)) ) {
|
||||
put(pred, u, get(pred, parent));
|
||||
put(pred, parent, u);
|
||||
}
|
||||
|
||||
while ( get(dtm, source(S.top(), g)) >= get(dtm, u) ) {
|
||||
put(comp, S.top(), c);
|
||||
S.pop();
|
||||
}
|
||||
put(comp, S.top(), c);
|
||||
S.pop();
|
||||
++c;
|
||||
if ( S.empty() ) {
|
||||
put(pred, u, parent);
|
||||
put(pred, parent, u);
|
||||
}
|
||||
if (parent == u) { // Root of tree is special
|
||||
if (children_of_root >= 2) {
|
||||
*out++ = u;
|
||||
}
|
||||
return;
|
||||
}
|
||||
put(lowpt, parent,
|
||||
min BOOST_PREVENT_MACRO_SUBSTITUTION(get(lowpt, parent),
|
||||
get(lowpt, u)));
|
||||
if ( get(lowpt, u) >= get(dtm, parent) ) {
|
||||
if ( get(pred, parent) != parent ) {
|
||||
*out++ = parent;
|
||||
}
|
||||
while ( get(dtm, source(S.top(), g)) >= get(dtm, u) ) {
|
||||
put(comp, S.top(), c);
|
||||
S.pop();
|
||||
}
|
||||
assert (source(S.top(), g) == parent);
|
||||
assert (target(S.top(), g) == u);
|
||||
put(comp, S.top(), c);
|
||||
S.pop();
|
||||
++c;
|
||||
}
|
||||
if ( is_art_point )
|
||||
*out++ = u;
|
||||
vis.finish_vertex(u, g);
|
||||
}
|
||||
|
||||
ComponentMap comp;
|
||||
std::size_t& c;
|
||||
std::size_t children_of_root;
|
||||
DiscoverTimeMap dtm;
|
||||
std::size_t& dfs_time;
|
||||
LowPointMap lowpt;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <stack>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/utility.hpp> //for next and prior
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
|
||||
@@ -69,6 +69,33 @@ namespace boost {
|
||||
}
|
||||
};
|
||||
|
||||
// Add a reverse_graph_edge_descriptor wrapper if the Graph is a
|
||||
// reverse_graph but the edge descriptor is from the original graph (this
|
||||
// case comes from the fact that transpose_graph uses reverse_graph
|
||||
// internally but doesn't expose the different edge descriptor type to the
|
||||
// user).
|
||||
template <typename Desc, typename Graph>
|
||||
struct add_reverse_edge_descriptor {
|
||||
typedef Desc type;
|
||||
static Desc convert(const Desc& d) {return d;}
|
||||
};
|
||||
|
||||
template <typename Desc, typename G, typename GR>
|
||||
struct add_reverse_edge_descriptor<Desc, boost::reverse_graph<G, GR> > {
|
||||
typedef reverse_graph_edge_descriptor<Desc> type;
|
||||
static reverse_graph_edge_descriptor<Desc> convert(const Desc& d) {
|
||||
return reverse_graph_edge_descriptor<Desc>(d);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Desc, typename G, typename GR>
|
||||
struct add_reverse_edge_descriptor<reverse_graph_edge_descriptor<Desc>, boost::reverse_graph<G, GR> > {
|
||||
typedef reverse_graph_edge_descriptor<Desc> type;
|
||||
static reverse_graph_edge_descriptor<Desc> convert(const reverse_graph_edge_descriptor<Desc>& d) {
|
||||
return d;
|
||||
}
|
||||
};
|
||||
|
||||
// Default edge and vertex property copiers
|
||||
|
||||
template <typename Graph1, typename Graph2>
|
||||
@@ -79,7 +106,7 @@ namespace boost {
|
||||
|
||||
template <typename Edge1, typename Edge2>
|
||||
void operator()(const Edge1& e1, Edge2& e2) const {
|
||||
put(edge_all_map2, e2, get(edge_all_map1, e1));
|
||||
put(edge_all_map2, e2, get(edge_all_map1, add_reverse_edge_descriptor<Edge1, Graph1>::convert(e1)));
|
||||
}
|
||||
typename property_map<Graph1, edge_all_t>::const_type edge_all_map1;
|
||||
mutable typename property_map<Graph2, edge_all_t>::type edge_all_map2;
|
||||
|
||||
@@ -2759,17 +2759,6 @@ namespace boost {
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
namespace boost {
|
||||
|
||||
#if BOOST_WORKAROUND( _STLPORT_VERSION, >= 0x500 )
|
||||
// STLport 5 already defines a hash<void*> specialization.
|
||||
#else
|
||||
template <>
|
||||
struct hash< void* > // Need this when vertex_descriptor=void*
|
||||
{
|
||||
std::size_t
|
||||
operator()(void* v) const { return (std::size_t)v; }
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename V>
|
||||
struct hash< boost::detail::stored_edge<V> >
|
||||
{
|
||||
|
||||
@@ -410,7 +410,7 @@ template <DIRECTED_GRAPH_PARAMS>
|
||||
typename DIRECTED_GRAPH::vertex_descriptor
|
||||
vertex(typename DIRECTED_GRAPH::vertices_size_type n,
|
||||
DIRECTED_GRAPH const& g)
|
||||
{ return vertex(g.impl()); }
|
||||
{ return vertex(n, g.impl()); }
|
||||
|
||||
template <DIRECTED_GRAPH_PARAMS>
|
||||
std::pair<typename DIRECTED_GRAPH::edge_descriptor, bool>
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace boost {
|
||||
{
|
||||
std::vector<size_type> multiplicity(max_invariant, 0);
|
||||
BGL_FORALL_VERTICES_T(v, G1, Graph1)
|
||||
++multiplicity[invariant1(v)];
|
||||
++multiplicity.at(invariant1(v));
|
||||
sort(V_mult, compare_multiplicity(invariant1, &multiplicity[0]));
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace boost {
|
||||
}
|
||||
// The largest possible vertex invariant number
|
||||
size_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const {
|
||||
return (m_max_vertex_in_degree + 2) * m_max_vertex_out_degree + 1;
|
||||
return (m_max_vertex_in_degree + 1) * (m_max_vertex_out_degree + 1);
|
||||
}
|
||||
private:
|
||||
InDegreeMap m_in_degree_map;
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace boost {
|
||||
detail::graph::compute_edge_length(g, distance, index,
|
||||
edge_or_side_length);
|
||||
|
||||
std::cerr << "edge_length = " << edge_length << std::endl;
|
||||
// std::cerr << "edge_length = " << edge_length << std::endl;
|
||||
|
||||
// Compute l_{ij} and k_{ij}
|
||||
const weight_type K = spring_constant;
|
||||
@@ -275,7 +275,7 @@ namespace boost {
|
||||
E += .5 * k_ij * (dist - l_ij) * (dist - l_ij);
|
||||
}
|
||||
}
|
||||
std::cerr << "E = " << E << std::endl;
|
||||
// std::cerr << "E = " << E << std::endl;
|
||||
|
||||
// Compute the elements of the Jacobian
|
||||
// From
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
#include <boost/graph/properties.hpp>
|
||||
|
||||
#include <LEDA/graph.h>
|
||||
#include <LEDA/node_array.h>
|
||||
#include <LEDA/node_map.h>
|
||||
#include <LEDA/graph/graph.h>
|
||||
#include <LEDA/graph/node_array.h>
|
||||
#include <LEDA/graph/node_map.h>
|
||||
|
||||
// The functions and classes in this file allows the user to
|
||||
// treat a LEDA GRAPH object as a boost graph "as is". No
|
||||
@@ -884,7 +884,7 @@ namespace boost {
|
||||
inline
|
||||
typename boost::property_traits<
|
||||
typename boost::property_map<leda::GRAPH<vtype, etype>,PropertyTag>::const_type
|
||||
::value_type
|
||||
>::value_type
|
||||
get(PropertyTag p, const leda::GRAPH<vtype, etype>& g, const Key& key) {
|
||||
return get(get(p, g), key);
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ template <UNDIRECTED_GRAPH_PARAMS>
|
||||
typename UNDIRECTED_GRAPH::vertex_descriptor
|
||||
vertex(typename UNDIRECTED_GRAPH::vertices_size_type n,
|
||||
UNDIRECTED_GRAPH const& g)
|
||||
{ return vertex(g.impl()); }
|
||||
{ return vertex(n, g.impl()); }
|
||||
|
||||
template <UNDIRECTED_GRAPH_PARAMS>
|
||||
std::pair<typename UNDIRECTED_GRAPH::edge_descriptor, bool>
|
||||
|
||||
Reference in New Issue
Block a user