Skip to main content

Graph.Vertex

A node in the graph.

Properties

data

data: (readonly) T

User data associated with the vertex.

edgesIn

edgesIn: (readonly) IterableIterator<Graph.Edge<T>>

An iterable of all edges that have this vertex as its destination endpoint.

const vertex = graph.vertex('a');
for (const edgeIn of vertex.edgesIn) {
console.log(`vertex "${edgeIn.dst.id}" has an edge coming in from a vertex "${edgeIn.src.id}"`);
}

edgesInCount

edgesInCount: (readonly) number

The nubmer of edges that have this vertex as its destination endpoint.

const vertex = graph.vertex('a');
console.log(`vertex "${vertex.id}" has ${vertex.edgesInCount} edges out");

edgesOut

edgesOut: (readonly) IterableIterator<Graph.Edge<T>>

An iterable of all edges that have this vertex as its source endpoint.

const vertex = graph.vertex('a');
for (const edgeOut of vertex.edgesOut) {
console.log(`vertex "${edgeOut.src.id}" has an edge going to a vertex "${edgeOut.dst.id}"`);
}

edgesOutCount

edgesOutCount: (readonly) number

The nubmer of edges that have this vertex as its source endpoint.

const vertex = graph.vertex('a');
console.log(`vertex "${vertex.id}" has ${vertex.edgeOutCount} edges out");

id

id: (readonly) string

The vertex's id.

neighbors

neighbors: (readonly) IterableIterator<Graph.Vertex<T>>

An iterable of all vertices that can be traversed to from this vertex.

const vertex = graph.vertex('a');
for (const neighbor of vertex.neighbors) {
console.log(`vertex "${vertex.id}" shares an edge with "${neighbor.id}");
}

Methods

findEdgeIn

findEdgeIn(predicate: (edgeIn: Graph.Edge<T>) => boolean, thisArg?: any): Graph.Edge<T> | undefined

Find an edge into this vertex.

const vertex = graph.vertex('a');
// find an edge into 'a' and out from 'b'
vertex.findEdgeIn(edge => edge.src.id === 'b');
ParameterType
predicate(edgeIn: Graph.Edge<T>) => boolean
The callback to run against each inward edge until one is found (by returning true.)
thisArg?any
The "this" argument to use in predicate

Returns: Graph.Edge<T> | undefined

findEdgeOut

findEdgeOut(predicate: (edgeOut: Graph.Edge<T>) => boolean, thisArg?: any): Graph.Edge<T> | undefined

Find an edge out of this vertex.

const vertex = graph.vertex('a');
// find an edge out from 'a' and into 'b'
vertex.findEdgeIn(edge => edge.src.id === 'b');
ParameterType
predicate(edgeOut: Graph.Edge<T>) => boolean
The callback to run against each outward edge until one is found (by returning true.)
thisArg?any
The "this" argument to use in predicate

Returns: Graph.Edge<T> | undefined