Solves a minimum-cost flow problem.
Remarks
The minimum-cost flow problem is an optimization problem to find the cheapest possible way of sending a certain amount of flow through a network with capacities and costs.
There are three main ways of using this class, depending on how the problem to solve is stated. All variants require the maximumCapacities and costs.
- There can be minimumCapacities for edges as well as the maximumCapacities. In this variant supply is considered for defining supply/demand for nodes in the network, while source and sink are ignored.
- A source and sink node can be provided, in which case supply is ignored.
- As a third option, multiple nodes can have specific values for supply and demand configured via supply.
Other Flow Algorithms
yFiles for HTML supports another algorithm related to network flow:
- MaximumFlow – solves a maximum flow problem where the largest possible flow through a network should be determined
Examples
Type Details
- yfiles module
- view-layout-bridge
- yfiles-umd modules
- view-layout-bridge
- Legacy UMD name
- yfiles.analysis.MinimumCostFlow
See Also
Constructors
Creates a new MinimumCostFlow instance.
Parameters
A map of options to pass to the method.
- minimumCapacities - ItemMapping<IEdge,number>
A mapping for the minimum capacities of edges. This option sets the minimumCapacities property on the created object.
- maximumCapacities - ItemMapping<IEdge,number>
A mapping for maximum capacities of edges. This option sets the maximumCapacities property on the created object.
- costs - ItemMapping<IEdge,number>
A mapping for edge costs. This option sets the costs property on the created object.
- supply - ItemMapping<INode,number>
A mapping which provides the supply (or demand, if negative) for each node. This option sets the supply property on the created object.
- source - SingleItem<INode>
A single source node. This option sets the source property on the created object.
- sink - SingleItem<INode>
A single sink node. This option sets the sink property on the created object.
- subgraphNodes - ItemCollection<INode>
The collection of nodes which define a subset of the graph for the algorithms to work on. This option sets the subgraphNodes property on the created object.
- subgraphEdges - ItemCollection<IEdge>
The collection of edges which define a subset of the graph for the algorithms to work on. This option sets the subgraphEdges property on the created object.
Properties
Gets or sets a mapping for edge costs.
Remarks
See Also
Gets or sets a mapping for maximum capacities of edges.
Remarks
See Also
Gets or sets a mapping for the minimum capacities of edges.
See Also
Gets or sets a single sink node.
Remarks
See Also
Gets or sets a single source node.
Remarks
See Also
Gets or sets the collection of edges which define a subset of the graph for the algorithms to work on.
Remarks
If nothing is set, all edges of the graph will be processed.
If only the excludes are set all edges in the graph except those provided in the excludes are processed.
Note that edges which start or end at nodes which are not in the subgraphNodes are automatically not considered by the algorithm.
ItemCollection<T> instances may be shared among algorithm instances and will be (re-)evaluated upon (re-)execution of the algorithm.
Examples
Gets or sets the collection of nodes which define a subset of the graph for the algorithms to work on.
Remarks
If nothing is set, all nodes of the graph will be processed.
If only the excludes are set all nodes in the graph except those provided in the excludes are processed.
ItemCollection<T> instances may be shared among algorithm instances and will be (re-)evaluated upon (re-)execution of the algorithm.
Examples
Gets or sets a mapping which provides the supply (or demand, if negative) for each node.
Remarks
Nodes with a positive supply effectively act as additional sources, while nodes with a negative supply (demand) effectively act as additional sinks. However, both can appear anywhere in the network.
This value is ignored if both a source and sink node but no minimumCapacities are provided.
If no source or sink or neither of them are provided it is mandatory to provide a valid supply map.
See Also
Methods
Solves the minimum-cost flow problem.
Parameters
A map of options to pass to the method.
- graph - IGraph
- The input graph to run the algorithm on.
Returns
- ↪MinimumCostFlowResult
- A MinimumCostFlowResult containing the flow for each edge and the total cost.
Throws
- Exception({ name: 'InvalidOperationError' })
- If the algorithm can't create a valid result due to an invalid graph structure or wrongly configured properties.