I’m trying to use Boost’s adjacency_list type and I’m having trouble understanding the documentation.
Say I define a class named State and I instantiate one instance for each state in the USA:
class State { ... }; State california, oregon, nevada, arizona, hawaii, ...
I want to enter these into a boost::adjacency_list the vertices are states and the edges are borders. For the states I listed above, I think the graph would have this data:
california : oregon, nevada, arizona hawaii : oregon : california, nevada nevada : oregon, california, arizona arizona : california, nevada
I understand how to put ints into the graph and I considered just making an array of states and inserting their array index into the graph, but it seems like I should be able to just say:
add_edge(california, oregon, graph);
but of course that doesn’t work. Please help!
Edit:
Here’s an example of almost exactly what I need.
Reading up on boost::adjacency_list, it appears you are supposed to use properties for the vertices rather than something like a class:
(Poorly) adapted from an example in boost.