Game.Simulation.Flow.Node
Assembly: Assembly-CSharp (inferred)
Namespace: Game.Simulation.Flow
Type: struct
Base: System.ValueType
Summary:
Node is a small value-type used in the simulation flow graph. It uses explicit layout (FieldOffset) to overlay multiple logical fields into the same memory region, allowing the same memory to be reused for different algorithms and temporary state (for example, max-flow / cut algorithms, BFS/shortest-path data, or queue flags). The struct stores indices into a global connection array (first/last connection), algorithmic values such as height/excess/distance/predecessor, a version number, and small flags. Because of the explicit layout, some fields share offsets — care must be taken when reading/writing overlapped fields.
Fields
-
public int m_FirstConnection
(offset 0)
Index of the first connection for this node in the global connection array (inclusive). -
public int m_LastConnection
(offset 4)
Index of the last connection for this node in the global connection array (exclusive). The number of connections is computed as m_LastConnection - m_FirstConnection. -
public int m_Height
(offset 8)
Height/level used by flow/routing algorithms (e.g., push-relabel). -
public int m_Excess
(offset 12)
Excess flow value used in flow algorithms. -
public int m_Version
(offset 16)
Version or tag value that can be used to mark a node for a particular pass/iteration without clearing arrays. -
public Identifier m_CutElementId
(offset 20)
Identifier used by cut-related algorithms. This field shares its offset with m_Distance (see below). The concrete size of Identifier determines overlap behavior; treat as mutually exclusive with m_Distance/m_Predecessor when used. -
public bool m_Retreat
(offset 28)
Boolean flag used by some algorithms (for example retreat/backtrack indicator). Shares offset with m_Enqueued. -
public int m_Distance
(offset 20)
Distance / level value used by shortest-path or BFS algorithms. Overlaps with m_CutElementId; do not use both at once. -
public int m_Predecessor
(offset 24)
Index/id of the predecessor node in a traversal. Overlaps with other fields in the same memory region depending on Identifier size. -
public bool m_Enqueued
(offset 28)
Boolean flag indicating whether the node is enqueued for processing. Shares offset with m_Retreat.
Notes about overlapping fields: - Offsets 20..28 are reused; m_CutElementId, m_Distance and m_Predecessor occupy the same region in different algorithmic contexts. Similarly, m_Retreat and m_Enqueued both map to offset 28. Do not assume these fields can hold independent values at the same time.
Properties
public int connectionCount => m_LastConnection - m_FirstConnection
Returns the number of connections for this node by subtracting the first connection index from the last. This is a computed getter; there is no backing field. Because m_FirstConnection and m_LastConnection are indices, connectionCount can be negative if those fields are set incorrectly — typically they should be maintained by the code that builds the connection lists.
Constructors
public Node()
(implicit default struct constructor)
As a value type, Node has the default parameterless constructor that zero-initializes all fields. There is no explicit constructor defined in the source.
Methods
- None declared in the source. The struct only contains fields and a single expression-bodied property for connectionCount.
Usage Example
// create and initialize a Node (value type)
var node = new Game.Simulation.Flow.Node();
// set connection index range
node.m_FirstConnection = 100;
node.m_LastConnection = 104;
int count = node.connectionCount; // 4
// use as BFS node: set distance and predecessor
node.m_Distance = 0;
node.m_Predecessor = -1;
node.m_Enqueued = true;
// NOTE: do not assume m_Distance and m_CutElementId can be used simultaneously.
// They overlap in memory and are intended for mutually exclusive algorithm contexts.
{{ This struct is optimized for low memory overhead in hot simulation loops. When modifying or reading overlapped fields, ensure you are in the correct algorithmic context to avoid corrupting data used by other passes. }}