|
Boost : |
From: jsiek_at_[hidden]
Date: 1999-12-12 00:43:01
So I was experimenting with an implementation of the
bellman-ford algorithm, and it's just a little bit
more elegant if I use this function you suggested.
Dietmar Kuehl writes:
> incident
> nodes of an edge, ie.
>
> incident(e,g) pair<V,V> get descriptors for the nodes incident
> to an edge.
Cool thing is, we don't really have to add it to the graph
requirements, we can just define it once as follows:
template <class Edge, class Graph>
std::pair<typename graph_traits<Graph>::vertex_descriptor,
typename graph_traits<Graph>::vertex_descriptor>
incident(Edge e, Graph& g)
{
return make_pair(source(e,g), target(e,g));
}
If a graph supports both source() and target(), then this is
valid, otherwise not, which is fine.
Cheers,
Jeremy
----------------------------------------------------------------------
Jeremy Siek
Ph.D. Candidate email: jsiek_at_[hidden]
Univ. of Notre Dame work phone: (650) 933-8724
and cell phone: (415) 377-5814
C++ Library & Compiler Group fax: (650) 932-0127
SGI www: http://www.lsc.nd.edu/~jsiek/
----------------------------------------------------------------------
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk