|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
59 template<
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()) {
114 for (
adjEntry adj : v->adjEntries) {
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()) {
174 for (
adjEntry adj : v->adjEntries) {
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);
The namespace for all OGDF objects.
Compare floating point numbers with epsilons and integral numbers with normal compare operators.
Includes declaration of graph class.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
void pop()
Removes the topmost element from the queue.
Priority queue interface wrapping various heaps.
void push(const E &element, const P &priority)
Adds a new element to the queue.
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 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...
bool contains(const E &element) const
Returns whether this queue contains that key.
Class for adjacency list elements.
Dijkstra's single source shortest path algorithm.
edge theEdge() const
Returns the edge associated with this adjacency entry.
bool empty() const
Checks whether the queue is empty.
Decralation of GraphElement and GraphList classes.
Prioritized queue interface wrapper for heaps.
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...
Doubly linked lists (maintaining the length of the list).
RegisteredArray for nodes, edges and adjEntries of a graph.
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,...
Data type for general directed graphs (adjacency list representation).
Implementation of pairing heap data structure.
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.
const E & topElement() const
Returns the topmost element in the queue.
EpsilonTest m_eps
For floating point comparisons (if floating point is used)
node twinNode() const
Returns the associated node of the corresponding adjacency entry (shorthand for twin()->theNode()).
void decrease(const E &element, const P &priority)
Decreases the priority of the given element.
Basic declarations, included by all source files.
Class for the representation of edges.
Declaration of doubly linked lists and iterators.
void init(const Graph *base=nullptr)
Reinitializes the array. Associates the array with the matching registry of base.
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,...
node target() const
Returns the target node of the edge.
Class for the representation of nodes.
iterator pushBack(const E &x)
Adds element x at the end of the list.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.