Class ScyllaGraphDOTS.Builder
Fluent builder for constructing ScyllaGraphDOTS instances with readable, self-documenting configuration code.
Default configuration: directed graph, 64 node capacity, 256 edge capacity. The allocator is mandatory and must be set via WithAllocator(Allocator) before calling Build(); omitting it causes Build() to throw InvalidOperationException.
This class is nested inside ScyllaGraphDOTS for API consistency with other DOTS collection builders in the Scylla framework (e.g. ScyllaBitArrayDOTS.Builder, ScyllaDisjointSetDOTS.Builder).
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaGraphDOTS.Builder
Methods
Build()
Constructs and returns a new ScyllaGraphDOTS instance with the configuration accumulated by previous builder calls. The returned graph is in the build phase (not finalized) and ready to receive nodes and edges.
The caller is responsible for disposing the returned graph when it is no longer needed by calling Dispose().
Declaration
public ScyllaGraphDOTS Build()
Returns
| Type | Description |
|---|---|
| ScyllaGraphDOTS | A new ScyllaGraphDOTS in build phase, configured with the settings provided to this builder. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when WithAllocator(Allocator) has not been called before this method. |
Directed()
Configures the graph as directed (the default). In a directed graph, AddEdge(int, int, float) stores only the single forward edge; traversal from the target back to the source requires an explicit reverse edge.
Declaration
public ScyllaGraphDOTS.Builder Directed()
Returns
| Type | Description |
|---|---|
| ScyllaGraphDOTS.Builder | This builder instance for method chaining. |
Undirected()
Configures the graph as undirected. In an undirected graph, AddEdge(int, int, float) automatically stores both the forward and reverse edges so that neighbor queries on either endpoint return the adjacent node. EdgeCount still counts each logical edge once.
Declaration
public ScyllaGraphDOTS.Builder Undirected()
Returns
| Type | Description |
|---|---|
| ScyllaGraphDOTS.Builder | This builder instance for method chaining. |
WithAllocator(Allocator)
Sets the Unity memory allocator that will be used for all native containers in the graph. This method must be called before Build().
Choose the allocator based on the expected lifetime of the graph:
- Unity.Collections.Allocator.Persistent - long-lived graphs (scenes, sessions).
- Unity.Collections.Allocator.TempJob - graphs used within a single job schedule frame.
- Unity.Collections.Allocator.Temp - graphs used within a single method call (very short-lived).
Declaration
public ScyllaGraphDOTS.Builder WithAllocator(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | The memory allocator. Must not be Unity.Collections.Allocator.None or Unity.Collections.Allocator.Invalid. |
Returns
| Type | Description |
|---|---|
| ScyllaGraphDOTS.Builder | This builder instance for method chaining. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
WithEdgeCapacity(int)
Sets the initial capacity hint for the build-phase edge list. This is the expected number of logical edges. For undirected graphs, the internal list may store up to twice this many entries, so size accordingly.
Declaration
public ScyllaGraphDOTS.Builder WithEdgeCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial edge capacity. Must be greater than or equal to zero. |
Returns
| Type | Description |
|---|---|
| ScyllaGraphDOTS.Builder | This builder instance for method chaining. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
WithNodeCapacity(int)
Sets the initial capacity hint for the node containers. This is the expected
number of nodes that will be added during the build phase. The underlying
NativeList and NativeHashMap will grow beyond this value if
needed, so over-estimating is preferable to under-estimating.
Declaration
public ScyllaGraphDOTS.Builder WithNodeCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial node capacity. Must be greater than or equal to zero. |
Returns
| Type | Description |
|---|---|
| ScyllaGraphDOTS.Builder | This builder instance for method chaining. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |