Skip to main content

namespace EdgeGraphSorted

An type-invariant immutable valued edge (undirected) graph. The connections are internally maintained using sorted collections See the Graph documentation and the EdgeGraphSorted API documentation

Companion interface: EdgeGraphSorted<N>

Interfaces

NameDescription
EdgeGraphSorted.Builder<N>A mutable EdgeGraphSorted builder used to efficiently create new immutable instances. See the Graph documentation and the EdgeGraphSorted.Builder API documentation
EdgeGraphSorted.Context<UN>The EdgeGraphSorted's Context instance that serves as a factory for all related immutable instances and builders.
EdgeGraphSorted.NonEmpty<N>A non-empty type-invariant immutable valued edge (undirected) graph. The connections are internally maintained using sorted collections See the Graph documentation and the EdgeGraphSorted API documentation
EdgeGraphSorted.TypesUtility interface that provides higher-kinded types for this collection.

Static Methods

builder

Returns an empty builder instance.

Definition

builder<N extends UN>(): WithGraphValues<Tp, N, unknown>['builder'];

Type parameters

NameConstraintsDescription
NUN
example
ArrowValuedGraphHashed.builder<number, string>()    // => ArrowValuedGraphHashed.Builder<number, string>

Overrides

Factory.builder

createContext

Returns a new EdgeGraphSorted context instance based on the given options.

Definition

createContext<UN>(options?: {
    linkMapContext?: SortedMap.Context<UN>;
    linkConnectionsContext?: SortedSet.Context<UN>;
  }): EdgeGraphSorted.Context<UN>;

Type parameters

NameDescription
UNthe upper node type for which the context can create instances

Parameters

NameTypeDescription
options{
    linkMapContext?: SortedMap.Context<UN>;
    linkConnectionsContext?: SortedSet.Context<UN>;
  }
(optional) an object containing the following properties:
- linkMapContext: (optional) the map context to use to maintain link maps
- linkConnectionsContext: (optional) the set context to use to maintain link connections

defaultContext

Returns the default context for this type of graph.

Definition

defaultContext<UN>(): EdgeGraphSorted.Context<UN>;

Type parameters

NameDescription
UNthe upper node type that the context should accept

empty

Returns the (singleton) empty instance of this type and context with given key and value types.

Definition

empty<N extends UN>(): WithGraphValues<Tp, N, unknown>['normal'];

Type parameters

NameConstraintsDescription
NUN
example
ArrowGraphHashed.empty<number>()    // => ArrowGraphHashed<number>
ArrowGraphHashed.empty<string>() // => ArrowGraphHashed<string>

Overrides

Factory.empty

from

Returns an immutable valued Graph, containing the graph elements from each of the given sources.

Definitions

from<N extends UN>(...sources: ArrayNonEmpty<StreamSource.NonEmpty<GraphElement<N>>>): WithGraphValues<Tp, N, unknown>['nonEmpty'];

from<N extends UN>(...sources: ArrayNonEmpty<StreamSource<GraphElement<N>>>): WithGraphValues<Tp, N, unknown>['normal'];

Type parameters

NameConstraintsDescription
NUN

Parameters

NameTypeDescription
sourcesArrayNonEmpty<StreamSource.NonEmpty<GraphElement<N>>>an array of StreamSource instances containing graph elements to add
example
ArrowGraphHashed.from([[1], [2]], [[3, 4]])  // => ArrowGraphHashed.NonEmpty<number>

Overrides

Factory.from

of

Returns an immutable valued Graph instance containing the graph elements from the given graphElements.

Definition

of<N extends UN>(...graphElements: ArrayNonEmpty<GraphElement<N>>): WithGraphValues<Tp, N, unknown>['nonEmpty'];

Type parameters

NameConstraintsDescription
NUN

Parameters

NameTypeDescription
graphElementsArrayNonEmpty<GraphElement<N>>a non-empty array of graph elements that are either a single tuple containing a node, or a triplet containing two connection nodes and the connection value.
example
ArrowGraphHashed.of([1], [2], [3, 4]) // => ArrowGraphHashed.NonEmpty<number>

Overrides

Factory.of

reducer

Returns a Reducer that adds received graph elements to a Graph and returns the Graph as a result. When a source is given, the reducer will first create a graph from the source, and then add graph elements to it.

Definition

reducer<N extends UN>(source?: StreamSource.NonEmpty<GraphElement<N>>): Reducer<GraphElement<N>, WithGraphValues<Tp, N, unknown>['normal']>;

Type parameters

NameConstraintsDescription
NUN

Parameters

NameTypeDescription
sourceStreamSource.NonEmpty<GraphElement<N>>(optional) an initial source of graph elements to add to
example
const someSource: GraphElement<number>[] = [[1, 2], [3], [5]];
const result = Stream.of([1, 3], [4, 3]).reduce(ArrowGraphSorted.reducer(someSource))
result.toArray() // => [[1, 2], [1, 3], [4, 3], [5]]
note

uses a builder under the hood. If the given source is a Graph in the same context, it will directly call .toBuilder().

Overrides

Factory.reducer