interface ArrowValuedGraphBase.Builder<N,V,Tp>
undocumented
Extends: ValuedGraphBase.Builder<N,V,Tp>
Type parameters
| Name | Constraints | Default | Description |
|---|---|---|---|
| N | undocumented | ||
| V | undocumented | ||
| Tp | ArrowValuedGraphBase.Types | ArrowValuedGraphBase.Types | undocumented |
Properties
connectionSize
Returns the amount of connections in the graph.
connectionSizecontext
Returns the context associated to this collection instance.
contextcontext associated to this collection instance.isEmpty
Returns true if there are no entries in the builder.
isEmptynodeSize
Returns the amount of nodes in the graph.
nodeSizeMethods
addGraphElement
Adds the given element graph element to the graph.
addGraphElementelement graph element to the graph.Definition
addGraphElement(element: ValuedGraphElement<N, V>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
element | ValuedGraphElement<N, V> |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.addGraphElement([4]) // => true
b.addGraphElement([3, 1, 'c']) // => true
b.addGraphElement([1, 2, 'a']) // => false
Overrides
addGraphElements
Adds the graph elements in the given elements StreamSource to the graph.
addGraphElementselements StreamSource to the graph.Definition
addGraphElements(elements: StreamSource<ValuedGraphElement<N, V>>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
elements | StreamSource<ValuedGraphElement<N, V>> |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.addGraphElements([[4], [5]]) // => true
b.addGraphElements([[3, 1, 'c'], [1]]) // => true
b.addGraphElements([[1, 2, 'a'], [1]]) // => false
Overrides
addNode
Adds the given node to the graph.
addNodenode to the graph.addNodes
Adds the given nodes to the builder.
addNodesnodes to the builder.Definition
addNodes(nodes: StreamSource<N>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
nodes | StreamSource<N> |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.addNodes([3, 4, 5]) // => true
b.addNodes([1, 2]) // => false
Overrides
build
Returns an immutable graph containing the nodes and connections of this builder.
buildDefinition
build(): WithGraphValues<Tp, N, V>['normal'];
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
const g: ArrowValuedGraphHashed<number, string> = b.build()
Overrides
buildMapValues
Returns an immutable graph containing the nodes and connections of this builder, where the values are mapped using the given mapFun function.
buildMapValuesmapFun function.Definition
buildMapValues<V2>(mapFun: (value: V, node1: N, node2: N) => V2): WithGraphValues<Tp, N, V2>['normal'];
Type parameters
| Name | Description |
|---|---|
| V2 |
Parameters
| Name | Type | Description |
|---|---|---|
mapFun | (value: V, node1: N, node2: N) => V2 | a function taking the value |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
const g: ArrowValuedGraphHashed<number, string> = b.buildMapValues(v => v.toUpperCase())
Overrides
connect
Adds a connection between node1 and node2 to the graph with given value.
connectnode1 and node2 to the graph with given value.Definition
connect(node1: N, node2: N, value: V): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
node1 | N | the first connection node |
node2 | N | the second connection node |
value | V |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.connect(3, 1, 'c') // => true
b.connect(1, 2, 'a') // => false
b.connect(1, 2, 'z') // => true
Overrides
connectAll
Adds the connections in given connections StreamSource to the graph.
connectAllconnections StreamSource to the graph.Definition
connectAll(connections: StreamSource<WithGraphValues<Tp, N, V>['link']>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
connections | StreamSource<WithGraphValues<Tp, N, V>['link']> |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.connectAll([[1, 2, 'a'], [3, 1, 'c']]) // => true
b.connectAll([[1, 2, 'a']]) // => false
Overrides
disconnect
Removes the connection between given node1 and node2 if the connection was present.
disconnectnode1 and node2 if the connection was present.Definition
disconnect<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UN | N |
Parameters
| Name | Type | Description |
|---|---|---|
node1 | RelatedTo<N, UN> | the first connection node |
node2 | RelatedTo<N, UN> |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.disconnect(1, 2) // => true
b.disconnect(3, 4) // => false
Overrides
disconnectAll
Removes all connections from the given connections StreamSource from the graph.
disconnectAllconnections StreamSource from the graph.Definition
disconnectAll<UN = N>(connections: StreamSource<Link<RelatedTo<N, UN>>>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UN | N |
Parameters
| Name | Type | Description |
|---|---|---|
connections | StreamSource<Link<RelatedTo<N, UN>>> |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.disconnectAll([[1, 2], [3, 4]]) // => true
b.disconnectAll([[3, 4], [5, 6]]) // => false
Overrides
getValue
Returns the value associated with the connection between node1 and node2, or given otherwise value if the key is not in the collection.
getValuenode1 and node2, or given otherwise value if the key is not in the collection.Definitions
getValue<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): V | undefined;
getValue<UN, O>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>, otherwise: OptLazy<O>): V | O;
Type parameters
| Name | Default | Description |
|---|---|---|
| UN | N |
Parameters
| Name | Type | Description |
|---|---|---|
node1 | RelatedTo<N, UN> | the first connection node |
node2 | RelatedTo<N, UN> | the second connection node |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
m.getValue(2, 3) // => 'b'
m.getValue(3, 4) // => undefined
m.getValue(2, 3, 'none') // => 'b'
m.getValue(3, 4, 'none') // => 'none'
Overrides
hasConnection
Returns true if the graph has a connection between given nodes node1 and node2.
hasConnectionnode1 and node2.Definition
hasConnection<UN = N>(node1: RelatedTo<N, UN>, node2: RelatedTo<N, UN>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UN | N |
Parameters
| Name | Type | Description |
|---|---|---|
node1 | RelatedTo<N, UN> | the first connection node |
node2 | RelatedTo<N, UN> | the second connection node |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.hasConnection(1, 2) // => true
b.hasConnection(6, 7) // => false
Overrides
hasNode
Returns true if the graph contains the given node.
hasNodenode.Definition
hasNode<UN = N>(node: RelatedTo<N, UN>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UN | N |
Parameters
| Name | Type | Description |
|---|---|---|
node | RelatedTo<N, UN> | the node to search |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.hasNode(1) // => true
b.hasNode(6) // => false
Overrides
modifyAt
Modifies the graph at the connection between given node1 and node2 modified according to given options.
modifyAtnode1 and node2 modified according to given options.Definition
modifyAt(node1: N, node2: N, options: {
ifNew?: OptLazyOr<V, Token>;
ifExists?: (value: V, remove: Token) => V | Token;
}): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
node1 | N | the first connection node |
node2 | N | the second connection node |
options | {ifNew?: OptLazyOr<V, Token>;ifExists?: (value: V, remove: Token) => V | Token;} |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.modifyAt(3, 4, { ifNew: 'c' }) // => true
g.modifyAt(4, 5, { ifNew: (none) => 1 < 2 ? none : 'c' }) // => false
g.modifyAt(1, 2, { ifNew: 'a' }) // => false
g.modifyAt(1, 2, { ifExists: () => 'c' }) // => false
g.modifyAt(1, 2, { ifExists: (v) => v + 'z' }) // => true
g.modifyAt(2, 3, { ifExists: (v, remove) => v === 'a' ? v : remove })
// => true
Overrides
removeNode
Removes the given node, and any of its connections, from the graph.
removeNodenode, and any of its connections, from the graph.removeNodes
Removes the given nodes, and any of their connections, from the graph.
removeNodesnodes, and any of their connections, from the graph.Definition
removeNodes<UN = N>(nodes: StreamSource<RelatedTo<N, UN>>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UN | N |
Parameters
| Name | Type | Description |
|---|---|---|
nodes | StreamSource<RelatedTo<N, UN>> |
const b = ArrowValuedGraphHashed
.of([[1, 2, 'a'], [2, 3, 'b']])
.toBuilder()
b.removeNodes([1, 6, 7]) // => true
b.removeNodes([6, 7]) // => false