documentationfor yFiles for HTML 3.0.0.3

MaximumFlow

Solves a maximum flow problem.

Inheritance Hierarchy
MaximumFlow

Remarks

The maximum flow problem is an optimization problem that involves finding the maximum flow from source to sink nodes through a network of edges, each with a specified maximum capacity.

The algorithm is an implementation of the preflow-push algorithm (also known as push-relabel algorithm) and is based on

  • Mehlhorn, Naeher: LEDA: a platform for combinatorial and geometric computing, Cambridge University Press, 2000, pp. 443–488.

Other Flow Algorithms

@PRODUCT@ supports another algorithm related to network flow:

  • MinimumCostFlow – Solves a minimum-cost flow problem where a given flow should be routed as cheaply as possible through a graph

Examples

Calculating a maximum flow of the graph
// prepare the maximum flow algorithm
const algorithm = new MaximumFlow({
  sources,
  sinks,
  capacities,
})
// run the algorithm
const result = algorithm.run(graph)

// highlight the partitions and the cut edges
for (const node of result.sourcePartition) {
  graph.setStyle(node, sourcePartitionStyle)
}
for (const node of result.sinkPartition) {
  graph.setStyle(node, sinkPartitionStyle)
}
for (const edge of result.minimumCut) {
  graph.setStyle(edge, cutEdgeStyle)
}
// add labels indicating the actual flow
for (const edge of graph.edges) {
  graph.addLabel(edge, String(result.flow.get(edge)))
}

Type Details

yFiles module
view-layout-bridge

See Also

Constructors

Properties

Methods