2
0
mirror of https://github.com/boostorg/graph.git synced 2026-02-26 16:52:12 +00:00

Merged Boost.Graph changes from trunk for 1.53

[SVN r82061]
This commit is contained in:
Jeremiah Willcock
2012-12-17 23:59:46 +00:00
parent 3419d42acc
commit 22b521ecf4
41 changed files with 2795 additions and 150 deletions

View File

@@ -34,17 +34,23 @@ public:
}
static void get_graphs(const boost::property_tree::ptree& top,
size_t desired_idx /* or -1 for all */,
std::vector<const boost::property_tree::ptree*>& result) {
using boost::property_tree::ptree;
size_t current_idx = 0;
BOOST_FOREACH(const ptree::value_type& n, top) {
if (n.first == "graph") {
result.push_back(&n.second);
get_graphs(n.second, result);
if (current_idx == desired_idx || desired_idx == (size_t)(-1)) {
result.push_back(&n.second);
get_graphs(n.second, (size_t)(-1), result);
if (desired_idx != (size_t)(-1)) break;
}
++current_idx;
}
}
}
void run(std::istream& in)
void run(std::istream& in, size_t desired_idx)
{
using boost::property_tree::ptree;
ptree pt;
@@ -74,7 +80,7 @@ public:
}
// Search for graphs
std::vector<const ptree*> graphs;
get_graphs(gml, graphs);
get_graphs(gml, desired_idx, graphs);
BOOST_FOREACH(const ptree* gr, graphs) {
// Search for nodes
BOOST_FOREACH(const ptree::value_type& node, *gr) {
@@ -209,9 +215,9 @@ private:
namespace boost
{
void BOOST_GRAPH_DECL
read_graphml(std::istream& in, mutate_graph& g)
read_graphml(std::istream& in, mutate_graph& g, size_t desired_idx)
{
graphml_reader reader(g);
reader.run(in);
reader.run(in, desired_idx);
}
}