Interface IScyllaMutableGraph
Mutable graph interface that supports adding and removing nodes and edges, updating node flags, and pre-allocating storage capacity. Extends IScyllaReadOnlyGraph with structural mutation operations.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public interface IScyllaMutableGraph : IScyllaReadOnlyGraph, IScyllaGraph, IScyllaCollection
Remarks
Position in the hierarchy. This interface extends IScyllaReadOnlyGraph, which in turn extends IScyllaGraph. The typed mutable variants, IScyllaMutableGraph<TNodeData> and IScyllaMutableGraph<TNodeData, TEdgeData>, extend this interface and add per-node and per-edge user data mutation operations respectively.
Fail-safe Try-pattern. All mutation methods follow the Try-pattern and
return a bool indicating success or failure rather than throwing on common
precondition violations such as duplicate IDs or missing nodes. This allows callers to
handle invalid states gracefully without exception overhead in hot paths.
Directed vs. undirected graph behaviour. The directionality of the graph is determined by the Directed flag in Properties. For undirected graphs, edge operations automatically maintain both directions of adjacency. For directed graphs, only the explicitly specified direction is added or removed.
Capacity management. EnsureCapacity(int) pre-allocates node storage to avoid reallocation during bulk insertion. Edge storage is managed dynamically and does not require pre-allocation. Call EnsureCapacity(int) before adding a large known number of nodes for best performance.
Methods
EnsureCapacity(int)
Ensures that the internal node storage can accommodate at least the specified number of nodes without triggering a reallocation.
Declaration
void EnsureCapacity(int minNodeCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | minNodeCapacity | The minimum number of nodes the graph storage should be able to hold. Values less than or equal to the current internal capacity are ignored without error. |
Remarks
This method is an optional performance hint. Call it before a bulk insertion of a known number of nodes to avoid incremental reallocations. It does not change NodeCount and does not add any nodes.
Edge storage grows dynamically on a per-node basis and is not affected by this call. There is no corresponding bulk edge pre-allocation method.
TryAddEdge(int, int, float)
Attempts to add an edge between two existing nodes.
Declaration
bool TryAddEdge(int fromID, int toID, float weight = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fromID | The ID of the source node. |
| int | toID | The ID of the target node. |
| float | weight | The weight of the edge. Defaults to |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
For undirected graphs, adding edge (A, B) automatically stores the reverse adjacency (B, A) as well. EdgeCount increases by 1 for each successful call regardless of directionality.
For typed edge graphs, edges added through this untyped overload will carry
default(TEdgeData). To associate edge data at creation time, use
TryAddEdge(int, int, float, TEdgeData).
See Also
TryAddNode(int, ScyllaGraphNodeFlags)
Attempts to add a new node with the specified ID and flags to the graph.
Declaration
bool TryAddNode(int nodeID, ScyllaGraphNodeFlags flags = ScyllaGraphNodeFlags.Walkable)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeID | A caller-supplied integer ID that must be unique within this graph. No ordering
or contiguity is required; any |
| ScyllaGraphNodeFlags | flags | Initial ScyllaGraphNodeFlags for the node. Defaults to Walkable if not specified. Flags can be changed later via TrySetNodeFlags(int, ScyllaGraphNodeFlags). |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
For typed graphs, nodes added through this untyped overload will have
default(TNodeData) as their data value. To associate data at creation
time, use TryAddNode(int, TNodeData, ScyllaGraphNodeFlags)
instead.
See Also
TryRemoveEdge(int, int)
Attempts to remove the edge between two nodes.
Declaration
bool TryRemoveEdge(int fromID, int toID)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fromID | The ID of the source node. |
| int | toID | The ID of the target node. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
For undirected graphs, removing edge (A, B) also removes the reverse adjacency (B, A). EdgeCount decreases by 1 for each successful call. For directed graphs, only the directed edge in the specified direction is removed; the reverse edge (if any) is unaffected.
See Also
TryRemoveNode(int)
Attempts to remove a node and all of its incident edges from the graph.
Declaration
bool TryRemoveNode(int nodeID)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeID | The ID of the node to remove. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Removing a node also removes all edges that have it as an endpoint (both outgoing and incoming edges for directed graphs, or all incident edges for undirected graphs). After a successful removal, NodeCount decreases by 1 and EdgeCount decreases by the number of edges removed.
See Also
TrySetNodeFlags(int, ScyllaGraphNodeFlags)
Attempts to update the flags on an existing node.
Declaration
bool TrySetNodeFlags(int nodeID, ScyllaGraphNodeFlags flags)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeID | The ID of the node to update. |
| ScyllaGraphNodeFlags | flags | The new ScyllaGraphNodeFlags value to assign to the node. Replaces the entire flags value; this is an assignment, not a bitwise OR. To add a flag while preserving existing flags, first retrieve the current value with TryGetNodeFlags(int, out ScyllaGraphNodeFlags), combine it with the new flag, then call this method with the combined value. |
Returns
| Type | Description |
|---|---|
| bool |
|