Skip to content

Typed API (TypeDoc)


Typed API (TypeDoc) / AGraph

Class: AGraph<VertexData, Vertex, Edge, Events>

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

Extends

  • EventEmitter<Events>

Extended by

Type Parameters

VertexData

VertexData

Vertex

Vertex extends IVertex<VertexData>

Edge

Edge extends IEdge<VertexData>

Events

Events extends GraphEvents<VertexData>

Implements

  • IGraph<VertexData, Vertex, Edge, Events>

Constructors

Constructor

new AGraph<VertexData, Vertex, Edge, Events>(options, _comparator, vertexType, edgeType): AGraph<VertexData, Vertex, Edge, Events>

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

Parameters

options

GraphProperties<VertexData> = ...

_comparator

Comparator<Vertex>

vertexType

(options?) => Vertex

edgeType

(options?) => Edge

Returns

AGraph<VertexData, Vertex, Edge, Events>

Overrides

EventEmitter<Events>.constructor

Properties

adjacencyMatrix?

optional adjacencyMatrix: AdjacencyMatrix

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

Implementation of

IGraph.adjacencyMatrix


comparator

comparator: Comparator<Vertex>

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


connected

connected: boolean = false

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

Implementation of

IGraph.connected


connectedComponentsCount

connectedComponentsCount: number = 0

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

Implementation of

IGraph.connectedComponentsCount


cycleCount

cycleCount: number = 0

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

Implementation of

IGraph.cycleCount


directed

directed: boolean = false

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

Implementation of

IGraph.directed


edges

edges: Set<Edge>

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

Implementation of

IGraph.edges


hasCycles

hasCycles: boolean = false

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

Implementation of

IGraph.hasCycles


hasNegativeCycles

hasNegativeCycles: boolean = false

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

Implementation of

IGraph.hasNegativeCycles


incidenceMatrix?

optional incidenceMatrix: IncidenceMatrix

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

Implementation of

IGraph.incidenceMatrix


mixed

mixed: boolean = false

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

Implementation of

IGraph.mixed


strongConnectedComponentsCount

strongConnectedComponentsCount: number = 0

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

Implementation of

IGraph.strongConnectedComponentsCount


title

title: string

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

Implementation of

IGraph.title


useMatrixLayer

readonly useMatrixLayer: boolean

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

Implementation of

IGraph.useMatrixLayer


uuid

uuid: string

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

Implementation of

IGraph.uuid


vertices

vertices: Set<Vertex>

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

Implementation of

IGraph.vertices


weightedAdjacencyMatrix?

optional weightedAdjacencyMatrix: WeightedAdjacencyMatrix

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

Implementation of

IGraph.weightedAdjacencyMatrix

Methods

addEdge()

addEdge(e): boolean

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

Parameters

e

Edge

Returns

boolean

Implementation of

IGraph.addEdge


addVertex()

addVertex(v): boolean

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

Parameters

v

Vertex

Returns

boolean

Implementation of

IGraph.addVertex


breadthFirstSearch()

breadthFirstSearch(startVertex): List<Vertex>

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

Parameters

startVertex

Vertex

Returns

List<Vertex>

Implementation of

IGraph.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

Implementation of

IGraph.c


checkForCycles()

checkForCycles(): boolean

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

Returns

boolean

Implementation of

IGraph.checkForCycles


checkForNegativeCycles()

checkForNegativeCycles(): boolean

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

Returns

boolean

Implementation of

IGraph.checkForNegativeCycles


clear()

clear(): void

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

Returns

void

Implementation of

IGraph.clear


clearListeners()

clearListeners<Key>(event?): this

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

Type Parameters

Key

Key extends string | number | symbol

Parameters

event?

Key

Returns

this

Description

Wrapper for clearing listeners for given event or all events.

Implementation of

IGraph.clearListeners

Inherited from

EventEmitter.clearListeners


connectedComponents()

connectedComponents(): List<IGraph<VertexData, Vertex, Edge, Events>>

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

Returns

List<IGraph<VertexData, Vertex, Edge, Events>>

Implementation of

IGraph.connectedComponents


constructShortestPath()

constructShortestPath(from, to, predecessors): Vertex[]

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

Parameters

from

Vertex

to

Vertex

predecessors

Map<Vertex, Vertex>

Returns

Vertex[]


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

Implementation of

IGraph.createEdge


createVertex()

createVertex(title, point, data): Vertex

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

Parameters

title

string = 'new vertex'

point

undefined = undefined

data

VertexData

Returns

Vertex

Implementation of

IGraph.createVertex


density()

density(): number

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

Returns

number

Implementation of

IGraph.density


depthFirstSearch()

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

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

Parameters

startVertex

Vertex

L?

IStack<Vertex>

Returns

List<Vertex>

Implementation of

IGraph.depthFirstSearch


dijkstra()

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

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

Parameters

startVertex

Vertex

useWeightedMatrix

boolean = false

Returns

SPPair<VertexData, Vertex>

Implementation of

IGraph.dijkstra


emit()

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

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

Type Parameters

Key

Key extends string | number | symbol

Parameters

event

Key

args

...Events[Key]

Returns

boolean

Description

Emit event.

Implementation of

IGraph.emit

Inherited from

EventEmitter.emit


filter()

filter(predicate): Vertex[]

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

Parameters

predicate

(node) => boolean

Returns

Vertex[]

Implementation of

IGraph.filter


findById()

findById(uuid): Vertex | null

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

Parameters

uuid

string | null | undefined

Returns

Vertex | null

Implementation of

IGraph.findById


fromFormat()

fromFormat(format, data): void

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

Parameters

format

string

data

VertexData

Returns

void


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>


infer()

infer(): void

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

Returns

void

Implementation of

IGraph.infer


inferCycles()

inferCycles(): Set<Vertex[]>

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

Returns

Set<Vertex[]>

Implementation of

IGraph.inferCycles


isAcyclic()

isAcyclic(): boolean

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

Returns

boolean

Implementation of

IGraph.isAcyclic


isConnected()

isConnected(): boolean

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

Returns

boolean

Implementation of

IGraph.isConnected


isCyclic()

isCyclic(): boolean

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

Returns

boolean

Implementation of

IGraph.isCyclic


isDense()

isDense(threshold): boolean

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

Parameters

threshold

number = 0.5

Returns

boolean

Implementation of

IGraph.isDense


isDirected()

isDirected(): boolean

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

Returns

boolean

Implementation of

IGraph.isDirected


isForest()

isForest(): boolean

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

Returns

boolean

Implementation of

IGraph.isForest


isMixed()

isMixed(): boolean

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

Returns

boolean

Implementation of

IGraph.isMixed


isSparse()

isSparse(threshold): boolean

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

Parameters

threshold

number = 0.5

Returns

boolean

Implementation of

IGraph.isSparse


isStronglyConnected()

isStronglyConnected(): boolean

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

Returns

boolean

Implementation of

IGraph.isStronglyConnected


isTree()

isTree(): boolean

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

Returns

boolean

Implementation of

IGraph.isTree


kShortestPaths()

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

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

Parameters

from

Vertex

to

Vertex

K

number

Returns

List<List<Vertex>>

Description

Yen's k-shortest-paths

Implementation of

IGraph.kShortestPaths


listenerCount()

listenerCount<Key>(event?): number

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

Type Parameters

Key

Key extends string | number | symbol

Parameters

event?

Key

Returns

number

Description

Count of listeners for a given event.

Implementation of

IGraph.listenerCount

Inherited from

EventEmitter.listenerCount


minimalSpanningTree()

minimalSpanningTree(): IGraph<VertexData, Vertex, Edge, Events>

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

Returns

IGraph<VertexData, Vertex, Edge, Events>

Description

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

Implementation of

IGraph.minimalSpanningTree


off()

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

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

Type Parameters

Key

Key extends string | number | symbol

Parameters

event

Key

listener?

Listener<Events[Key]>

Returns

this

Description

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

Implementation of

IGraph.off

Inherited from

EventEmitter.off


on()

on<Key>(event, listener): this

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

Type Parameters

Key

Key extends string | number | symbol

Parameters

event

Key

listener

Listener<Events[Key]>

Returns

this

Description

Listen for an event.

Implementation of

IGraph.on

Inherited from

EventEmitter.on


once()

once<Key>(event, listener): this

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

Type Parameters

Key

Key extends string | number | symbol

Parameters

event

Key

listener

Listener<Events[Key]>

Returns

this

Description

Listen once for event.

Implementation of

IGraph.once

Inherited from

EventEmitter.once


order()

order(): number

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

Returns

number

Implementation of

IGraph.order


parallelTopologicalSorting()

parallelTopologicalSorting(): List<List<Vertex>>

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

Returns

List<List<Vertex>>

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)

Implementation of

IGraph.parallelTopologicalSorting


registerSerializer()

registerSerializer(format, serializer): void

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

Parameters

format

string

serializer

GraphSerializer<VertexData, Events>

Returns

void


removeEdge()

removeEdge(e): boolean

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

Parameters

e

Edge

Returns

boolean

Implementation of

IGraph.removeEdge


removeVertex()

removeVertex(v): boolean

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

Parameters

v

Vertex

Returns

boolean

Implementation of

IGraph.removeVertex


render()

render<RenderReturnType>(format): RenderReturnType

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

Type Parameters

RenderReturnType

RenderReturnType

Parameters

format

string = 'json'

Returns

RenderReturnType


shortestPath()

shortestPath(from, to): List<Vertex>

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

Parameters

from

Vertex

to

Vertex

Returns

List<Vertex>

Description

shortest path (Moore-Bellman-Ford)

Implementation of

IGraph.shortestPath


size()

size(): number

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

Returns

number

Implementation of

IGraph.size


strongConnectedComponentCount()

strongConnectedComponentCount(): number

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

Returns

number


strongConnectedComponents()

strongConnectedComponents(): IGraph<VertexData, Vertex, Edge, Events>[]

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

Returns

IGraph<VertexData, Vertex, Edge, Events>[]

Implementation of

IGraph.strongConnectedComponents


subgraph()

subgraph(predicate): IGraph<VertexData, Vertex, Edge, Events>

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

Parameters

predicate

(node) => boolean

Returns

IGraph<VertexData, Vertex, Edge, Events>

Implementation of

IGraph.subgraph


toJSON()

toJSON(): GraphProperties<VertexData>

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

Returns

GraphProperties<VertexData>


topologicalSorting()

topologicalSorting(): List<Vertex>

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

Returns

List<Vertex>

Implementation of

IGraph.topologicalSorting

Built with VitePress – Released under the MIT License.