Interface IScyllaReadOnlyGraph
Extended read-only inspection interface for graph structures. Adds individual edge retrieval, node flag access, and allocation-free bulk copy operations on top of the structural query contract established by IScyllaGraph.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public interface IScyllaReadOnlyGraph : IScyllaGraph, IScyllaCollection
Remarks
Position in the hierarchy. This interface is the first read-only extension above IScyllaGraph. It is further extended by IScyllaReadOnlyGraph<TNodeData> for graphs with per-node typed user data, and by IScyllaMutableGraph for graphs that also support structural mutation.
Clear on read-only graphs. This interface inherits
Clear() from the base collection interface.
Graph implementations that are truly read-only (i.e., the
Mutable flag is NOT set in
Properties) must throw
InvalidOperationException from Clear() to signal
that structural mutation is not permitted.
Allocation-free bulk access. CopyAllNodes(Span<ScyllaGraphNode>) and
CopyAllEdges(Span<ScyllaGraphEdge>) are designed for zero-allocation inspection patterns.
Callers should rent a buffer (e.g. via System.Buffers.ArrayPool) or use a
stack-allocated span sized to NodeCount or
EdgeCount respectively, then pass it to these methods
to avoid heap pressure in performance-sensitive code paths.
Methods
CopyAllEdges(Span<ScyllaGraphEdge>)
Copies all edge descriptors from the graph into the provided span without allocating any managed memory.
Declaration
int CopyAllEdges(Span<ScyllaGraphEdge> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<ScyllaGraphEdge> | destination | The caller-supplied span into which ScyllaGraphEdge descriptors will be written. The span should be at least EdgeCount elements long to receive all edges; if it is smaller, only as many edges as fit are copied. |
Returns
| Type | Description |
|---|---|
| int | The number of ScyllaGraphEdge descriptors written to
|
Remarks
For undirected graphs, each conceptual edge is copied exactly once. The FromID and ToID fields reflect the canonical storage direction and may not match the order in which the edge was originally added.
For directed graphs, each directed edge appears as a separate descriptor; reciprocal edges (A->B and B->A) produce two distinct entries.
The order of edges within destination is
implementation-defined and should not be relied upon. For typed edge graphs,
retrieve per-edge user data via
TryGetEdgeData(int, int, out TEdgeData)
after copying the base descriptors.
See Also
CopyAllNodes(Span<ScyllaGraphNode>)
Copies all node descriptors from the graph into the provided span without allocating any managed memory.
Declaration
int CopyAllNodes(Span<ScyllaGraphNode> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Span<ScyllaGraphNode> | destination | The caller-supplied span into which ScyllaGraphNode descriptors will be written. The span should be at least NodeCount elements long to receive all nodes; if it is smaller, only as many nodes as fit are copied. |
Returns
| Type | Description |
|---|---|
| int | The number of ScyllaGraphNode descriptors written to
|
Remarks
The order in which nodes are written into destination is
implementation-defined. Callers must not assume any particular ordering.
For typed graphs, this method copies only the base descriptor (ID and flags). To retrieve per-node user data alongside the descriptor, call TryGetNodeData(int, out TNodeData) for each node after copying. See the remarks on that interface for guidance on performing typed bulk operations.
See Also
TryGetEdge(int, int, out ScyllaGraphEdge)
Attempts to retrieve the edge descriptor for the edge between two nodes.
Declaration
bool TryGetEdge(int fromID, int toID, out ScyllaGraphEdge edge)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fromID | The ID of the source node. For undirected graphs, argument order is irrelevant. |
| int | toID | The ID of the target node. For undirected graphs, argument order is irrelevant. |
| ScyllaGraphEdge | edge | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
For undirected graphs, the fromID and toID
arguments are interchangeable. The returned FromID
and ToID will match the canonical storage direction
used internally, which may differ from the argument order supplied.
For directed graphs, only the edge in the direction
(fromID -> toID) is looked up.
The reverse direction is independent; call this method again with swapped
arguments to check the reverse edge separately.
To check existence without retrieving the descriptor, prefer ContainsEdge(int, int) which may be implemented more efficiently in some graph representations.
See Also
TryGetNodeFlags(int, out ScyllaGraphNodeFlags)
Attempts to retrieve the flags associated with the specified node.
Declaration
bool TryGetNodeFlags(int nodeID, out ScyllaGraphNodeFlags flags)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeID | The ID of the node to query. |
| ScyllaGraphNodeFlags | flags | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Node flags are bitpacked into a uint. Bit 0 is the
Walkable flag; bits 1-31 are user-defined
tags (Tag0 through
Tag30) that callers may use for domain-specific
categorization such as terrain type, cost multiplier tier, or zone membership.
Flags can be mutated on mutable graphs via TrySetNodeFlags(int, ScyllaGraphNodeFlags).