]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/example/interior_pmap_bundled.cpp
1 //=======================================================================
2 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
3 // Copyright 2004 Trustees of Indiana University
4 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Douglas Gregor
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //=======================================================================
11 #include <boost/config.hpp>
14 #include <boost/graph/adjacency_list.hpp>
15 #include <boost/property_map/property_map.hpp>
19 using namespace boost
;
22 Interior Property Map Basics
24 An interior property map is a way of associating properties
25 with the vertices or edges of a graph. The "interior" part means
26 that the properties are stored inside the graph object. This can be
27 convenient when the need for the properties is somewhat permanent,
28 and when the properties will be with a graph for the duration of its
29 lifetime. A "distance from source vertex" property is often of this
34 Jeremy owes Rich some money
35 Jeremy owes Andrew some money
36 Jeremy owes Jeff some money
37 Jeremy owes Kinis some money
38 Andrew owes Jeremy some money
39 Andrew owes Kinis some money
40 Jeff owes Jeremy some money
41 Jeff owes Rich some money
42 Jeff owes Kinis some money
43 Kinis owes Jeremy some money
44 Kinis owes Rich some money
48 template < class EdgeIter
, class Graph
>
49 void who_owes_who(EdgeIter first
, EdgeIter last
, const Graph
& G
)
53 cout
<< G
[source(*first
, G
)].first_name
<< " owes "
54 << G
[target(*first
, G
)].first_name
<< " some money" << endl
;
67 // Create the graph, and specify that we will use std::string to
68 // store the first name's.
69 typedef adjacency_list
< vecS
, vecS
, directedS
, VertexData
> MyGraphType
;
71 typedef pair
< int, int > Pair
;
72 Pair edge_array
[11] = { Pair(0, 1), Pair(0, 2), Pair(0, 3), Pair(0, 4),
73 Pair(2, 0), Pair(3, 0), Pair(2, 4), Pair(3, 1), Pair(3, 4),
74 Pair(4, 0), Pair(4, 1) };
77 for (int i
= 0; i
< 11; ++i
)
78 add_edge(edge_array
[i
].first
, edge_array
[i
].second
, G
);
80 G
[0].first_name
= "Jeremy";
81 G
[1].first_name
= "Rich";
82 G
[2].first_name
= "Andrew";
83 G
[3].first_name
= "Jeff";
84 G
[4].first_name
= "Doug";
86 who_owes_who(edges(G
).first
, edges(G
).second
, G
);