3 Copyright (c) Jeremy Siek, Lie-Quan Lee, and Andrew Lumsdaine 2000
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
10 <Title>Boost Graph Library: Edge List Class
</Title>
11 <BODY BGCOLOR=
"#ffffff" LINK=
"#0000ee" TEXT=
"#000000" VLINK=
"#551a8b"
13 <IMG SRC=
"../../../boost.png"
14 ALT=
"C++ Boost" width=
"277" height=
"86">
19 <H1><A NAME=
"sec:edge-list-class"></A>
21 edge_list
<EdgeIterator, ValueType, DiffType
>
26 The
<TT>edge_list
</TT> class is an adaptor that turns a pair of edge
27 iterators into a class that models
<TT>EdgeListGraph
</TT>. The
28 <TT>value_type
</TT> of the edge iterator must be a
<TT>std::pair
</TT> (or
29 at least have
<TT>first
</TT> and
<TT>second
</TT> members). The
30 <TT>first_type
</TT> and
<TT>second_type
</TT> of the pair must be the
31 same and they will be used for the graph's
<TT>vertex_descriptor
</TT>.
32 The
<TT>ValueType
</TT> and
<TT>DiffType
</TT> template parameters are only
33 needed if your compiler does not support partial
34 specialization. Otherwise they default to the correct types.
41 Applying the Bellman-Ford shortest paths algorithm to an
46 enum { u, v, x, y, z, N };
47 char name[] = { 'u', 'v', 'x', 'y', 'z' };
49 typedef std::pair
<int,int
> E;
50 E edges[] = { E(u,y), E(u,x), E(u,v),
56 int weight[] = { -
4,
8,
5,
62 typedef boost::edge_list
<E*
> Graph;
63 Graph g(edges, edges + sizeof(edges) / sizeof(E));
65 std::vector
<int
> distance(N, std::numeric_limits
<short
>::max());
66 std::vector
<int
> parent(N,-
1);
70 bool r = boost::bellman_ford_shortest_paths(g, int(N), weight,
74 for (int i =
0; i
< N; ++i)
75 std::cout
<< name[i]
<< ": " << distance[i]
76 << " " << name[parent[i]]
<< std::endl;
78 std::cout
<< "negative cycle" << std::endl;
80 The output is the distance from the root and the parent
81 of each vertex in the shortest paths tree.
93 <H3>Where Defined
</H3>
95 <a href=
"../../../boost/graph/edge_list.hpp"><TT>boost/graph/edge_list.hpp
</TT></a>
98 <H3>Template Parameters
</H3>
103 <th>Parameter
</th><th>Description
</th>
106 <TR><TD><TT>EdgeIterator
</TT></TD> <TD>Must be model of
<a
107 href=
"http://www.sgi.com/tech/stl/InputIterator.html">InputIterator
</a>
108 who's
<TT>value_type
</TT> must be a pair of vertex descriptors.
</TD>
111 <TR><TD><TT>ValueType
</TT></TD>
112 <TD>The
<TT>value_type
</TT> of the
<TT>EdgeIterator
</TT>.
<br>
113 Default:
<TT>std::iterator_traits
<EdgeIterator
>::value_type
</TT></TD>
116 <TR><TD><TT>DiffType
</TT></TD>
117 <TD>The
<TT>difference_type
</TT> of the
<TT>EdgeIterator
</TT>.
<br>
118 Default:
<TT>std::iterator_traits
<EdgeIterator
>::difference_type
</TT></TD>
126 <a href=
"./EdgeListGraph.html">EdgeListGraph
</a>
131 <H3>Associated Types
</H3>
135 <tt>boost::graph_traits
<edge_list
>::vertex_descriptor
</tt>
137 The type for the vertex descriptors associated with the
138 <TT>edge_list
</TT>. This will be the same type as
139 <TT>std::iterator_traits
<EdgeIterator
>::value_type::first_type
</TT>.
144 boost::graph_traits
<edge_list
>::edge_descriptor
147 The type for the edge descriptors associated with the
153 boost::graph_traits
<edge_list
>::edge_iterator
156 The type for the iterators returned by
<TT>edges()
</TT>. The iterator
157 category of the
<TT>edge_iterator
</TT> will be the same as that of the
158 <TT>EdgeIterator
</TT>.
162 <h3>Member Functions
</h3>
167 edge_list(EdgeIterator first, EdgeIterator last)
170 Creates a graph object with
<TT>n
</TT> vertices and with the
171 edges specified in the edge list given by the range
<TT>[first,last)
</TT>.
175 <H3>Non-Member Functions
</H3>
180 std::pair
<edge_iterator, edge_iterator
><br>
181 edges(const edge_list
& g)
184 Returns an iterator-range providing access to the edge set of graph
<TT>g
</TT>.
189 vertex_descriptor
<br>
190 source(edge_descriptor e, const edge_list
& g)
193 Returns the source vertex of edge
<TT>e
</TT>.
198 vertex_descriptor
<br>
199 target(edge_descriptor e, const edge_list
& g)
202 Returns the target vertex of edge
<TT>e
</TT>.
210 <TD nowrap
>Copyright
© 2000-
2001</TD><TD>
211 <A HREF=
"http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek
</A>,
212 Indiana University (
<A
213 HREF=
"mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu
</A>)
<br>
214 <A HREF=
"http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee
</A>, Indiana University (
<A HREF=
"mailto:llee@cs.indiana.edu">llee@cs.indiana.edu
</A>)
<br>
215 <A HREF=
"http://www.osl.iu.edu/~lums">Andrew Lumsdaine
</A>,
216 Indiana University (
<A
217 HREF=
"mailto:lums@osl.iu.edu">lums@osl.iu.edu
</A>)