The maxFlow action calculates the maximum flow of a graph. The maximum flow problem is a classical network flow problem that involves finding a feasible flow from a single source node to a single sink node that is maximum. This action is useful for modeling problems in logistics, transportation, and communication.
| Parameter | Description |
|---|---|
| deterministic | When set to True, ensures that each invocation (with the same machine configuration and parameter settings) produces the same final result. Default is True. |
| direction | Specifies whether to consider the input graph as directed or undirected. Default is 'UNDIRECTED'. |
| graph | Specifies the in-memory graph to use. |
| links | Specifies the input data table that contains the graph link information. |
| logLevel | Controls the amount of information that is displayed in the SAS log. Can be 'NONE', 'BASIC', 'MODERATE', or 'AGGRESSIVE'. Default is 'BASIC'. |
| outLinks | Specifies the output data table to contain the flow on each link and the cut information. |
| outNodes | Specifies the output data table to contain the cut information for each node. |
| sink | Specifies the sink node for maximum network flow calculations. |
| source | Specifies the source node for maximum network flow calculations. |
This example illustrates calculating the maximum flow between a source node 'S' and a sink node 'T' in a directed graph. The capacity of each link is defined in the 'capacity' variable.
| 1 | DATA mycas.LinkData; |
| 2 | INPUT from $ to $ capacity; |
| 3 | DATALINES; |
| 4 | S A 5 |
| 5 | S B 8 |
| 6 | A C 4 |
| 7 | A D 2 |
| 8 | B D 3 |
| 9 | B E 4 |
| 10 | C T 3 |
| 11 | D T 6 |
| 12 | E T 5 |
| 13 | ; |
| 14 | RUN; |
This example calculates the maximum flow from node 'S' to node 'T'. The total maximum flow value is stored in the macro variable `max_flow_val`.
| 1 | PROC CAS; |
| 2 | optNetwork.maxFlow |
| 3 | links = {name='LinkData'}, |
| 4 | linksVar = {from='from', to='to', weight='capacity'}, |
| 5 | SOURCE = 'S', |
| 6 | sink = 'T'; |
| 7 | RUN; |
| 8 | QUIT; |
| 9 | %put Maximum Flow = &_OROPTNET_MAXFLOW_; |
This example calculates the maximum flow and outputs two tables: `FlowNetwork` and `MinCutNodes`. The `FlowNetwork` table shows the flow on each link, and `MinCutNodes` identifies the nodes in the source-side of the minimum cut.
| 1 | PROC CAS; |
| 2 | optNetwork.maxFlow |
| 3 | links = {name='LinkData'}, |
| 4 | linksVar = {from='from', to='to', weight='capacity'}, |
| 5 | SOURCE = 'S', |
| 6 | sink = 'T', |
| 7 | outLinks = {name='FlowNetwork', replace=true}, |
| 8 | outNodes = {name='MinCutNodes', replace=true}; |
| 9 | RUN; |
| 10 | PROC PRINT DATA=mycas.FlowNetwork; |
| 11 | RUN; |
| 12 | PROC PRINT DATA=mycas.MinCutNodes; |
| 13 | RUN; |