networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
cost_of_flow(G, flowDict, weight='weight')

Note that this function does not check for the validity of the flow flowDict. This function will fail if the graph G and the flow don't have the same edge set.

Notes

This algorithm is not guaranteed to work if edge weights or demands are floating point numbers (overflows and roundoff errors can cause problems). As a workaround you can use integer numbers by multiplying the relevant edge attributes by a convenient constant factor (eg 100).

Parameters

G : NetworkX graph

DiGraph on which a minimum cost flow satisfying all demands is to be found.

weight : string

Edges of the graph G are expected to have an attribute weight that indicates the cost incurred by sending one unit of flow on that edge. If not present, the weight is considered to be 0. Default value: 'weight'.

flowDict : dictionary

Dictionary of dictionaries keyed by nodes such that flowDict[u][v] is the flow edge (u, v).

Returns

cost : Integer, float

The total cost of the flow. This is given by the sum over all edges of the product of the edge's flow and the edge's weight.

Compute the cost of the flow given by flowDict on graph G.

See Also

max_flow_min_cost
min_cost_flow
min_cost_flow_cost
network_simplex

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.flow.mincost.min_cost_flow_cost networkx.algorithms.flow.networksimplex.network_simplex networkx.algorithms.flow.mincost.max_flow_min_cost networkx.algorithms.flow.mincost.min_cost_flow

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/flow/mincost.py#187
type: <class 'function'>
Commit: