Skip to content

@graphty/graphty-element / extend / NodeView

Interface: NodeView ​

Defined in: graphty-element/src/simple/types.ts:131

One node of the graph an algorithm or a layout reads.

Properties ​

degree ​

readonly degree: number

Defined in: graphty-element/src/simple/types.ts:141

edges().length: a self-loop counts ONCE and each parallel edge counts. This is NOT the built-in "degree" algorithm's number, which counts a self-loop twice and a repeated edge (same ends, same direction) once. NetworkX and igraph count a self-loop twice: add edgesTo(node).length to match them. For the number of distinct neighbours, use neighbors().length.


id ​

readonly id: NodeId

Defined in: graphty-element/src/simple/types.ts:133

The node's id, as the data spelled it.

Methods ​

attr() ​

attr(path): unknown

Defined in: graphty-element/src/simple/types.ts:185

An attribute or a published result, by path: the key on the node record as loaded (tier for { id: 1, tier: 2 }), a dotted path into it ("location.lat"), or a result ("results.clusters.group"). undefined when absent, or when path is undefined (an unbound optional "attribute" option).

Parameters ​

path ​

string | undefined

Returns ​

unknown


edges() ​

edges(): readonly EdgeView[]

Defined in: graphty-element/src/simple/types.ts:153

Every edge touching this node, parallel edges included. Use edge.other(node) for the far end.

Returns ​

readonly EdgeView[]


edgesTo() ​

edgesTo(other): readonly EdgeView[]

Defined in: graphty-element/src/simple/types.ts:163

Every edge between this node and other, parallel edges included; empty when they are not adjacent. node.edgesTo(node) is the node's self-loops. In a directed view, only the edges from this node to other.

Parameters ​

other ​

NodeView

Returns ​

readonly EdgeView[]


inEdges() ​

inEdges(): readonly EdgeView[]

Defined in: graphty-element/src/simple/types.ts:157

The edges entering this node. Needs direction: "directed", as outNeighbors does.

Returns ​

readonly EdgeView[]


inNeighbors() ​

inNeighbors(): readonly NodeView[]

Defined in: graphty-element/src/simple/types.ts:151

The nodes whose edges lead to this one. Needs direction: "directed", as outNeighbors does.

Returns ​

readonly NodeView[]


neighbors() ​

neighbors(): readonly NodeView[]

Defined in: graphty-element/src/simple/types.ts:143

Every adjacent node once, whichever way the edge points. Never the node itself: a self-loop is in edges() only.

Returns ​

readonly NodeView[]


number() ​

number(path): number | undefined

Defined in: graphty-element/src/simple/types.ts:187

attr(path) when it is a finite number; undefined otherwise. A numeric string is NOT parsed.

Parameters ​

path ​

string | undefined

Returns ​

number | undefined


outEdges() ​

outEdges(): readonly EdgeView[]

Defined in: graphty-element/src/simple/types.ts:155

The edges leaving this node. Needs direction: "directed", as outNeighbors does.

Returns ​

readonly EdgeView[]


outNeighbors() ​

outNeighbors(): readonly NodeView[]

Defined in: graphty-element/src/simple/types.ts:149

The directed forms. They throw unless the definition declares direction: "directed", so a plugin never reads direction the view was not built with. With direction: "directed", an undirected edge counts both ways: it is in both outEdges() and inEdges() of each end.

Returns ​

readonly NodeView[]


strength() ​

strength(path, direction?): number

Defined in: graphty-element/src/simple/types.ts:178

The weighted degree: the sum of edge.weight(path) over edges() (default "all"), or over outEdges() / inEdges() (which need direction: "directed"). With path undefined it is the degree. An edge with no number at path is left out and counted in the run record's warning. A self-loop counts once, as in degree. Computed once per node, path and direction per run, so calling it from edge() is cheap.

Parameters ​

path ​

string | undefined

direction? ​

"out" | "in" | "all"

Returns ​

number


weightTo() ​

weightTo(other, path): number | undefined

Defined in: graphty-element/src/simple/types.ts:170

The sum of edge.weight(path) over edgesTo(other) -- w_ij, with parallel edges added together. undefined when there is no such edge, AND when the edges exist but none of them has a number at path; an edge without a number is left out of the sum. The weight rule is EdgeView.weight's.

Parameters ​

other ​

NodeView

path ​

string | undefined

Returns ​

number | undefined