directed-graph
Represents a directed graph.
Get it
Download from NPM (typescript types are included):
npm install --save @stugotech/directed-graph
Use it
DirectedGraph<T>
Class A directed graph with vertices of type T
.
addVertex(vertex: T)
Method Add a vertex to the graph.
addEdge(source: T, target: T)
Method Add an edge between source
and target
. This will add any vertices it not already known.
edges(): Map<T, T[]>
Method Get a map of the edges (source to target).
leaves(): T[]
Method Get all vertices with no outgoing edges.
reverse(): DirectedGraph<T>
Method Return a graph which has the same vertices with all edges reversed.
getAdjacencyToNode(root: T): Map<T, number>
Method Generate a map containing all vertices reachable from root
as the keys, and the path lengths to the respective vertices from the root as the values.
Build it
This package uses gulp. To build, run:
gulp
This will run clean
and tsc
tasks.
Licence
See LICENCE.md.