27 namespace treeTraversal {
38 static void Write(std::ostream& outStream,
const Histogram& histogram)
40 if (!histogram.empty())
42 Histogram::const_iterator endIt = histogram.end();
44 const int largest = endIt->first;
45 for (
int bin = 0; bin <= largest; ++bin)
47 Histogram::const_iterator item = histogram.find(bin);
48 const int count = (item == histogram.end() ? 0 : *item->second);
49 outStream << bin <<
" " << count <<
"\n";
62 if (node->children.size() > 1)
64 int largestProblemSize = 0;
65 int secondLargestProblemSize = 0;
66 for(
const boost::shared_ptr<NODE>& child: node->children)
68 if (child->problemSize() > largestProblemSize)
70 secondLargestProblemSize = largestProblemSize;
71 largestProblemSize = child->problemSize();
73 else if (child->problemSize() > secondLargestProblemSize)
75 secondLargestProblemSize = child->problemSize();
85 template<
class FOREST>
90 DepthFirstForest(forest, statsPtr, internal::statisticsVisitor<typename FOREST::Node>);
Histogram problemSizeHistogram
Struct to store gathered statistics about a forest.
Included from all GTSAM files.
void DepthFirstForest(FOREST &forest, DATA &rootData, VISITOR_PRE &visitorPre, VISITOR_POST &visitorPost)
Histogram problemSizeOfSecondLargestChildHistogram
static void Write(std::ostream &outStream, const Histogram &histogram)
Histogram numberOfChildrenHistogram
ForestStatistics * statisticsVisitor(const boost::shared_ptr< NODE > &node, ForestStatistics *stats)
A thin wrapper around std::map that uses boost's fast_pool_allocator.
FastMap< int, ValueWithDefault< int, 0 > > Histogram
ForestStatistics GatherStatistics(const FOREST &forest)