Skip to main content

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​

Returns the values of the link graph element if the given element e is a Link element, or undefined otherwise.

Definition​

function getLink<N>(e: GraphElement<N>): Link<N> | undefined;

Type parameters​
NameDescription
N

Parameters​

NameTypeDescription
eGraphElement<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.

Definition​

function getLinkElement<N>(e: GraphElement<N>, key: 0 |1): N| undefined;

Type parameters​
NameDescription
N

Parameters​

NameTypeDescription
eGraphElement<N>the graph element
key0 | 1the 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.

Definition​

function getSingleNode<N>(e: GraphElement<N>): N | undefined;

Type parameters​
NameDescription
N

Parameters​

NameTypeDescription
eGraphElement<N>the graph element

Returns true if the given graph element 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​

NameTypeDescription
eGraphElement<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.

Definition​

function isSingleNode(e: GraphElement<any>): e is [unknown];

Parameters​

NameTypeDescription
eGraphElement<any>the graph element