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?
optionaladjacencyMatrix:AdjacencyMatrix
Defined in: graph/src/graph.ts:124
Implementation of
comparator
comparator:
Comparator<Vertex>
Defined in: graph/src/graph.ts:123
connected
connected:
boolean=false
Defined in: graph/src/graph.ts:117
Implementation of
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
directed
directed:
boolean=false
Defined in: graph/src/graph.ts:115
Implementation of
edges
edges:
Set<Edge>
Defined in: graph/src/graph.ts:114
Implementation of
hasCycles
hasCycles:
boolean=false
Defined in: graph/src/graph.ts:121
Implementation of
hasNegativeCycles
hasNegativeCycles:
boolean=false
Defined in: graph/src/graph.ts:122
Implementation of
incidenceMatrix?
optionalincidenceMatrix:IncidenceMatrix
Defined in: graph/src/graph.ts:126
Implementation of
mixed
mixed:
boolean=false
Defined in: graph/src/graph.ts:116
Implementation of
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
useMatrixLayer
readonlyuseMatrixLayer:boolean
Defined in: graph/src/graph.ts:127
Implementation of
uuid
uuid:
string
Defined in: graph/src/graph.ts:111
Implementation of
vertices
vertices:
Set<Vertex>
Defined in: graph/src/graph.ts:113
Implementation of
weightedAdjacencyMatrix?
optionalweightedAdjacencyMatrix: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
addVertex()
addVertex(
v):boolean
Defined in: graph/src/graph.ts:1600
Parameters
v
Vertex
Returns
boolean
Implementation of
breadthFirstSearch()
breadthFirstSearch(
startVertex):List<Vertex>
Defined in: graph/src/graph.ts:242
Parameters
startVertex
Vertex
Returns
List<Vertex>
Implementation of
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
checkForCycles()
checkForCycles():
boolean
Defined in: graph/src/graph.ts:929
Returns
boolean
Implementation of
checkForNegativeCycles()
checkForNegativeCycles():
boolean
Defined in: graph/src/graph.ts:1087
Returns
boolean
Implementation of
clear()
clear():
void
Defined in: graph/src/graph.ts:1964
Returns
void
Implementation of
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
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
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
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
density()
density():
number
Defined in: graph/src/graph.ts:1390
Returns
number
Implementation of
depthFirstSearch()
depthFirstSearch(
startVertex,L?):List<Vertex>
Defined in: graph/src/graph.ts:192
Parameters
startVertex
Vertex
L?
IStack<Vertex>
Returns
List<Vertex>
Implementation of
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
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
Inherited from
EventEmitter.emit
filter()
filter(
predicate):Vertex[]
Defined in: graph/src/graph.ts:1375
Parameters
predicate
(node) => boolean
Returns
Vertex[]
Implementation of
findById()
findById(
uuid):Vertex|null
Defined in: graph/src/graph.ts:1383
Parameters
uuid
string | null | undefined
Returns
Vertex | null
Implementation of
fromFormat()
fromFormat(
format,data):void
Defined in: graph/src/graph.ts:1937
Parameters
format
string
data
VertexData
Returns
void
fromJSON()
staticfromJSON<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
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
inferCycles()
inferCycles():
Set<Vertex[]>
Defined in: graph/src/graph.ts:1108
Returns
Set<Vertex[]>
Implementation of
isAcyclic()
isAcyclic():
boolean
Defined in: graph/src/graph.ts:1412
Returns
boolean
Implementation of
isConnected()
isConnected():
boolean
Defined in: graph/src/graph.ts:1461
Returns
boolean
Implementation of
isCyclic()
isCyclic():
boolean
Defined in: graph/src/graph.ts:1408
Returns
boolean
Implementation of
isDense()
isDense(
threshold):boolean
Defined in: graph/src/graph.ts:1535
Parameters
threshold
number = 0.5
Returns
boolean
Implementation of
isDirected()
isDirected():
boolean
Defined in: graph/src/graph.ts:1443
Returns
boolean
Implementation of
isForest()
isForest():
boolean
Defined in: graph/src/graph.ts:1432
Returns
boolean
Implementation of
isMixed()
isMixed():
boolean
Defined in: graph/src/graph.ts:1530
Returns
boolean
Implementation of
isSparse()
isSparse(
threshold):boolean
Defined in: graph/src/graph.ts:1539
Parameters
threshold
number = 0.5
Returns
boolean
Implementation of
isStronglyConnected()
isStronglyConnected():
boolean
Defined in: graph/src/graph.ts:1504
Returns
boolean
Implementation of
isTree()
isTree():
boolean
Defined in: graph/src/graph.ts:1416
Returns
boolean
Implementation of
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
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
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
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
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
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
Inherited from
EventEmitter.once
order()
order():
number
Defined in: graph/src/graph.ts:1400
Returns
number
Implementation of
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
removeVertex()
removeVertex(
v):boolean
Defined in: graph/src/graph.ts:1610
Parameters
v
Vertex
Returns
boolean
Implementation of
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
size()
size():
number
Defined in: graph/src/graph.ts:1404
Returns
number
Implementation of
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
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>