59template<
typename T,
template<
typename P,
class C>
class H = PairingHeap>
79 bool arcsReversed =
false) {
81 distance.
init(G, std::numeric_limits<T>::max());
82 predecessor.
init(G,
nullptr);
87 for (
node s : sources) {
94 for (
node v : G.nodes) {
95 queue.
push(v, distance[v]);
97 for (
node s : sources) {
98 queue.
decrease(s, (distance[s] = 0));
102 for (
edge de : G.edges) {
107 while (!queue.
empty()) {
115 edge e = adj->theEdge();
116 node w = adj->twinNode();
118 && ((!arcsReversed && e->
target() == v)
119 || (arcsReversed && e->
target() != v))) {
123 if (
m_eps.
greater(distance[w], distance[v] + weight[e])) {
124 OGDF_ASSERT(std::numeric_limits<T>::max() - weight[e] >= distance[v]);
125 queue.
decrease(w, (distance[w] = distance[v] + weight[e]));
147 node target, T maxLength = std::numeric_limits<T>::max()) {
149 distance.
init(G, std::numeric_limits<T>::max());
150 predecessor.
init(G,
nullptr);
153 for (
node s : sources) {
154 queue.
push(s, (distance[s] = 0));
158 for (
edge de : G.edges) {
163 while (!queue.
empty()) {
175 edge e = adj->theEdge();
176 node w = adj->twinNode();
178 && ((!arcsReversed && e->
target() == v)
179 || (arcsReversed && e->
target() != v))) {
183 const T newDistance = distance[v] + weight[e];
189 OGDF_ASSERT(std::numeric_limits<T>::max() - weight[e] >= distance[v]);
190 distance[w] = newDistance;
194 queue.
push(w, distance[w]);
215 NodeArray<T>& distance,
bool directed =
false,
bool arcsReversed =
false) {
218 callUnbound(G, weight, sources, predecessor, distance, directed, arcsReversed);
235 T maxLength = std::numeric_limits<T>::max()) {
238 callBound(G, weight, sources, predecessor, distance, directed, arcsReversed, target,
255 bool arcsReversed =
false,
node target =
nullptr,
256 T maxLength = std::numeric_limits<T>::max()) {
257 if (target ==
nullptr && maxLength == std::numeric_limits<T>::max()) {
258 callUnbound(G, weight, sources, predecessor, distance, directed, arcsReversed);
260 callBound(G, weight, sources, predecessor, distance, directed, arcsReversed, target,
277 NodeArray<T>& distance,
bool directed =
false,
bool arcsReversed =
false,
278 node target =
nullptr, T maxLength = std::numeric_limits<T>::max()) {
279 if (target ==
nullptr && maxLength == std::numeric_limits<T>::max()) {
280 callUnbound(G, weight, s, predecessor, distance, directed, arcsReversed);
282 callBound(G, weight, s, predecessor, distance, directed, arcsReversed, target, maxLength);
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Declaration of doubly linked lists and iterators.
Implementation of pairing heap data structure.
Priority queue interface wrapping various heaps.
Basic declarations, included by all source files.
Class for adjacency list elements.
Dijkstra's single source shortest path algorithm.
void call(const Graph &G, const EdgeArray< T > &weight, const List< node > &sources, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed=false, bool arcsReversed=false, node target=nullptr, T maxLength=std::numeric_limits< T >::max())
Calculates, based on the graph G with corresponding edge costs and source nodes, the shortest paths a...
void callUnbound(const Graph &G, const EdgeArray< T > &weight, const List< node > &sources, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed=false, bool arcsReversed=false)
Calculates, based on the graph G with corresponding edge costs and source nodes, the shortest paths a...
void callUnbound(const Graph &G, const EdgeArray< T > &weight, node s, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed=false, bool arcsReversed=false)
Calculates, based on the graph G with corresponding edge costs and a source node s,...
void call(const Graph &G, const EdgeArray< T > &weight, const node s, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed=false, bool arcsReversed=false, node target=nullptr, T maxLength=std::numeric_limits< T >::max())
Calculates, based on the graph G with corresponding edge costs and a source node s,...
void callBound(const Graph &G, const EdgeArray< T > &weight, node s, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed, bool arcsReversed, node target, T maxLength=std::numeric_limits< T >::max())
Calculates, based on the graph G with corresponding edge costs and a source node s,...
void callBound(const Graph &G, const EdgeArray< T > &weight, const List< node > &sources, NodeArray< edge > &predecessor, NodeArray< T > &distance, bool directed, bool arcsReversed, node target, T maxLength=std::numeric_limits< T >::max())
Calculates, based on the graph G with corresponding edge costs and source nodes, the shortest paths a...
EpsilonTest m_eps
For floating point comparisons (if floating point is used)
Class for the representation of edges.
node target() const
Returns the target node of the edge.
std::enable_if< std::is_integral< T >::value, bool >::type greater(const T &x, const T &y) const
Compare if x is GREATER than y for integral types.
Data type for general directed graphs (adjacency list representation).
Doubly linked lists (maintaining the length of the list).
iterator pushBack(const E &x)
Adds element x at the end of the list.
Class for the representation of nodes.
internal::GraphObjectContainer< AdjElement > adjEntries
The container containing all entries in the adjacency list of this node.
Prioritized queue interface wrapper for heaps.
bool empty() const
Checks whether the queue is empty.
void init(const Base *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
void decrease(const E &element, const P &priority)
Decreases the priority of the given element.
bool contains(const E &element) const
Returns whether this queue contains that key.
void pop()
Removes the topmost element from the queue.
void push(const E &element, const P &priority)
Adds a new element to the queue.
const E & topElement() const
Returns the topmost element in the queue.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.