Skip to content

Game.Simulation.Flow.MaxFlowSolverState

Assembly:
Namespace: Game.Simulation.Flow

Type: struct

Base:

Summary:
A small POD (plain-old-data) struct that stores the runtime state for a max-flow solver used by the simulation flow system. It contains simple counters/flags used to drive layer processing and versioning of label/active buffers. The struct is blittable (only primitive fields) and is suitable for use in low-level solver code, Unity Jobs / Burst contexts, or in NativeArrays. It represents transient solver state and is typically reinitialized between solver runs.


Fields

  • public bool m_Complete
    Indicates whether the solver has completed its work for the current run. True when no more augmenting paths / processing is required.

  • public int m_NextLayerIndex
    Index of the next layer to process in the layered graph traversal. Used to track progress through BFS/level graph construction or similar layer-based iterations.

  • public int m_CurrentLabelVersion
    Version counter used for label arrays to avoid clearing them between runs. Incremented when starting a new labeling pass so previously written labels with older versions are treated as invalid.

  • public int m_CurrentActiveVersion
    Version counter used for active/visited flags (or active lists). Like m_CurrentLabelVersion, it avoids zeroing arrays by using version numbers to indicate current membership/validity.

Properties

  • None. This type exposes only public fields.

Constructors

  • None explicitly declared.
    The struct has the default value-type constructor. For correct semantics in solver code, explicitly initialize fields before use (for example, set m_Complete = false and initialize indices/versions as needed).

Methods

  • None.

Usage Example

// Example initialization and usage inside a solver routine:
MaxFlowSolverState state = default;
state.m_Complete = false;
state.m_NextLayerIndex = 0;
state.m_CurrentLabelVersion = 1;
state.m_CurrentActiveVersion = 1;

// During solver loop:
while (!state.m_Complete)
{
    // build level graph using state.m_NextLayerIndex and state.m_CurrentLabelVersion
    // process active nodes using state.m_CurrentActiveVersion
    // if no more work: state.m_Complete = true;
    // otherwise advance layer index, or update versions as needed
    state.m_NextLayerIndex++;
}

// When starting a fresh run, bump versions instead of clearing large arrays:
state.m_CurrentLabelVersion++;
state.m_CurrentActiveVersion++;
state.m_Complete = false;
state.m_NextLayerIndex = 0;

{{ Notes: - Because this is a value type, pass by ref if you want in-place updates inside methods (e.g., Solve(ref state, ...)). - The version counters are an optimization to avoid expensive memory clears; ensure wrapping logic is handled if they can overflow in long-running sessions. - Keep this struct small to maintain good cache behavior in jobified or array-of-struct scenarios. }}