Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
maxflow_ff Class Reference

Maximum flow algorithm (Edmonds-Karp). More...

#include <JETSCAPE/blob/main/external_packages/gtl/include/GTL/maxflow_ff.h>

+ Inheritance diagram for maxflow_ff:
+ Collaboration diagram for maxflow_ff:

Public Member Functions

 maxflow_ff ()
 
virtual ~maxflow_ff ()
 
void set_vars (const edge_map< double > &edge_capacity)
 
void set_vars (const edge_map< double > &edge_capacity, const node &net_source, const node &net_target)
 
virtual int check (graph &G)
 
int run (graph &G)
 
double get_max_flow (const edge &e) const
 
double get_max_flow () const
 
double get_rem_cap (const edge &e) const
 
virtual void reset ()
 
- Public Member Functions inherited from algorithm
 algorithm ()
 Creates an algorithm object.
 
virtual ~algorithm ()
 Destroys the algorithm object.
 

Protected Types

enum  { SP_FOUND = 2, NO_SP_FOUND = 3 }
 

Protected Member Functions

void create_artif_source_target (graph &G)
 
void prepare_run (const graph &G)
 
void comp_single_flow (graph &G, node_map< edge > &last_edge)
 
int get_sp (const graph &G, node_map< edge > &last_edge)
 
int comp_sp (const graph &G, queue< node > &next_nodes, node_map< bool > &visited, node_map< edge > &last_edge)
 
double extra_charge (const node_map< edge > &last_edge) const
 
void create_back_edge (graph &G, const edge &org_edge)
 
void comp_max_flow (const graph &G)
 
void restore_graph (graph &G)
 

Protected Attributes

bool artif_source_target
 
bool set_vars_executed
 
double max_graph_flow
 
node net_source
 
node net_target
 
list< edgeedges_not_org
 
edge_map< bool > edge_org
 
edge_map< bool > back_edge_exists
 
edge_map< edgeback_edge
 
edge_map< doubleedge_capacity
 
edge_map< doubleedge_max_flow
 

Additional Inherited Members

- Public Types inherited from algorithm
enum  { GTL_OK = 1, GTL_ERROR = 0 }
 Return values for algorithm::check and algorithm::run. More...
 

Detailed Description

Maximum flow algorithm (Edmonds-Karp).

Definition at line 25 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 25 of file maxflow_ff.h

Member Enumeration Documentation

anonymous enum
protected
Enumerator:
SP_FOUND 
NO_SP_FOUND 

Definition at line 127 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 127 of file maxflow_ff.h

Constructor & Destructor Documentation

__GTL_BEGIN_NAMESPACE maxflow_ff::maxflow_ff ( )

Default constructor. Enables only the calculation of maximum flow.

See Also
algorithm::algorithm

Definition at line 28 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 28 of file maxflow_ff.cpp

References max_graph_flow, and set_vars_executed.

maxflow_ff::~maxflow_ff ( )
virtual

Destructor.

See Also
algorithm::~algorithm

Definition at line 35 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 35 of file maxflow_ff.cpp

Member Function Documentation

int maxflow_ff::check ( graph G)
virtual

Checks whether following preconditions are satisfied:

  • maxflow_ff::set_vars has been executed before.
  • only edge_capacities >= 0 are applied.
  • G is directed.
  • G is connected.
  • G has at least one edge and two nodes.
  • if not applied, start-nodes and end-nodes exists.
  • if applied, start-node is not the same node as end-node.
Parameters
Ggraph
Returns
algorithm::GTL_OK on success algorithm::GTL_ERROR otherwise
See Also
algorithm::check

Implements algorithm.

Definition at line 61 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 61 of file maxflow_ff.cpp

References artif_source_target, edge_capacity, graph::edges_begin(), graph::edges_end(), algorithm::GTL_ERROR, algorithm::GTL_OK, graph::is_connected(), graph::is_undirected(), net_source, net_target, graph::nodes_begin(), graph::nodes_end(), graph::number_of_nodes(), and set_vars_executed.

+ Here is the call graph for this function:

void maxflow_ff::comp_max_flow ( const graph G)
protected

Definition at line 328 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 328 of file maxflow_ff.cpp

References edge_max_flow, max_graph_flow, net_source, node::out_edges_begin(), and node::out_edges_end().

Referenced by restore_graph().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void maxflow_ff::comp_single_flow ( graph G,
node_map< edge > &  last_edge 
)
protected

Definition at line 207 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 207 of file maxflow_ff.cpp

References back_edge, back_edge_exists, create_back_edge(), edge_capacity, edge_max_flow, edge_org, extra_charge(), graph::hide_edge(), net_source, net_target, and graph::restore_edge().

Referenced by run().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int maxflow_ff::comp_sp ( const graph G,
queue< node > &  next_nodes,
node_map< bool > &  visited,
node_map< edge > &  last_edge 
)
protected

Definition at line 259 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 259 of file maxflow_ff.cpp

References net_target, next, NO_SP_FOUND, node::out_edges_begin(), node::out_edges_end(), and SP_FOUND.

Referenced by get_sp().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void maxflow_ff::create_artif_source_target ( graph G)
protected

Definition at line 160 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 160 of file maxflow_ff.cpp

References Acts::UnitConstants::e, edge_capacity, node::indeg(), net_source, net_target, graph::new_edge(), graph::new_node(), graph::nodes_begin(), graph::nodes_end(), and node::outdeg().

Referenced by run().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void maxflow_ff::create_back_edge ( graph G,
const edge org_edge 
)
protected

Definition at line 314 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 314 of file maxflow_ff.cpp

References back_edge, back_edge_exists, edge_capacity, edge_max_flow, edge_org, edges_not_org, graph::new_edge(), edge::source(), and edge::target().

Referenced by comp_single_flow().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double maxflow_ff::extra_charge ( const node_map< edge > &  last_edge) const
protected

Definition at line 294 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 294 of file maxflow_ff.cpp

References edge_capacity, edge_max_flow, net_source, and net_target.

Referenced by comp_single_flow().

+ Here is the caller graph for this function:

double maxflow_ff::get_max_flow ( const edge e) const

Returns the maximum flow of an edge.

Parameters
eedge of a graph G
Returns
maximum flow value

Definition at line 137 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 137 of file maxflow_ff.cpp

References edge_max_flow.

double maxflow_ff::get_max_flow ( ) const

Returns the maximum flow of the whole graph G.

Returns
maximum flow value

Definition at line 143 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 143 of file maxflow_ff.cpp

References max_graph_flow.

double maxflow_ff::get_rem_cap ( const edge e) const

Returns the remaining free capacity of an edge.

Parameters
eedge of a graph G
Returns
remaining capacity

Definition at line 149 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 149 of file maxflow_ff.cpp

References edge_capacity, and edge_max_flow.

int maxflow_ff::get_sp ( const graph G,
node_map< edge > &  last_edge 
)
protected

Definition at line 241 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 241 of file maxflow_ff.cpp

References comp_sp(), net_source, NO_SP_FOUND, and SP_FOUND.

Referenced by run().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void maxflow_ff::prepare_run ( const graph G)
protected

Definition at line 198 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 198 of file maxflow_ff.cpp

References back_edge_exists, edge_max_flow, edge_org, ne_map< Key, Value, Graph, Alloc >::init(), and max_graph_flow.

Referenced by run().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void maxflow_ff::reset ( )
virtual

Resets maximum flow algorithm, i.e. prepares the algorithm to be applied to another graph.

See Also
algorithm::reset

Implements algorithm.

Definition at line 155 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 155 of file maxflow_ff.cpp

void maxflow_ff::restore_graph ( graph G)
protected

Definition at line 342 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 342 of file maxflow_ff.cpp

References artif_source_target, comp_max_flow(), graph::del_edge(), graph::del_node(), edges_not_org, net_source, net_target, and graph::restore_graph().

Referenced by run().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int maxflow_ff::run ( graph G)
virtual

Computes maximum flow of graph G.

Parameters
Ggraph
Returns
algorithm::GTL_OK on success algorithm::GTL_ERROR otherwise
See Also
algorithm::run

Implements algorithm.

Definition at line 116 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 116 of file maxflow_ff.cpp

References artif_source_target, comp_single_flow(), create_artif_source_target(), get_sp(), algorithm::GTL_OK, prepare_run(), restore_graph(), and SP_FOUND.

+ Here is the call graph for this function:

void maxflow_ff::set_vars ( const edge_map< double > &  edge_capacity)

Sets capacity of every edge for maximum flow calculation where artificial start-node and end_node will be computed automatically.

Parameters
edge_capacitycapacity of every edge

Definition at line 40 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 40 of file maxflow_ff.cpp

References artif_source_target, edge_capacity, max_graph_flow, and set_vars_executed.

void maxflow_ff::set_vars ( const edge_map< double > &  edge_capacity,
const node net_source,
const node net_target 
)

Sets capacity of every edge for maximum flow calculation

Parameters
edge_capacitycapacity of every edge
net_sourcestart-node
net_targetend-node

Definition at line 49 of file maxflow_ff.cpp.

View newest version in sPHENIX GitHub at line 49 of file maxflow_ff.cpp

References artif_source_target, edge_capacity, max_graph_flow, net_source, net_target, and set_vars_executed.

Member Data Documentation

bool maxflow_ff::artif_source_target
protected

Definition at line 132 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 132 of file maxflow_ff.h

Referenced by check(), restore_graph(), run(), and set_vars().

edge_map<edge> maxflow_ff::back_edge
protected

Definition at line 172 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 172 of file maxflow_ff.h

Referenced by comp_single_flow(), and create_back_edge().

edge_map<bool> maxflow_ff::back_edge_exists
protected

Definition at line 167 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 167 of file maxflow_ff.h

Referenced by comp_single_flow(), create_back_edge(), and prepare_run().

edge_map<double> maxflow_ff::edge_capacity
protected

Definition at line 177 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 177 of file maxflow_ff.h

Referenced by check(), comp_single_flow(), create_artif_source_target(), create_back_edge(), extra_charge(), get_rem_cap(), and set_vars().

edge_map<double> maxflow_ff::edge_max_flow
protected

Definition at line 182 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 182 of file maxflow_ff.h

Referenced by comp_max_flow(), comp_single_flow(), create_back_edge(), extra_charge(), get_max_flow(), get_rem_cap(), and prepare_run().

edge_map<bool> maxflow_ff::edge_org
protected

Definition at line 162 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 162 of file maxflow_ff.h

Referenced by comp_single_flow(), create_back_edge(), and prepare_run().

list<edge> maxflow_ff::edges_not_org
protected

Definition at line 157 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 157 of file maxflow_ff.h

Referenced by create_back_edge(), and restore_graph().

double maxflow_ff::max_graph_flow
protected

Definition at line 142 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 142 of file maxflow_ff.h

Referenced by comp_max_flow(), get_max_flow(), maxflow_ff(), prepare_run(), and set_vars().

node maxflow_ff::net_source
protected

Definition at line 147 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 147 of file maxflow_ff.h

Referenced by check(), comp_max_flow(), comp_single_flow(), create_artif_source_target(), extra_charge(), get_sp(), restore_graph(), and set_vars().

node maxflow_ff::net_target
protected

Definition at line 152 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 152 of file maxflow_ff.h

Referenced by check(), comp_single_flow(), comp_sp(), create_artif_source_target(), extra_charge(), restore_graph(), and set_vars().

bool maxflow_ff::set_vars_executed
protected

Definition at line 137 of file maxflow_ff.h.

View newest version in sPHENIX GitHub at line 137 of file maxflow_ff.h

Referenced by check(), maxflow_ff(), and set_vars().


The documentation for this class was generated from the following files: