On Nov 24, 2004, at 11:21 AM, TC MA wrote:
Still has a compile problem.
interior_property_map.cpp is now:
struct vertexStruct {
string name;
};
template
void who_owes_who(EdgeIter first, EdgeIter last, const
Graph& G)
{
// Access the propety acessor type for this graph
typedef typename property_map::const_type NamePA;
My mistake, this would have needed to be:
typedef typename property_map::const_type NamePA;
But, this shows us just how different bundled properties are from the
prior types of properties. The property_map class becomes harder to
use, but in many cases is not necessary. At the end is my rewrite of
the example, which illustrates how much less baggage we need to worry
about when we go all-out with bundled parameters.
Doug
template
void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G)
{
while (first != last) {
cout << G[source(*first, G)].first_name << " owes "
<< G[target(*first, G)].first_name << " some money" << endl;
++first;
}
}
struct VertexData
{
string first_name;
};
int
main()
{
{
// Create the graph, and specify that we will use std::string to
// store the first name's.
typedef adjacency_list
MyGraphType;
typedef pair Pair;
Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4),
Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1),
Pair(3,4), Pair(4,0), Pair(4,1) };
MyGraphType G(5);
for (int i=0; i<11; ++i)
add_edge(edge_array[i].first, edge_array[i].second, G);
G[0].first_name = "Jeremy";
G[1].first_name = "Rich";
G[2].first_name = "Andrew";
G[3].first_name = "Jeff";
G[4].first_name = "Doug";
who_owes_who(edges(G).first, edges(G).second, G);
}
cout << endl;
return 0;
}