Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71929 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2011-05-13 19:50:02


Author: jewillco
Date: 2011-05-13 19:50:01 EDT (Fri, 13 May 2011)
New Revision: 71929
URL: http://svn.boost.org/trac/boost/changeset/71929

Log:
Changed to explicit stack as suggested by Aaron Windsor
Text files modified:
   trunk/boost/graph/chrobak_payne_drawing.hpp | 18 ++++++++++++++----
   1 files changed, 14 insertions(+), 4 deletions(-)

Modified: trunk/boost/graph/chrobak_payne_drawing.hpp
==============================================================================
--- trunk/boost/graph/chrobak_payne_drawing.hpp (original)
+++ trunk/boost/graph/chrobak_payne_drawing.hpp 2011-05-13 19:50:01 EDT (Fri, 13 May 2011)
@@ -34,12 +34,22 @@
                             VertexToVertexMap left,
                             VertexToVertexMap right)
     {
- if (v != graph_traits<Graph>::null_vertex())
- {
+ typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor;
+ // Suggestion of explicit stack from Aaron Windsor to avoid system stack
+ // overflows.
+ typedef std::pair<vertex_descriptor, std::size_t> stack_entry;
+ std::stack<stack_entry> st;
+ st.push(stack_entry(v, offset));
+ while (!st.empty()) {
+ vertex_descriptor v = st.top().first;
+ std::size_t offset = st.top().second;
+ st.pop();
+ if (v != graph_traits<Graph>::null_vertex()) {
           x[v] += delta_x[v] + offset;
- accumulate_offsets(left[v], x[v], g, x, delta_x, left, right);
- accumulate_offsets(right[v], x[v], g, x, delta_x, left, right);
+ st.push(stack_entry(left[v], x[v]));
+ st.push(stack_entry(right[v], x[v]));
         }
+ }
     }
 
   } /*namespace detail*/ } /*namespace graph*/


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk