pgr_maxFlowMinCost_Cost - Experimental - pgRouting Manual (3.2)
pgr_maxFlowMinCost_Cost - Experimental
   
    
     pgr_maxFlowMinCost_Cost
    
   
   - Calculates the minmum cost maximum flow in a directed graph from the source(s) to the targets(s).
  
   
   Warning
Possible server crash
- 
     
These functions might create a server crash
 
Warning
Experimental functions
- 
     
They are not officially of the current release.
 - 
     
They likely will not be officially be part of the next release:
- 
       
The functions might not make use of ANY-INTEGER and ANY-NUMERICAL
 - 
       
Name might change.
 - 
       
Signature might change.
 - 
       
Functionality might change.
 - 
       
pgTap tests might be missing.
 - 
       
Might need c/c++ coding.
 - 
       
May lack documentation.
 - 
       
Documentation if any might need to be rewritten.
 - 
       
Documentation examples might need to be automatically generated.
 - 
       
Might need a lot of feedback from the comunity.
 - 
       
Might depend on a proposed function of pgRouting
 - 
       
Might depend on a deprecated function of pgRouting
 
 - 
       
 
Availability
- 
    
Version 3.2.0
- 
      
New experimental function:
- 
        
pgr_maxFlowMinCost_Cost(Combinations)
 
 - 
        
 
 - 
      
 - 
    
Version 3.0.0
- 
      
New experimental function
 
 - 
      
 
Description
The main characteristics are:
- 
     
The graph is directed .
 - 
     
The cost value of all input edges must be nonnegative.
 - 
     
When the maximum flow is 0 then there is no flow and 0 is returned.
- 
       
There is no flow when a source is the same as a target .
 
 - 
       
 - 
     
Any duplicated value in the source(s) or target(s) are ignored.
 - 
     
Uses the pgr_maxFlowMinCost algorithm.
 
- 
     
Running time: \(O(U * (E + V * logV))\) , where \(U\) is the value of the max flow. \(U\) is upper bound on number of iteration. In many real world cases number of iterations is much smaller than \(U\) .
 
Signatures
Summary
pgr_maxFlowMinCost_Cost(Edges SQL, source, target)
pgr_maxFlowMinCost_Cost(Edges SQL, sources, target)
pgr_maxFlowMinCost_Cost(Edges SQL, source, targets)
pgr_maxFlowMinCost_Cost(Edges SQL, sources, targets)
pgr_maxFlowMinCost_Cost(Edges SQL, Combinations SQL) -- Experimental on v3.2
RETURNS FLOAT
    One to One
pgr_maxFlowMinCost_Cost(Edges SQL, source, target)
RETURNS FLOAT
     - Example :
 - 
      
From vertex \(2\) to vertex \(3\)
 
SELECT * FROM pgr_MaxFlowMinCost_Cost(
    'SELECT id,
     source, target,
     capacity, reverse_capacity,
     cost, reverse_cost FROM edge_table',
    2, 3
);
 pgr_maxflowmincost_cost
-------------------------
                     400
(1 row)
     One to Many
pgr_maxFlowMinCost_Cost(Edges SQL, source, targets)
RETURNS FLOAT
     - Example :
 - 
      
From vertex \(13\) to vertices \(\{7, 1, 4\}\)
 
SELECT * FROM pgr_MaxFlowMinCost_Cost(
    'SELECT id,
     source, target,
     capacity, reverse_capacity,
     cost, reverse_cost FROM edge_table',
    13, ARRAY[7, 1, 4]
);
 pgr_maxflowmincost_cost
-------------------------
                     450
(1 row)
     Many to One
pgr_maxFlowMinCost_Cost(Edges SQL, sources, target)
RETURNS FLOAT
     - Example :
 - 
      
From vertices \(\{1, 7, 14\}\) to vertex \(12\)
 
SELECT * FROM pgr_MaxFlowMinCost_Cost(
    'SELECT id,
     source, target,
     capacity, reverse_capacity,
     cost, reverse_cost FROM edge_table',
    ARRAY[1, 7, 14], 12
);
 pgr_maxflowmincost_cost
-------------------------
                     650
(1 row)
     Many to Many
pgr_maxFlowMinCost_Cost(Edges SQL, sources, targets)
RETURNS FLOAT
     - Example :
 - 
      
From vertices \(\{7, 13\}\) to vertices \(\{3, 9\}\)
 
SELECT * FROM pgr_MaxFlowMinCost_Cost(
    'SELECT id,
     source, target,
     capacity, reverse_capacity,
     cost, reverse_cost FROM edge_table',
    ARRAY[7, 13], ARRAY[3, 9]
);
 pgr_maxflowmincost_cost
-------------------------
                     600
(1 row)
     Combinations
pgr_maxFlowMinCost_Cost(Edges SQL, Combinations SQL)
RETURNS FLOAT
     - Example :
 - 
      
Using a combinations table, equivalent to calculating result from vertices \(\{7, 13\}\) to vertices \(\{3, 9\}\) .
 
SELECT * FROM pgr_MaxFlowMinCost_Cost(
    'SELECT id,
     source, target,
     capacity, reverse_capacity,
     cost, reverse_cost FROM edge_table',
    'SELECT * FROM ( VALUES (7, 3), (13, 9) ) AS t(source, target)'
);
 pgr_maxflowmincost_cost
-------------------------
                     600
(1 row)
     Parameters
| 
        Column  | 
      
        Type  | 
      
        Default  | 
      
        Description  | 
     
|---|---|---|---|
| 
        Edges SQL  | 
      
        
          | 
      
        Edges query as described in Inner Queries .  | 
     |
| 
        Combinations SQL  | 
      
        
          | 
      
        Combinations query as described in Inner Queries .  | 
     |
| 
        source  | 
      
        
          | 
      
        Identifier of the starting vertex of the flow.  | 
     |
| 
        sources  | 
      
        
          | 
      
        Array of identifiers of the starting vertices of the flow.  | 
     |
| 
        target  | 
      
        
          | 
      
        Identifier of the ending vertex of the flow.  | 
     |
| 
        targets  | 
      
        
          | 
      
        Array of identifiers of the ending vertices of the flow.  | 
     
Inner queries
- Edges SQL :
 - 
     
an SQL query of a directed graph of capacities, which should return a set of rows with the following columns:
 
| 
        Column  | 
      
        Type  | 
      
        Default  | 
      
        Description  | 
     
|---|---|---|---|
| 
        id  | 
      
        
          | 
      
        Identifier of the edge.  | 
     |
| 
        source  | 
      
        
          | 
      
        Identifier of the first end point vertex of the edge.  | 
     |
| 
        target  | 
      
        
          | 
      
        Identifier of the second end point vertex of the edge.  | 
     |
| 
        capacity  | 
      
        
          | 
      
        Capacity of the edge (source, target) 
  | 
     |
| 
        reverse_capacity  | 
      
        
          | 
      
        -1  | 
      
        Capacity of the edge (target, source) , 
  | 
     
| 
        cost  | 
      
        
          | 
      
        Weight of the edge (source, target) if it exists.  | 
     |
| 
        reverse_cost  | 
      
        
          | 
      
        0  | 
      
        Weight of the edge (target, source) if it exists.  | 
     
Where:
- ANY-INTEGER :
 - 
     
SMALLINT, INTEGER, BIGINT
 - ANY-NUMERICAL :
 - 
     
smallint, int, bigint, real, float
 
- Combinations SQL :
 - 
     
an SQL query which should return a set of rows with the following columns:
 
| 
        Column  | 
      
        Type  | 
      
        Default  | 
      
        Description  | 
     
|---|---|---|---|
| 
        source  | 
      
        
          | 
      
        Identifier of the first end point vertex of the edge.  | 
     |
| 
        target  | 
      
        
          | 
      
        Identifier of the second end point vertex of the edge.  | 
     
Where:
- ANY-INTEGER :
 - 
     
SMALLINT, INTEGER, BIGINT
 
The function aggregates the sources and the targets, removes the duplicates, and then it calculates the result from the resultant source vertices to the target vertices.
Result Columns
| 
        Type  | 
      
        Description  | 
     
|---|---|
| 
        
          | 
      
        Minimum Cost Maximum Flow possible from the source(s) to the target(s)  | 
     
See Also
Indices and tables