Class ScyllaAdjacencyListGraph.Builder
Fluent builder for constructing ScyllaAdjacencyListGraph instances with a readable, self-documenting configuration chain.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaAdjacencyListGraph.Builder
Remarks
Obtain a builder via CreateBuilder(). Configure it with method chaining, then call Build() to obtain an IScyllaMutableGraph or BuildConcrete() to obtain the strongly-typed ScyllaAdjacencyListGraph.
Default builder state: directed, unweighted, capacity 16, no self-loops, no parallel edges, unsynchronized.
var graph = ScyllaAdjacencyListGraph.CreateBuilder()
.Directed()
.Weighted()
.WithCapacity(128)
.Synchronized()
.Build();
Methods
AllowParallelEdges(bool)
Configures whether the graph permits parallel edges - multiple edges between the same ordered pair of nodes.
Declaration
public ScyllaAdjacencyListGraph.Builder AllowParallelEdges(bool value = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value |
|
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
AllowSelfLoops(bool)
Configures whether the graph permits self-loops - edges where the source and target node are the same.
Declaration
public ScyllaAdjacencyListGraph.Builder AllowSelfLoops(bool value = true)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value |
|
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
Build()
Builds and returns the configured graph as an IScyllaMutableGraph. If Synchronized(object) was called, the returned instance is a ScyllaAdjacencyListGraph.SynchronizedScyllaAdjacencyListGraph; otherwise it is a bare ScyllaAdjacencyListGraph.
Declaration
public IScyllaMutableGraph Build()
Returns
| Type | Description |
|---|---|
| IScyllaMutableGraph | An IScyllaMutableGraph configured according to the current builder state. |
BuildConcrete()
Builds and returns the concrete ScyllaAdjacencyListGraph instance without wrapping it. Useful when the caller needs access to concrete members such as GetEnumerator() or AsSynchronized(object).
Declaration
public ScyllaAdjacencyListGraph BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph | A new ScyllaAdjacencyListGraph configured according to the current builder state. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when Synchronized(object) has been called, because a concrete unsynchronized instance cannot be returned in that case. Use Build() instead to receive the synchronized wrapper. |
Directed()
Configures the graph as directed so that each edge has an explicit source and target and the reverse direction is not automatically traversable. This is the default state; calling this method explicitly is only needed after calling Undirected().
Declaration
public ScyllaAdjacencyListGraph.Builder Directed()
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
Synchronized(object)
Configures Build() to return a ScyllaAdjacencyListGraph.SynchronizedScyllaAdjacencyListGraph wrapper instead of the bare graph, making all operations thread-safe through a shared lock.
Declaration
public ScyllaAdjacencyListGraph.Builder Synchronized(object syncRoot = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | syncRoot | An optional external lock object. When |
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
Undirected()
Configures the graph as undirected so that each edge is automatically mirrored in both endpoint adjacency lists, making the connection traversable from either end.
Declaration
public ScyllaAdjacencyListGraph.Builder Undirected()
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
Unweighted()
Configures the graph as unweighted (the default) so that all edge weights are
normalised to 1.0f regardless of the value passed to
TryAddEdge(int, int, float).
Declaration
public ScyllaAdjacencyListGraph.Builder Unweighted()
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
Weighted()
Configures the graph as weighted so that the weight parameter of
TryAddEdge(int, int, float) is stored as-is.
Declaration
public ScyllaAdjacencyListGraph.Builder Weighted()
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
WithCapacity(int)
Sets the initial node capacity of the graph, pre-allocating internal storage to avoid rehash overhead when inserting a known number of nodes.
Declaration
public ScyllaAdjacencyListGraph.Builder WithCapacity(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The desired initial capacity. Must be at least 1. |
Returns
| Type | Description |
|---|---|
| ScyllaAdjacencyListGraph.Builder | This builder instance for method chaining. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |