namespace EdgeValuedGraphSorted
An type-invariant immutable valued edge (undirected) graph. The nodes are internally maintained using SortedMaps See the Graph documentation and the EdgeValuedGraphSorted API documentation
Companion interface: EdgeValuedGraphSorted<N,V>
Interfaces
Name | Description |
---|---|
EdgeValuedGraphSorted.Builder<N,V> | A mutable EdgeValuedGraphSorted builder used to efficiently create new immutable instances. See the Graph documentation and the EdgeValuedGraphSorted.Builder API documentation |
EdgeValuedGraphSorted.Context<UN> | The EdgeValuedGraphSorted's Context instance that serves as a factory for all related immutable instances and builders. |
EdgeValuedGraphSorted.NonEmpty<N,V> | A non-empty type-invariant immutable valued edge (undirected) graph. The nodes are internally maintained using SortedMaps See the Graph documentation and the EdgeValuedGraphSorted API documentation |
EdgeValuedGraphSorted.Types | Utility interface that provides higher-kinded types for this collection. |
Static Methods
builder
Returns an empty builder instance.
builder
Definition
builder<N extends UN, V>():
WithGraphValues
<Tp, N, V>['builder'];
Type parameters
Name | Constraints | Description |
---|---|---|
N | UN | |
V |
ArrowValuedGraphHashed.builder<number, string>() // => ArrowValuedGraphHashed.Builder<number, string>
Overrides
createContext
Returns a new EdgeValuedGraph context instance based on the given options
.
createContext
options
.Definition
createContext<UN>(options?: {
linkMapContext?:
SortedMap.Context
<UN>;
linkConnectionsContext?:
SortedMap.Context
<UN>;
}):
EdgeValuedGraphSorted.Context
<UN>;
Type parameters
Name | Description |
---|---|
UN | the upper node type for which the context can create instances |
Parameters
Name | Type | Description |
---|---|---|
options | { linkMapContext?: SortedMap.Context <UN>; linkConnectionsContext?: SortedMap.Context <UN>; } | (optional) an object containing the following properties: - linkMapContext: (optional) the map context to use to maintain link maps - linkConnectionsContext: (optional) the map context to use to maintain link connection maps |
defaultContext
Returns the default context for this type of graph.
defaultContext
Definition
defaultContext<UN>():
EdgeValuedGraphSorted.Context
<UN>;
Type parameters
Name | Description |
---|---|
UN | the 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.
empty
Definition
empty<N extends UN, V>():
WithGraphValues
<Tp, N, V>['normal'];
Type parameters
Name | Constraints | Description |
---|---|---|
N | UN | |
V |
ArrowValuedGraphHashed.empty<number, string>() // => ArrowValuedGraphHashed<number, string>
ArrowValuedGraphHashed.empty<string, boolean>() // => ArrowValuedGraphHashed<string, boolean>
Overrides
from
Returns an immutable valued Graph, containing the graph elements from each of the given sources
.
from
sources
.Definitions
from<N extends UN, V>(...sources:
ArrayNonEmpty
<
StreamSource.NonEmpty
<ValuedGraphElement<N, V>>>):
WithGraphValues
<Tp, N, V>['nonEmpty'];
from<N extends UN, V>(...sources:
ArrayNonEmpty
<
StreamSource
<ValuedGraphElement<N, V>>>):
WithGraphValues
<Tp, N, V>['normal'];
Type parameters
Name | Constraints | Description |
---|---|---|
N | UN | |
V |
Parameters
Name | Type | Description |
---|---|---|
sources | ArrayNonEmpty < StreamSource.NonEmpty <ValuedGraphElement<N, V>>> | an array of StreamSource instances containing graph elements to add |
ArrowValuedGraphHashed.from([[1], [2]], [[3, 4, 'c']]) // => ArrowValuedGraphHashed.NonEmpty<number, string>
Overrides
of
Returns an immutable valued Graph instance containing the graph elements from the given graphElements
.
of
graphElements
.Definition
of<N extends UN, V>(...graphElements:
ArrayNonEmpty
<ValuedGraphElement<N, V>>):
WithGraphValues
<Tp, N, V>['nonEmpty'];
Type parameters
Name | Constraints | Description |
---|---|---|
N | UN | |
V |
Parameters
Name | Type | Description |
---|---|---|
graphElements | ArrayNonEmpty <ValuedGraphElement<N, V>> | 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. |
ArrowValuedGraphHashed.of([1], [2], [3, 4, 'a']) // => ArrowValuedGraphHashed.NonEmpty<number, string>
Overrides
reducer
Returns a Reducer
that adds valued received graph elements to a ValuedGraph and returns the ValuedGraph 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.
reducer
Reducer
that adds valued received graph elements to a ValuedGraph and returns the ValuedGraph 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, V>(source?:
StreamSource.NonEmpty
<ValuedGraphElement<N, V>>): Reducer<ValuedGraphElement<N, V>,
WithGraphValues
<Tp, N, V>['normal']>;
Type parameters
Name | Constraints | Description |
---|---|---|
N | UN | |
V |
Parameters
Name | Type | Description |
---|---|---|
source | StreamSource.NonEmpty <ValuedGraphElement<N, V>> | (optional) an initial source of graph elements to add to |
const someSource: ValuedGraphElement<number, string>[] = [[1, 2, 'a'], [3], [5]];
const result = Stream.of([1, 3, 'b'], [4, 3, 'c']).reduce(ArrowGraphSorted.reducer(someSource))
result.toArray() // => [[1, 2, 'a'], [1, 3, 'b'], [4, 3, 'c'], [5]]
uses a builder under the hood. If the given source
is a ValuedGraph in the same context, it will directly call .toBuilder()
.