I'm writing an application that's parsing a data structure with something like
struct Block
{
std::string foo;
/* ... even more local data ... */
};
std::map<std::string, Block> blockContainer; // Each Block will have a name here
struct Signal
{
// the direct links to the Blocks, no redundant storage of the name so that an
// simple renaming of a Block would be possible
std::map<std::string, Block>::iterator from;
std::map<std::string, Block>::iterator to;
std::string bar;
/* ... even more local data ... */
};
std::vector<Signal> signalContainer;
parsing and filling this list was quite easy. Now I need to do a topological sort of the Blocks depending on the Signals - also quite easy when I use Boost::Graph
.
But first parsing it in a STL data structure and then copying them over to the Boost::Graph structure doesn't make much sense to me. Especially as all that'll be done with this data afterwards is perhaps some simple modifications (add/remove of Blocks and Signals, some signal rerouteing; serialising it out again) with a new topological sort afterwards.
So I'd be fine with any of these possible solutions:
- Make Boost::Graph work on my containers directly
- Parse the data directly into the Boost::Graph data structures (and e.g. use a graph with bundled properties like
boost::adjacency_list<boost::mapS, boost::vecS, boost::directedS, Block, Signal>
)
But it seems I'm not intelligent enough to understand the documentation here to do either. Also all the examples I found on the net were showing how to use the bundled properties - but not how to construct the graph with those on the fly. (And, of course, not with node and vertex properties at the same time, or how to use a std::map
for the nodes to access them by their name, ...)
Can someone help me out?
Thanks!