Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

FullComponentGeneratorCaller.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 
37 namespace ogdf {
38 namespace steiner_tree {
39 
40 template<typename T>
42 public:
45  const EdgeWeightedGraph<T>& graph,
46  const List<node>& terminals,
47  const NodeArray<bool>& isTerminal,
48  int restricted);
49 };
50 
51 template<typename T>
53  const EdgeWeightedGraph<T>& graph,
54  const List<node>& terminals,
55  const NodeArray<bool>& isTerminal,
56  int restricted) {
57  if (steiner_tree::FullComponentDecisions::shouldUseDijkstra(restricted, graph.numberOfNodes(), graph.numberOfEdges(), terminals.size())) {
58  if (restricted <= 3) {
59  // for 2- and 3-restricted computations, it is ok to use SSSP from all terminals
60  MinSteinerTreeModule<T>::allTerminalShortestPaths(graph, terminals, isTerminal, distance, pred);
61  } else {
62  MinSteinerTreeModule<T>::allNodeShortestPaths(graph, terminals, isTerminal, distance, pred);
63  }
64  } else {
65  MinSteinerTreeModule<T>::allPairShortestPaths(graph, isTerminal, distance, pred);
66  }
67 }
68 
69 }
70 }
static void allPairShortestPaths(const EdgeWeightedGraph< T > &G, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T >> &distance, NodeArray< NodeArray< edge >> &pred)
The default all-pair-shortest-paths algorithm.
Declaration of ogdf::MinSteinerTreeModule.
Definition of the FullComponentDecisions class.
static void allNodeShortestPaths(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T >> &distance, NodeArray< NodeArray< edge >> &pred, std::function< void(const EdgeWeightedGraph< T > &, node, const NodeArray< bool > &, NodeArray< T > &, NodeArray< edge > &)> ssspFunc=singleSourceShortestPaths)
Runs a given (or the default) single-source-shortest-paths function from all nodes.
static void computeDistanceMatrix(NodeArray< NodeArray< T >> &distance, NodeArray< NodeArray< edge >> &pred, const EdgeWeightedGraph< T > &graph, const List< node > &terminals, const NodeArray< bool > &isTerminal, int restricted)
Computes distance and predecessor matrix.
int numberOfEdges() const
Returns the number of edges in the graph.
Definition: Graph_d.h:601
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
static bool shouldUseDijkstra(int k, int n, int m, int t)
Returns true iff the rule of thumb predicts to use multiple Dijkstra calls instead of the algorithm b...
int size() const
Returns the number of elements in the list.
Definition: List.h:1312
static void allTerminalShortestPaths(const EdgeWeightedGraph< T > &G, const List< node > &terminals, const NodeArray< bool > &isTerminal, NodeArray< NodeArray< T >> &distance, NodeArray< NodeArray< edge >> &pred, std::function< void(const EdgeWeightedGraph< T > &, node, const NodeArray< bool > &, NodeArray< T > &, NodeArray< edge > &)> ssspFunc=singleSourceShortestPaths)
Runs a given (or the default) single-source-shortest-paths function from all terminals.
The namespace for all OGDF objects.
int numberOfNodes() const
Returns the number of nodes in the graph.
Definition: Graph_d.h:598