Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

ConnectivityTester.h
Go to the documentation of this file.
1 
32 #pragma once
33 
36 #include <ogdf/basic/GraphCopy.h>
37 
38 namespace ogdf {
39 
48 private:
54  bool m_directed;
55  const Graph *m_graph;
56 
64  void prepareGraph(const Graph &graph);
65 
72  int computeConnectivity(node v, node u);
73 
82  int computeConnectivity(NodeArray<NodeArray<int>> &result);
83 
89  void duplicateEdges(Graph &graph);
90 
97  void restrictNodes(Graph &graph);
98 
106  node copyOf(node v, bool isSource = false) const;
107 
108 public:
115  explicit ConnectivityTester(bool nodeConnectivity = true, bool directed = false) :
116  ConnectivityTester(new MaxFlowGoldbergTarjan<int>(), nodeConnectivity, directed) {
117  m_usingDefaultMaxFlow = true;
118  }
119 
127  ConnectivityTester(MaxFlowModule<int> *flowAlgo, bool nodeConnectivity = true, bool directed = false) :
128  m_flowAlgo(flowAlgo),
129  m_source(nullptr),
130  m_usingDefaultMaxFlow(false),
131  m_graphCopied(false),
132  m_nodeConnectivity(nodeConnectivity),
133  m_directed(directed),
134  m_graph(nullptr) {
135  }
136 
141  if (m_usingDefaultMaxFlow) {
142  delete m_flowAlgo;
143  }
144 
145  if (m_graphCopied) {
146  delete m_graph;
147  }
148 
149  delete m_source;
150  }
151 
161  int computeConnectivity(const Graph &graph, node v, node u) {
162  prepareGraph(graph);
163 
164  return computeConnectivity(copyOf(v, true), copyOf(u));
165  }
166 
176  int computeConnectivity(const Graph &graph, NodeArray<NodeArray<int>> &result) {
177  prepareGraph(graph);
178 
179  return computeConnectivity(result);
180  }
181 };
182 
183 }
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
Interface for Max Flow Algorithms.
int computeConnectivity(const Graph &graph, NodeArray< NodeArray< int >> &result)
Computes the connectivity of all nodes of the provided graph.
Declaration and implementation of Goldberg-Tarjan max-flow algorithm with global relabeling and gap r...
NodeArray< node > * m_source
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
Declaration of graph copy classes.
ConnectivityTester(MaxFlowModule< int > *flowAlgo, bool nodeConnectivity=true, bool directed=false)
Initializes a new onnectivity tester using a custom ogdf::MaxFlowModule.
Naive implementation for testing the connectivity of a graph.
int computeConnectivity(const Graph &graph, node v, node u)
Computes the connectivity of two nodes.
Class for the representation of nodes.
Definition: Graph_d.h:169
ConnectivityTester(bool nodeConnectivity=true, bool directed=false)
Initializes a new connectivity tester using ogdf::MaxFlowGoldbergTarjan.
~ConnectivityTester()
Destroys the connectivity tester and frees allocated memory.
The namespace for all OGDF objects.
MaxFlowModule< int > * m_flowAlgo
Computes a max flow via Preflow-Push (global relabeling and gap relabeling heuristic).