Skip to content

Typed API (TypeDoc)


Typed API (TypeDoc) / Graph

Class: Graph<T>

Defined in: graph/src/graph.ts:1984

Extends

Type Parameters

T

T = Record<string, any>

Constructors

Constructor

new Graph<T>(props, comparator): Graph<T>

Defined in: graph/src/graph.ts:1985

Parameters

props

GraphProperties<T> = {}

comparator

Comparator<Vertex<T>> = graphVertexComparator

Returns

Graph<T>

Overrides

AGraph.constructor

Properties

adjacencyMatrix?

optional adjacencyMatrix: AdjacencyMatrix

Defined in: graph/src/graph.ts:124

Inherited from

AGraph.adjacencyMatrix


comparator

comparator: Comparator<Vertex<T>>

Defined in: graph/src/graph.ts:123

Inherited from

AGraph.comparator


connected

connected: boolean = false

Defined in: graph/src/graph.ts:117

Inherited from

AGraph.connected


connectedComponentsCount

connectedComponentsCount: number = 0

Defined in: graph/src/graph.ts:118

Inherited from

AGraph.connectedComponentsCount


cycleCount

cycleCount: number = 0

Defined in: graph/src/graph.ts:120

Inherited from

AGraph.cycleCount


directed

directed: boolean = false

Defined in: graph/src/graph.ts:115

Inherited from

AGraph.directed


edges

edges: Set<Edge<T>>

Defined in: graph/src/graph.ts:114

Inherited from

AGraph.edges


hasCycles

hasCycles: boolean = false

Defined in: graph/src/graph.ts:121

Inherited from

AGraph.hasCycles


hasNegativeCycles

hasNegativeCycles: boolean = false

Defined in: graph/src/graph.ts:122

Inherited from

AGraph.hasNegativeCycles


incidenceMatrix?

optional incidenceMatrix: IncidenceMatrix

Defined in: graph/src/graph.ts:126

Inherited from

AGraph.incidenceMatrix


mixed

mixed: boolean = false

Defined in: graph/src/graph.ts:116

Inherited from

AGraph.mixed


strongConnectedComponentsCount

strongConnectedComponentsCount: number = 0

Defined in: graph/src/graph.ts:119

Inherited from

AGraph.strongConnectedComponentsCount


title

title: string

Defined in: graph/src/graph.ts:112

Inherited from

AGraph.title


useMatrixLayer

readonly useMatrixLayer: boolean

Defined in: graph/src/graph.ts:127

Inherited from

AGraph.useMatrixLayer


uuid

uuid: string

Defined in: graph/src/graph.ts:111

Inherited from

AGraph.uuid


vertices

vertices: Set<Vertex<T>>

Defined in: graph/src/graph.ts:113

Inherited from

AGraph.vertices


weightedAdjacencyMatrix?

optional weightedAdjacencyMatrix: WeightedAdjacencyMatrix

Defined in: graph/src/graph.ts:125

Inherited from

AGraph.weightedAdjacencyMatrix

Methods

addEdge()

addEdge(e): boolean

Defined in: graph/src/graph.ts:1555

Parameters

e

Edge

Returns

boolean

Inherited from

AGraph.addEdge


addVertex()

addVertex(v): boolean

Defined in: graph/src/graph.ts:1600

Parameters

v

Vertex

Returns

boolean

Inherited from

AGraph.addVertex


breadthFirstSearch()

breadthFirstSearch(startVertex): List<Vertex<T>>

Defined in: graph/src/graph.ts:242

Parameters

startVertex

Vertex

Returns

List<Vertex<T>>

Inherited from

AGraph.breadthFirstSearch


c()

c(from, to): number

Defined in: graph/src/graph.ts:1634

Parameters

from

Vertex

to

Vertex

Returns

number

Description

Weight function for calculating the weight of an edge.

Override, for custom weight function

Inherited from

AGraph.c


checkForCycles()

checkForCycles(): boolean

Defined in: graph/src/graph.ts:929

Returns

boolean

Inherited from

AGraph.checkForCycles


checkForNegativeCycles()

checkForNegativeCycles(): boolean

Defined in: graph/src/graph.ts:1087

Returns

boolean

Inherited from

AGraph.checkForNegativeCycles


clear()

clear(): void

Defined in: graph/src/graph.ts:1964

Returns

void

Inherited from

AGraph.clear


clearListeners()

clearListeners<Key>(event?): this

Defined in: event-emitter/dist/emitter.es.d.ts:35

Type Parameters

Key

Key extends keyof GraphEvents<T>

Parameters

event?

Key

Returns

this

Description

Wrapper for clearing listeners for given event or all events.

Inherited from

AGraph.clearListeners


connectedComponents()

connectedComponents(): List<IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>>

Defined in: graph/src/graph.ts:1131

Returns

List<IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>>

Inherited from

AGraph.connectedComponents


constructShortestPath()

constructShortestPath(from, to, predecessors): Vertex<T>[]

Defined in: graph/src/graph.ts:1805

Parameters

from

Vertex

to

Vertex

predecessors

Map<Vertex<T>, Vertex<T>>

Returns

Vertex<T>[]

Inherited from

AGraph.constructShortestPath


createEdge()

createEdge(from, to, title, directed, weight): Edge

Defined in: graph/src/graph.ts:1543

Parameters

from

Vertex

to

Vertex

title

string = 'new edge'

directed

boolean = true

weight

number = 0

Returns

Edge

Inherited from

AGraph.createEdge


createVertex()

createVertex(title, point, data): Vertex

Defined in: graph/src/graph.ts:1587

Parameters

title

string = 'new vertex'

point

undefined = undefined

data

T

Returns

Vertex

Inherited from

AGraph.createVertex


density()

density(): number

Defined in: graph/src/graph.ts:1390

Returns

number

Inherited from

AGraph.density


depthFirstSearch()

depthFirstSearch(startVertex, L?): List<Vertex<T>>

Defined in: graph/src/graph.ts:192

Parameters

startVertex

Vertex

L?

IStack<Vertex<T>>

Returns

List<Vertex<T>>

Inherited from

AGraph.depthFirstSearch


dijkstra()

dijkstra(startVertex, useWeightedMatrix): SPPair<T, Vertex<T>>

Defined in: graph/src/graph.ts:271

Parameters

startVertex

Vertex

useWeightedMatrix

boolean = false

Returns

SPPair<T, Vertex<T>>

Inherited from

AGraph.dijkstra


emit()

emit<Key>(event, ...args): boolean

Defined in: event-emitter/dist/emitter.es.d.ts:30

Type Parameters

Key

Key extends keyof GraphEvents<T>

Parameters

event

Key

args

...GraphEvents<T>[Key]

Returns

boolean

Description

Emit event.

Inherited from

AGraph.emit


filter()

filter(predicate): Vertex<T>[]

Defined in: graph/src/graph.ts:1375

Parameters

predicate

(node) => boolean

Returns

Vertex<T>[]

Inherited from

AGraph.filter


findById()

findById(uuid): Vertex<T> | null

Defined in: graph/src/graph.ts:1383

Parameters

uuid

string | null | undefined

Returns

Vertex<T> | null

Inherited from

AGraph.findById


fromFormat()

fromFormat(format, data): void

Defined in: graph/src/graph.ts:1937

Parameters

format

string

data

T

Returns

void

Inherited from

AGraph.fromFormat


fromJSON()

static fromJSON<T, V, E, Events>(dto, comparator, vertexType, edgeType): AGraph<T, V, E, Events>

Defined in: graph/src/graph.ts:1910

Type Parameters

T

T

V

V extends IVertex<T>

E

E extends IEdge<T>

Events

Events extends GraphEvents<T>

Parameters

dto

GraphProperties<T>

comparator

Comparator<V>

vertexType

(options?) => V

edgeType

(options?) => E

Returns

AGraph<T, V, E, Events>

Inherited from

AGraph.fromJSON


infer()

infer(): void

Defined in: graph/src/graph.ts:187

Returns

void

Inherited from

AGraph.infer


inferCycles()

inferCycles(): Set<Vertex<T>[]>

Defined in: graph/src/graph.ts:1108

Returns

Set<Vertex<T>[]>

Inherited from

AGraph.inferCycles


isAcyclic()

isAcyclic(): boolean

Defined in: graph/src/graph.ts:1412

Returns

boolean

Inherited from

AGraph.isAcyclic


isConnected()

isConnected(): boolean

Defined in: graph/src/graph.ts:1461

Returns

boolean

Inherited from

AGraph.isConnected


isCyclic()

isCyclic(): boolean

Defined in: graph/src/graph.ts:1408

Returns

boolean

Inherited from

AGraph.isCyclic


isDense()

isDense(threshold): boolean

Defined in: graph/src/graph.ts:1535

Parameters

threshold

number = 0.5

Returns

boolean

Inherited from

AGraph.isDense


isDirected()

isDirected(): boolean

Defined in: graph/src/graph.ts:1443

Returns

boolean

Inherited from

AGraph.isDirected


isForest()

isForest(): boolean

Defined in: graph/src/graph.ts:1432

Returns

boolean

Inherited from

AGraph.isForest


isMixed()

isMixed(): boolean

Defined in: graph/src/graph.ts:1530

Returns

boolean

Inherited from

AGraph.isMixed


isSparse()

isSparse(threshold): boolean

Defined in: graph/src/graph.ts:1539

Parameters

threshold

number = 0.5

Returns

boolean

Inherited from

AGraph.isSparse


isStronglyConnected()

isStronglyConnected(): boolean

Defined in: graph/src/graph.ts:1504

Returns

boolean

Inherited from

AGraph.isStronglyConnected


isTree()

isTree(): boolean

Defined in: graph/src/graph.ts:1416

Returns

boolean

Inherited from

AGraph.isTree


kShortestPaths()

kShortestPaths(from, to, K): List<List<Vertex<T>>>

Defined in: graph/src/graph.ts:543

Parameters

from

Vertex

to

Vertex

K

number

Returns

List<List<Vertex<T>>>

Description

Yen's k-shortest-paths

Inherited from

AGraph.kShortestPaths


listenerCount()

listenerCount<Key>(event?): number

Defined in: event-emitter/dist/emitter.es.d.ts:40

Type Parameters

Key

Key extends keyof GraphEvents<T>

Parameters

event?

Key

Returns

number

Description

Count of listeners for a given event.

Inherited from

AGraph.listenerCount


minimalSpanningTree()

minimalSpanningTree(): IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>

Defined in: graph/src/graph.ts:629

Returns

IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>

Description

Minimal spanning tree algorithmen (Kruskal and minimum branching) for undirected/directed, connected and weighted graphs

Inherited from

AGraph.minimalSpanningTree


off()

off<Key>(event, listener?): this

Defined in: event-emitter/dist/emitter.es.d.ts:18

Type Parameters

Key

Key extends keyof GraphEvents<T>

Parameters

event

Key

listener?

Listener<GraphEvents<T>[Key]>

Returns

this

Description

Remove listener for event or clear all listeners for given event.

Inherited from

AGraph.off


on()

on<Key>(event, listener): this

Defined in: event-emitter/dist/emitter.es.d.ts:12

Type Parameters

Key

Key extends keyof GraphEvents<T>

Parameters

event

Key

listener

Listener<GraphEvents<T>[Key]>

Returns

this

Description

Listen for an event.

Inherited from

AGraph.on


once()

once<Key>(event, listener): this

Defined in: event-emitter/dist/emitter.es.d.ts:24

Type Parameters

Key

Key extends keyof GraphEvents<T>

Parameters

event

Key

listener

Listener<GraphEvents<T>[Key]>

Returns

this

Description

Listen once for event.

Inherited from

AGraph.once


order()

order(): number

Defined in: graph/src/graph.ts:1400

Returns

number

Inherited from

AGraph.order


parallelTopologicalSorting()

parallelTopologicalSorting(): List<List<Vertex<T>>>

Defined in: graph/src/graph.ts:855

Returns

List<List<Vertex<T>>>

Description

With this variant of the topological sorting it's additionally possible to determine which vertices can be processed simulations (see "parallel topological sorting" test)

Inherited from

AGraph.parallelTopologicalSorting


registerSerializer()

registerSerializer(format, serializer): void

Defined in: graph/src/graph.ts:1902

Parameters

format

string

serializer

GraphSerializer<T, GraphEvents<T>>

Returns

void

Inherited from

AGraph.registerSerializer


removeEdge()

removeEdge(e): boolean

Defined in: graph/src/graph.ts:1565

Parameters

e

Edge

Returns

boolean

Inherited from

AGraph.removeEdge


removeVertex()

removeVertex(v): boolean

Defined in: graph/src/graph.ts:1610

Parameters

v

Vertex

Returns

boolean

Inherited from

AGraph.removeVertex


render()

render<RenderReturnType>(format): RenderReturnType

Defined in: graph/src/graph.ts:1930

Type Parameters

RenderReturnType

RenderReturnType

Parameters

format

string = 'json'

Returns

RenderReturnType

Inherited from

AGraph.render


shortestPath()

shortestPath(from, to): List<Vertex<T>>

Defined in: graph/src/graph.ts:531

Parameters

from

Vertex

to

Vertex

Returns

List<Vertex<T>>

Description

shortest path (Moore-Bellman-Ford)

Inherited from

AGraph.shortestPath


size()

size(): number

Defined in: graph/src/graph.ts:1404

Returns

number

Inherited from

AGraph.size


strongConnectedComponentCount()

strongConnectedComponentCount(): number

Defined in: graph/src/graph.ts:1360

Returns

number

Inherited from

AGraph.strongConnectedComponentCount


strongConnectedComponents()

strongConnectedComponents(): IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>[]

Defined in: graph/src/graph.ts:1233

Returns

IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>[]

Inherited from

AGraph.strongConnectedComponents


subgraph()

subgraph(predicate): IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>

Defined in: graph/src/graph.ts:176

Parameters

predicate

(node) => boolean

Returns

IGraph<T, Vertex<T>, Edge<T>, GraphEvents<T>>

Inherited from

AGraph.subgraph


toJSON()

toJSON(): GraphProperties<T>

Defined in: graph/src/graph.ts:1906

Returns

GraphProperties<T>

Inherited from

AGraph.toJSON


topologicalSorting()

topologicalSorting(): List<Vertex<T>>

Defined in: graph/src/graph.ts:773

Returns

List<Vertex<T>>

Inherited from

AGraph.topologicalSorting

Built with VitePress – Released under the MIT License.