Interface IScyllaReadOnlyGraph<TNodeData, TEdgeData>
Generic read-only graph interface that attaches typed user data to both nodes and edges. Extends IScyllaReadOnlyGraph<TNodeData> with per-edge data retrieval and a typed allocation-free neighbor access overload.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public interface IScyllaReadOnlyGraph<TNodeData, TEdgeData> : IScyllaReadOnlyGraph<TNodeData>, IScyllaReadOnlyGraph, IScyllaGraph, IScyllaCollection
Type Parameters
| Name | Description |
|---|---|
| TNodeData | The type of user data stored alongside each node. May be any managed or value type.
Nodes added without explicit data default to |
| TEdgeData | The type of user data stored alongside each edge. May be any managed or value type.
Edges added through the untyped
TryAddEdge(int, int, float) overload default to
|
Remarks
Position in the hierarchy. This is the most fully-featured read-only interface, combining per-node and per-edge typed data with the full structural and inspection contract of IScyllaReadOnlyGraph. The corresponding mutable variant is IScyllaMutableGraph<TNodeData, TEdgeData>.
Typed neighbor access. GetNeighborsNonAlloc(int, Span<ScyllaGraphEdge<TEdgeData>>) is a typed overload of GetNeighborsNonAlloc(int, Span<ScyllaGraphEdge>) that fills ScyllaGraphEdge<TEdgeData> descriptors containing both the base edge information and per-edge user data in a single call. The untyped overload defined on IScyllaGraph remains accessible through the base interface for callers that do not require edge data.
Methods
GetNeighborsNonAlloc(int, Span<ScyllaGraphEdge<TEdgeData>>)
Copies the typed outgoing edges of the specified node into the provided span without allocating any managed memory. This is the typed overload of GetNeighborsNonAlloc(int, Span<ScyllaGraphEdge>) that returns ScyllaGraphEdge<TEdgeData> descriptors containing per-edge user data alongside the base edge information.
Declaration
int GetNeighborsNonAlloc(int nodeID, Span<ScyllaGraphEdge<TEdgeData>> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeID | The ID of the node whose typed neighbors to retrieve. |
| Span<ScyllaGraphEdge<TEdgeData>> | destination | The caller-supplied span into which ScyllaGraphEdge<TEdgeData> descriptors will be written. Should be at least GetNeighborCount(int) elements long to receive all neighbors. If smaller, only as many edges as fit are written. |
Returns
| Type | Description |
|---|---|
| int | The number of ScyllaGraphEdge<TEdgeData> descriptors written to
|
Remarks
This overload produces typed descriptors in a single pass, avoiding the need to call TryGetEdgeData(int, int, out TEdgeData) individually for each neighbor. Use it in traversal loops where both the edge topology and per-edge data are required simultaneously.
The base untyped overload GetNeighborsNonAlloc(int, Span<ScyllaGraphEdge>) is still accessible through the base interface and remains the preferred choice when edge data is not needed, as it may be implemented more efficiently.
The sentinel return value -1 for a missing node is consistent with
GetNeighborCount(int) and the untyped overload.
See Also
TryGetEdgeData(int, int, out TEdgeData)
Attempts to retrieve the user data associated with the edge between two nodes.
Declaration
bool TryGetEdgeData(int fromID, int toID, out TEdgeData data)
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. |
| TEdgeData | data | When this method returns |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
Edges added through the untyped
TryAddEdge(int, int, float) overload store
default(TEdgeData) as their data value until explicitly updated via
TrySetEdgeData(int, int, TEdgeData). A return
value of true with data == default(TEdgeData) therefore does not
distinguish between intentional default data and data that was never set.
For undirected graphs, argument order does not affect whether the edge is found, but the canonical storage direction may influence which data value is returned if the implementation stores direction-specific data internally.