Class: DiGraph

DiGraph()

An unweighted directed graph that does not allow parallel edges

Constructor

new DiGraph()

Constructs a new empty DiGraph.
Source:

Extends

Classes

DiGraph

Members

adj

Returns an immutable copy of the adjacency list.
Overrides:
Source:

Methods

addEdge()

Source:

addPath(path)

Adds all the edges in the path to the graph.
Parameters:
Name Type Description
path Array.<V> the path to add.
Overrides:
Source:

addVertex()

Source:

edges()

Source:

fromEdgeList(edgeList)

Adds all the edges in the edge list to the graph
Parameters:
Name Type Description
edgeList Array.<Array.<V>> the list of edges to add.
Overrides:
Source:

hasEdge()

Source:

hasVertex(v) → {boolean}

Determines if the graph contains the vertex v.
Parameters:
Name Type Description
v V the vertex to check.\
Overrides:
Source:
Returns:
true if the graph contains the vertex v, false otherwise.
Type
boolean

inDegree()

Source:

isDirected()

Source:

neighbors()

Source:

numberOfNodes() → {number}

Returns the number of vertices in the graph.
Overrides:
Source:
Returns:
the number of vertices in the graph.
Type
number

outDegree()

Source:

removeEdge()

Source:

removeVertex(v)

Removes a vertex from the graph.
Parameters:
Name Type Description
v V the vertex to remove.
Overrides:
Source:

toString() → {string}

Returns a string representation of the graph. Just calls the toString() method of the underlying adjacency list.
Overrides:
Source:
Returns:
a string representation of the graph.
Type
string

validateEdge(v, w)

Validates that the edge (v, w) exists in the graph.
Parameters:
Name Type Description
v V
w V
Overrides:
Source:
Throws:
EdgeDoesNotExistError if the edge does not exist.

validateVertex(v)

Validates that the vertex v exists in the graph.
Parameters:
Name Type Description
v V
Overrides:
Source:
Throws:
VertexDoesNotExistError if the vertex does not exist.

vertices() → {Array.<V>}

Returns an array of all the vertices in the graph.
Overrides:
Source:
Returns:
an array of all the vertices in the graph.
Type
Array.<V>