pgr_maxFlow
— Calculates the maximum flow in a directed graph given source(s) and sink(s).
Warning
These are proposed functions
Calculates the maximum flow in a directed graph from a source node to a sink node.
pgr_maxFlow(edges_sql, source_vertex, sink_vertex)
pgr_maxFlow(edges_sql, source_vertices, sink_vertex)
pgr_maxFlow(edges_sql, source_vertex, sink_vertices)
pgr_maxFlow(edges_sql, source_vertices, sink_vertices)
RETURNS BIGINT
Calculates the maximum flow from one source vertex to one sink vertex in a directed graph.
pgr_maxFlow(edges_sql, source_vertex, sink_vertex)
RETURNS BIGINT
Example: |
---|
SELECT * FROM pgr_maxFlow(
'SELECT id,
source,
target,
c1.capacity as capacity,
c2.capacity as reverse_capacity
FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
WHERE edge_table.reverse_category_id = c2.category_id
ORDER BY id'
, 6, 11
);
pgr_maxflow
-------------
280
(1 row)
Ccalculates the maximum flow from one source vertex to many sink vertices in a directed graph.
pgr_maxFlow(edges_sql, source_vertex, sink_vertices)
RETURNS BIGINT
Example: |
---|
SELECT * FROM pgr_maxFlow(
'SELECT id,
source,
target,
c1.capacity as capacity,
c2.capacity as reverse_capacity
FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
WHERE edge_table.reverse_category_id = c2.category_id
ORDER BY id'
, 6, ARRAY[11, 1, 13]
);
pgr_maxflow
-------------
410
(1 row)
Calculates the maximum flow from many source vertices to one sink vertex in a directed graph.
pgr_maxFlow(edges_sql, source_vertices, sink_vertex)
RETURNS BIGINT
Example: |
---|
SELECT * FROM pgr_maxFlow(
'SELECT id,
source,
target,
c1.capacity as capacity,
c2.capacity as reverse_capacity
FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
WHERE edge_table.reverse_category_id = c2.category_id
ORDER BY id'
, ARRAY[6, 8, 12], 11
);
pgr_maxflow
-------------
280
(1 row)
Calculates the maximum flow from many sources to many sinks in a directed graph.
pgr_maxFlow(edges_sql, source_vertices, sink_vertices)
RETURNS BIGINT
Example: |
---|
SELECT * FROM pgr_maxFlow(
'SELECT id,
source,
target,
c1.capacity as capacity,
c2.capacity as reverse_capacity
FROM edge_table JOIN categories AS c1 USING(category_id), categories AS c2
WHERE edge_table.reverse_category_id = c2.category_id
ORDER BY id'
, ARRAY[6, 8, 12], ARRAY[1, 3, 11]
);
pgr_maxflow
-------------
460
(1 row)
edges_sql: | an SQL query, which should return a set of rows with the following columns: |
---|
Column | Type | Description |
---|---|---|
id | ANY-INTEGER |
Identifier of the edge. |
source | ANY-INTEGER |
Identifier of the first end point vertex of the edge. |
target | ANY-INTEGER |
Identifier of the second end point vertex of the edge. |
capacity | ANY-INTEGER |
Capacity of the edge (source, target). Must be positive. |
reverse_capacity | ANY-INTEGER |
(optional) Weight of the edge (target, source). Must be positive or null. |
Where:
ANY-INTEGER: | SMALLINT, INTEGER, BIGINT |
---|
Column | Type | Description |
---|---|---|
edges_sql | TEXT |
SQL query as described above. |
source_vertex | BIGINT |
Identifier of the source vertex(or vertices). |
sink_vertex | BIGINT |
Identifier of the sink vertex(or vertices). |