# Changeset 1754:4bf5ceb49023 in lemon-0.x for lemon/johnson.h

Ignore:
Timestamp:
11/02/05 16:27:38 (14 years ago)
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2283
Message:

Documentation modified

File:
1 edited

Unmodified
Added
Removed
• ## lemon/johnson.h

 r1747 }; /// \brief Johnson algorithm class. /// \brief %Johnson algorithm class. /// /// \ingroup flowalgs /// This class provides an efficient implementation of \c Johnson /// This class provides an efficient implementation of \c %Johnson /// algorithm. The edge lengths are passed to the algorithm using a /// \ref concept::ReadMap "ReadMap", so it is easy to change it to any /// The algorithm solves the shortest path problem for each pairs /// of node when the edges can have negative length but the graph should /// not contain circle with negative sum of length. If we can assume /// not contain cycles with negative sum of length. If we can assume /// that all edge is non-negative in the graph then the dijkstra algorithm /// should be used from each node. } }; ///\ref named-templ-param "Named parameter" for setting heap and cross ///reference type ///\brief \ref named-templ-param "Named parameter" for setting heap and ///cross reference type ///\ref named-templ-param "Named parameter" for setting heap and cross protected: typedef typename BelmannFord:: template DefOperationTraits:: template DefPredMap >:: Create BelmannFordType; void shiftedRun(const BelmannFordType& belmannford) { template void shiftedRun(const PotentialMap& potential) { typename Graph::template EdgeMap shiftlen(*graph); for (EdgeIt it(*graph);  it != INVALID; ++it) { shiftlen[it] = (*length)[it] + belmannford.dist(graph->source(it)) - belmannford.dist(graph->target(it)); + potential[graph->source(it)] - potential[graph->target(it)]; } if (dijkstra.reached(jt)) { _dist->set(it, jt, dijkstra.dist(jt) + belmannford.dist(jt) - belmannford.dist(it)); potential[jt] - potential[it]); _pred->set(it, jt, dijkstra.pred(jt)); } else { void start() { typedef typename BelmannFord:: template DefOperationTraits:: template DefPredMap >:: Create BelmannFordType; BelmannFordType belmannford(*graph, *length); belmannford.start(); shiftedRun(belmannford); } /// \brief Executes the algorithm and checks the negatvie circles. shiftedRun(belmannford.distMap()); } /// \brief Executes the algorithm and checks the negatvie cycles. /// /// This method runs the %Johnson algorithm in order to compute /// the shortest path to each node pairs. If the graph contains /// negative circle it gives back false. The algorithm /// negative cycle it gives back false. The algorithm /// computes /// - The shortest path tree for each node. /// - The distance between each node pairs. bool checkedStart() { typedef typename BelmannFord:: template DefOperationTraits:: template DefPredMap >:: Create BelmannFordType; BelmannFordType belmannford(*graph, *length); if (!belmannford.checkedStart()) return false; shiftedRun(belmannford); shiftedRun(belmannford.distMap()); return true; }
Note: See TracChangeset for help on using the changeset viewer.