Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f07d913
[subgraph.hpp] add_vertex(u_global, g) on a subgraph does not recursi…
Nov 2, 2016
faef224
Reproduce memory issue with resource constrained shortest paths. Valg…
Jul 4, 2017
67a32c2
Fix read/writes outside allocated memory. Remove is_valid assertions …
Jul 4, 2017
726e953
Replace /bin/bash with /bin/sh
asomers Jul 27, 2017
e2db737
Don't copy value if not needed, as source's m_property will be set to…
Jul 30, 2018
e8d7c9f
Added test case for removing edges bug from previous commit.
Aug 23, 2018
a499be8
Merge pull request #1 from pmateusz/develop
anadon Sep 1, 2018
03b6e8a
Merge pull request #3 from raahlb/fix_remove_vertex
anadon Sep 1, 2018
e2f742d
Merge pull request #2 from asomers/develop
anadon Sep 1, 2018
19dd94e
Merge pull request #4 from boostorg/develop
anadon Sep 1, 2018
c045049
Merge pull request #5 from anadon/fix-add-vertex-subgraph
anadon Sep 1, 2018
84122c8
Fixed an incorrect file name in tests and added a git ignore for gene…
anadon Sep 1, 2018
19c23ca
Removing references and testing to relaxed heap; relaxed heap is now …
anadon Sep 1, 2018
98164bf
Removed dead code/comment block from iteration macros.
anadon Sep 1, 2018
283675d
Use of nullptr when it is too soon to include that feature.
anadon Sep 5, 2018
82fa79e
Inappropriate overuse of 'typename' removed.
anadon Sep 5, 2018
037af4d
Fixing incorrect use of typedef's via macro.
anadon Sep 6, 2018
3cc890e
Changing c++11 auto type usage to delctype() boilerplate in order to …
anadon Sep 7, 2018
8551039
Learned more of how typename works, changed to using that.
anadon Sep 8, 2018
a10f17e
Made typename fixes more broad and complete.
anadon Sep 11, 2018
6808062
First possible complete fixes for r_c_shortest_paths.
anadon Sep 11, 2018
21bdac5
Silencing some build warnings about a trivial faux pas
anadon Sep 14, 2018
9cfddda
I don't recall messing with these to make them auto, but they were au…
anadon Sep 23, 2018
5d0f5a6
Clang had some helpful warnings about typename usage which were applied.
anadon Sep 23, 2018
5d6c7f6
Reverting a block comment removal at jzmaddock's request.
anadon Sep 25, 2018
5dd7483
Realized the while loop in reindex_edge_list(), and so changed this.
anadon Sep 28, 2018
2e54007
Merge pull request #6 from apolukhin/antoshkka/visibility-issues
anadon Sep 29, 2018
d31aa18
Rebasing to new develop
anadon Sep 29, 2018
183a67f
Merge branch 'boostorg-develop' into develop
anadon Sep 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cube-fr.dot
cube.dot
disconnected-fr.dot
graphml_test_out.xml
kevin-bacon2.dat
random.dot
triangular-fr.dot
triangular-kk.dot
4 changes: 2 additions & 2 deletions doc/grid_graph_export_svg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

#=======================================================================
# Copyright 2009 Trustees of Indiana University.
Expand All @@ -16,4 +16,4 @@ inkscape --export-png grid_graph_unwrapped.png --export-id g3150 --export-id-onl
inkscape --export-png grid_graph_wrapped.png grid_graph_unindexed.svg

# Indexed, unwrapped
inkscape --export-png grid_graph_indexed.png grid_graph_indexed.svg
inkscape --export-png grid_graph_indexed.png grid_graph_indexed.svg
44 changes: 21 additions & 23 deletions include/boost/graph/cycle_canceling.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//=======================================================================
// Copyright 2013 University of Warsaw.
// Authors: Piotr Wygocki
// Authors: Piotr Wygocki
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
Expand All @@ -12,15 +12,14 @@
// by Ahuja, Magnanti, Orlin.

#ifndef BOOST_GRAPH_CYCLE_CANCELING_HPP
#define BOOST_GRAPH_CYCLE_CANCELING_HPP
#define BOOST_GRAPH_CYCLE_CANCELING_HPP

#include <numeric>

#include <boost/property_map/property_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/graph_concepts.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <boost/pending/relaxed_heap.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/detail/augment.hpp>
Expand All @@ -32,11 +31,11 @@ namespace boost {
namespace detail {

template <typename PredEdgeMap, typename Vertex>
class RecordEdgeMapAndCycleVertex
class RecordEdgeMapAndCycleVertex
: public bellman_visitor<edge_predecessor_recorder<PredEdgeMap, on_edge_relaxed> > {
typedef edge_predecessor_recorder<PredEdgeMap, on_edge_relaxed> PredRec;
public:
RecordEdgeMapAndCycleVertex(PredEdgeMap pred, Vertex & v) :
RecordEdgeMapAndCycleVertex(PredEdgeMap pred, Vertex & v) :
bellman_visitor<PredRec>(PredRec(pred)), m_v(v), m_pred(pred) {}

template <typename Graph, typename Edge>
Expand All @@ -63,27 +62,27 @@ template <class Graph, class Pred, class Distance, class Reversed, class Residua
void cycle_canceling(const Graph &g, Weight weight, Reversed rev, ResidualCapacity residual_capacity, Pred pred, Distance distance) {
typedef filtered_graph<const Graph, is_residual_edge<ResidualCapacity> > ResGraph;
ResGraph gres = detail::residual_graph(g, residual_capacity);

typedef graph_traits<ResGraph> ResGTraits;
typedef graph_traits<Graph> GTraits;
typedef typename ResGTraits::edge_descriptor edge_descriptor;
typedef typename ResGTraits::vertex_descriptor vertex_descriptor;

typename GTraits::vertices_size_type N = num_vertices(g);

BGL_FORALL_VERTICES_T(v, g, Graph) {
put(pred, v, edge_descriptor());
put(distance, v, 0);
}

vertex_descriptor cycleStart;
while(!bellman_ford_shortest_paths(gres, N,
while(!bellman_ford_shortest_paths(gres, N,
weight_map(weight).
distance_map(distance).
visitor(detail::RecordEdgeMapAndCycleVertex<Pred, vertex_descriptor>(pred, cycleStart)))) {

detail::augment(g, cycleStart, cycleStart, pred, residual_capacity, rev);

BGL_FORALL_VERTICES_T(v, g, Graph) {
put(pred, v, edge_descriptor());
put(distance, v, 0);
Expand All @@ -97,7 +96,7 @@ namespace detail {

template <class Graph, class P, class T, class R, class ResidualCapacity, class Weight, class Reversed, class Pred, class Distance>
void cycle_canceling_dispatch2(
const Graph &g,
const Graph &g,
Weight weight,
Reversed rev,
ResidualCapacity residual_capacity,
Expand All @@ -110,7 +109,7 @@ void cycle_canceling_dispatch2(
//setting default distance map
template <class Graph, class P, class T, class R, class Pred, class ResidualCapacity, class Weight, class Reversed>
void cycle_canceling_dispatch2(
Graph &g,
Graph &g,
Weight weight,
Reversed rev,
ResidualCapacity residual_capacity,
Expand All @@ -121,27 +120,27 @@ void cycle_canceling_dispatch2(

std::vector<D> d_map(num_vertices(g));

cycle_canceling(g, weight, rev, residual_capacity, pred,
cycle_canceling(g, weight, rev, residual_capacity, pred,
make_iterator_property_map(d_map.begin(), choose_const_pmap(get_param(params, vertex_index), g, vertex_index)));
}

template <class Graph, class P, class T, class R, class ResidualCapacity, class Weight, class Reversed, class Pred>
void cycle_canceling_dispatch1(
Graph &g,
Weight weight,
Graph &g,
Weight weight,
Reversed rev,
ResidualCapacity residual_capacity,
Pred pred,
const bgl_named_params<P, T, R>& params) {
cycle_canceling_dispatch2(g, weight, rev,residual_capacity, pred,
cycle_canceling_dispatch2(g, weight, rev,residual_capacity, pred,
get_param(params, vertex_distance), params);
}

//setting default predecessors map
template <class Graph, class P, class T, class R, class ResidualCapacity, class Weight, class Reversed>
void cycle_canceling_dispatch1(
Graph &g,
Weight weight,
Graph &g,
Weight weight,
Reversed rev,
ResidualCapacity residual_capacity,
param_not_found,
Expand All @@ -151,20 +150,20 @@ void cycle_canceling_dispatch1(

cycle_canceling_dispatch2(g, weight, rev, residual_capacity,
make_iterator_property_map(p_map.begin(), choose_const_pmap(get_param(params, vertex_index), g, vertex_index)),
get_param(params, vertex_distance), params);
get_param(params, vertex_distance), params);
}

}//detail

template <class Graph, class P, class T, class R>
void cycle_canceling(Graph &g,
const bgl_named_params<P, T, R>& params) {
cycle_canceling_dispatch1(g,
cycle_canceling_dispatch1(g,
choose_const_pmap(get_param(params, edge_weight), g, edge_weight),
choose_const_pmap(get_param(params, edge_reverse), g, edge_reverse),
choose_pmap(get_param(params, edge_residual_capacity),
choose_pmap(get_param(params, edge_residual_capacity),
g, edge_residual_capacity),
get_param(params, vertex_predecessor),
get_param(params, vertex_predecessor),
params);
}

Expand All @@ -178,4 +177,3 @@ void cycle_canceling(Graph &g) {
}

#endif /* BOOST_GRAPH_CYCLE_CANCELING_HPP */

13 changes: 6 additions & 7 deletions include/boost/graph/detail/adjacency_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ namespace boost {
: Base(static_cast< Base const& >(x)), m_property(const_cast<self&>(x).m_property) { }
self& operator=(const self& x) {
// NOTE: avoid 'Base::operator=(x);' broken on SGI MIPSpro (bug 55771 of Mozilla).
static_cast<Base&>(*this) = static_cast< Base const& >(x);
static_cast<Base&>(*this) = static_cast< Base const& >(x);
m_property = const_cast<self&>(x).m_property;
return *this;
}
Expand All @@ -277,7 +277,7 @@ namespace boost {
: Base(static_cast< Base&& >(x)), m_property(std::move(x.m_property)) { }
self& operator=(self&& x) {
// NOTE: avoid 'Base::operator=(x);' broken on SGI MIPSpro (bug 55771 of Mozilla).
static_cast<Base&>(*this) = static_cast< Base&& >(x);
static_cast<Base&>(*this) = static_cast< Base&& >(x);
m_property = std::move(x.m_property);
return *this;
}
Expand Down Expand Up @@ -2051,16 +2051,15 @@ namespace boost {
if ((*ei).get_target() > u)
--(*ei).get_target();
}

template <class EdgeList, class vertex_descriptor>
inline void
reindex_edge_list(EdgeList& el, vertex_descriptor u,
boost::disallow_parallel_edge_tag)
{
typename EdgeList::iterator ei = el.begin(), e_end = el.end();
while (ei != e_end) {
typename EdgeList::value_type ce = *ei;
++ei;
if (ce.get_target() > u) {
for(typename EdgeList::iterator ei = el.begin(); ei != el.end(); ++ei) {
if (ei->get_target() > u) {
typename EdgeList::value_type ce = *ei;
el.erase(ce);
--ce.get_target();
el.insert(ce);
Expand Down
35 changes: 5 additions & 30 deletions include/boost/graph/dijkstra_shortest_paths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <boost/graph/relax.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <boost/graph/exception.hpp>
#include <boost/pending/relaxed_heap.hpp>
#include <boost/graph/overloading.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/graph/detail/d_ary_heap.hpp>
Expand Down Expand Up @@ -53,18 +52,13 @@ namespace boost {
* @param old_distance the previous distance to @p vertex
*/
template<typename Buffer, typename Vertex, typename DistanceType>
inline void
inline void
dijkstra_queue_update(Buffer& Q, Vertex vertex, DistanceType old_distance)
{
(void)old_distance;
Q.update(vertex);
}

#ifdef BOOST_GRAPH_DIJKSTRA_TESTING
// This is a misnomer now: it now just refers to the "default heap", which is
// currently d-ary (d=4) but can be changed by a #define.
static bool dijkstra_relaxed_heap = true;
#endif

template <class Visitor, class Graph>
struct DijkstraVisitorConcept {
Expand Down Expand Up @@ -187,7 +181,7 @@ namespace boost {
// The test here is equivalent to e_weight < 0 if m_combine has a
// cancellation law, but always returns false when m_combine is a
// projection operator.
if (m_compare(m_combine(m_zero, get(m_weight, e)), m_zero))
if (m_compare(m_combine(m_zero, get(m_weight, e)), m_zero))
boost::throw_exception(negative_edge());
// End of test for negative-weight edges.

Expand Down Expand Up @@ -345,25 +339,7 @@ namespace boost {

typedef typename graph_traits<Graph>::vertex_descriptor Vertex;

#ifdef BOOST_GRAPH_DIJKSTRA_TESTING
if (!dijkstra_relaxed_heap) {
typedef mutable_queue<Vertex, std::vector<Vertex>, IndirectCmp, IndexMap>
MutableQueue;

MutableQueue Q(num_vertices(g), icmp, index_map);
detail::dijkstra_bfs_visitor<DijkstraVisitor, MutableQueue, WeightMap,
PredecessorMap, DistanceMap, Combine, Compare>
bfs_vis(vis, Q, weight, predecessor, distance, combine, compare, zero);

breadth_first_visit(g, s_begin, s_end, Q, bfs_vis, color);
return;
}
#endif // BOOST_GRAPH_DIJKSTRA_TESTING

#ifdef BOOST_GRAPH_DIJKSTRA_USE_RELAXED_HEAP
typedef relaxed_heap<Vertex, IndirectCmp, IndexMap> MutableQueue;
MutableQueue Q(num_vertices(g), icmp, index_map);
#else // Now the default: use a d-ary heap
// Now the default: use a d-ary heap
boost::scoped_array<std::size_t> index_in_heap_map_holder;
typedef
detail::vertex_property_map_generator<Graph, IndexMap, std::size_t>
Expand All @@ -374,7 +350,6 @@ namespace boost {
typedef d_ary_heap_indirect<Vertex, 4, IndexInHeapMap, DistanceMap, Compare>
MutableQueue;
MutableQueue Q(distance, index_in_heap, compare);
#endif // Relaxed heap

detail::dijkstra_bfs_visitor<DijkstraVisitor, MutableQueue, WeightMap,
PredecessorMap, DistanceMap, Combine, Compare>
Expand Down Expand Up @@ -406,7 +381,7 @@ namespace boost {
template <class VertexListGraph, class SourceInputIter, class DijkstraVisitor,
class PredecessorMap, class DistanceMap,
class WeightMap, class IndexMap, class Compare, class Combine,
class DistInf, class DistZero, typename T, typename Tag,
class DistInf, class DistZero, typename T, typename Tag,
typename Base>
inline void
dijkstra_shortest_paths
Expand All @@ -429,7 +404,7 @@ namespace boost {
template <class VertexListGraph, class DijkstraVisitor,
class PredecessorMap, class DistanceMap,
class WeightMap, class IndexMap, class Compare, class Combine,
class DistInf, class DistZero, typename T, typename Tag,
class DistInf, class DistZero, typename T, typename Tag,
typename Base>
inline void
dijkstra_shortest_paths
Expand Down
Loading