namespace GraphElement
A graph element is either an isolated node as a 1-tuple, or a link between nodes represented as a Link
instance.
Companion type: GraphElement<N>
Functions
getLink
Returns the values of the link graph element if the given element e
is a Link element, or undefined otherwise.
getLink
e
is a Link element, or undefined otherwise.Definition
function getLink<N>(e:
GraphElement
<N>):
Link
<N>
|
undefined;
Type parameters
Name | Description |
---|---|
N |
Parameters
Name | Type | Description |
---|---|---|
e | GraphElement <N> | the graph element |
getLinkElement
Returns the element at the given key
in the graph element e
, if the element is a Link element, or returns the given otherwise
value otherwise.
getLinkElement
key
in the graph element e
, if the element is a Link element, or returns the given otherwise
value otherwise.Definition
function getLinkElement<N>(e:
GraphElement
<N>, key: 0
|
1): N
|
undefined;
Type parameters
Name | Description |
---|---|
N |
Parameters
Name | Type | Description |
---|---|---|
e | GraphElement <N> | the graph element |
key | 0 | 1 | the link key |
getSingleNode
Returns the value of a single node graph element if the given element e
is a single node, or the given otherwise
fallback value otherwise.
getSingleNode
e
is a single node, or the given otherwise
fallback value otherwise.Definition
function getSingleNode<N>(e:
GraphElement
<N>): N
|
undefined;
Type parameters
Name | Description |
---|---|
N |
Parameters
Name | Type | Description |
---|---|---|
e | GraphElement <N> | the graph element |
isLink
Returns true if the given graph element e
is a 2-tuple. Instructs the compiler that the type is a 2-tuple.
isLink
e
is a 2-tuple. Instructs the compiler that the type is a 2-tuple.Definition
function isLink(e:
GraphElement
<any>): e is [unknown, unknown];
Parameters
Name | Type | Description |
---|---|---|
e | GraphElement <any> | the graph element |
isSingleNode
Returns true if the given graph element e
is a single node. Instructs the compiler that the type is a 1-tuple.
isSingleNode
e
is a single node. Instructs the compiler that the type is a 1-tuple.Definition
function isSingleNode(e:
GraphElement
<any>): e is [unknown];
Parameters
Name | Type | Description |
---|---|---|
e | GraphElement <any> | the graph element |