[/
 / Copyright (c) 2007 Andrew Sutton
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section Edge List]

 template <
     typename EdgeIter,
     typename ValueType = typename iterator_traits<EdgeIter>::value_type,
     typename DiffereneType = typename iterator_traits<EdgeIter>::difference_type
     typename Category  = typename iterator_traits<EdgeIter>::iterator_category>
 class edge_list;

The `edge_list` class is an adaptor that turns a pair of edge iterators into a
graph type that models the [EdgeListGraph] concept. The `value_type` of the edge
iterator must be a `pair` (or at least have `first` and `second` members). The
`first_type` and `second_type` of the pair must be the same and they will be
used for the graph's `vertex_descriptor`. The `ValueType` and `DifferenceType`
template parameters are only needed if your compiler does not support partial
specialization. Otherwise they default to the correct types.

[heading Where Defined]

 #incldue <boost/graph/edge_list.hpp>

[heading Template Parameters]
[table
    [[Parameter] [Description] [Default]]
    [
        [`EdgeIter`]
        [
            Must be a model of [SgiInputIterator], and its `value_type` must be
            `pair<vertex_descriptor, vertex_descriptor>`.
        ]
        [ ]
    ]
    [
        [`ValueType`]
        [The `value_type` of `EdgeIter`.]
        [`iterator_traits<EdgeIter>::value_type`]
    ]
    [
        [`DifferenceType`]
        [The `difference_type` of `EdgeIter`.]
        [`iterator_traits<EdgeIter>::difference_type`]
    ]
    [
        [`Category`]
        [The `iterator_category` of `EdgeIter`.]
        [`iterator_traits<EdgeIter>::iterator_category`]
    ]
]

[heading Model Of]
[EdgeListGraph]

[heading Associated Types]
[table
    [[Type] [Description]]
    [
        [`graph_traits<adjancency_list>::vertex_descriptor`]
        [The type of vertex descriptors associated with the `edge_list`.]
    ]
    [
        [`graph_traits<adjancency_list>::edge_descriptor`]
        [The type of edge descriptors associated with the `edge_list`.]
    ]
    [
        [`graph_traits<edge_list>::edge_size_type`]
        [The type used for dealing with the number of edges in the graph.]
    ]
    [
        [`graph_traits<edge_list>::edge_iterator`]
        [The type used for iterating over edges in the graph. The same as `EdgeIter`.]
    ]
]

[/

<h3>Member Functions</h3>

<hr>

<tt>
edge_list(EdgeIterator first, EdgeIterator last)
</tt>
<br><br>
Creates a graph object with `n` vertices and with the
edges specified in the edge list given by the range \first,last).

<hr>

<H3>Non-Member Functions</H3>

<hr>

<tt>
std::pair&lt;edge_iterator, edge_iterator&gt;<br>
edges(const edge_list&amp; g)
</tt>
<br><br>
Returns an iterator-range providing access to the edge set of graph `g`.

<hr>

<tt>
vertex_descriptor<br>
source(edge_descriptor e, const edge_list&amp; g)
</tt>
<br><br>
Returns the source vertex of edge `e`.

<hr>

<tt>
vertex_descriptor<br>
target(edge_descriptor e, const edge_list&amp; g)
</tt>
<br><br>
Returns the target vertex of edge `e`.

<hr>
]

[heading Example]

Applying the Bellman-Ford shortest paths algorithm to an `edge_list`.

 enum { u, v, x, y, z, N };
 char name[] = { 'u', 'v', 'x', 'y', 'z' };

 typedef std::pair<int,int> E;
 E edges[] = { E(u,y), E(u,x), E(u,v),
               E(v,u),
               E(x,y), E(x,v),
               E(y,v), E(y,z),
               E(z,u), E(z,x) };

 int weight[] = { -4, 8, 5,
                  -2,
                  9, -3,
                  7, 2,
                  6, 7 };

 typedef boost::edge_list<E*> Graph;
 Graph g(edges, edges + sizeof(edges) / sizeof(E));

 std::vector<int> distance(N, std::numeric_limits<short>::max());
 std::vector<int> parent(N,-1);

 distance[z] = 0;
 parent[z] = z;
 bool r = boost::bellman_ford_shortest_paths(g, int(N), weight,
                                             distance.begin(),
                                             parent.begin());
 if(r) {
     for(int i = 0; i < N; ++i) {
         std::cout << name[i] << ": " << distance[i]
                   << " " << name[parent[i]] << std::endl;
     }
 } else {
     std::cout << "negative cycle" << std::endl;
 }

The output is the distance from the root and the parent of each vertex in the
shortest paths tree.

[pre
u: 2 v
v: 4 x
x: 7 z
y: -2 u
z: 0 z
]

[endsect]