Yog.Flow.MaxFlowResult (YogEx v0.70.0)

Copy Markdown View Source

Result of maximum flow computation (Edmonds-Karp, etc.).

Contains the maximum flow value and the residual graph, which can be used to extract the minimum cut.

Fields

  • max_flow - The maximum flow value from source to sink
  • residual_graph - The residual graph after flow computation
  • source - The source node ID
  • sink - The sink node ID
  • algorithm - Name of the algorithm used (optional)
  • metadata - Optional metadata (iterations, time, etc.)

Examples

iex> result = %Yog.Flow.MaxFlowResult{
...>   max_flow: 15,
...>   residual_graph: graph,
...>   source: 1,
...>   sink: 4,
...>   algorithm: :edmonds_karp
...> }
iex> result.max_flow
15

Summary

Functions

Backward compatibility: convert from legacy map format.

Creates a new max flow result.

Creates a new max flow result with algorithm name.

Get flow value on a specific edge in the residual graph.

Convert to legacy map format.

Types

t()

@type t() :: %Yog.Flow.MaxFlowResult{
  algorithm: atom(),
  max_flow: number(),
  metadata: map(),
  residual_graph: Yog.graph(),
  sink: Yog.Model.node_id(),
  source: Yog.Model.node_id()
}

Functions

from_map(map)

@spec from_map(map()) :: t()

Backward compatibility: convert from legacy map format.

new(max_flow, residual_graph, source, sink)

Creates a new max flow result.

new(max_flow, residual_graph, source, sink, algorithm)

@spec new(number(), Yog.graph(), Yog.Model.node_id(), Yog.Model.node_id(), atom()) ::
  t()

Creates a new max flow result with algorithm name.

residual_capacity(max_flow_result, src, dst)

@spec residual_capacity(t(), Yog.Model.node_id(), Yog.Model.node_id()) :: number()

Get flow value on a specific edge in the residual graph.

to_map(result)

@spec to_map(t()) :: map()

Convert to legacy map format.