Legato.Graph.DirectedGraph

Implements a directed graph.

Summary
Legato.Graph.DirectedGraphImplements a directed graph.
Properties
vertices{Object} Name/{Legato.Graph.Vertex} map.
Functions
initializeConstructs a new directed graph.
getVertexReturns: {Legato.Graph.Vertex} Existing vertex for the given name or null if no vertex found.
getOrCreateVertexReturns: {Legato.Graph.Vertex} Either existing or a new vertex for the given name.
addEdgeCreates an edge between two vertices.
removeEdgeRemoves an edge between two vertices.
cloneClones the graph.
toArrayPerforms the topological sorting of the given graph and returns the array of vertex names in the sorted order.

Properties

vertices

{Object} Name/{Legato.Graph.Vertex} map.

Functions

initialize

initialize : function()

Constructs a new directed graph.

getVertex

getVertex : function(name)

Returns: {Legato.Graph.Vertex} Existing vertex for the given name or null if no vertex found.

Parameters

name{String} name of the vertex.

getOrCreateVertex

getOrCreateVertex : function(name)

Returns: {Legato.Graph.Vertex} Either existing or a new vertex for the given name.

Parameters

name{String} name of the vertex.

addEdge

addEdge : function(parentName,
childName)

Creates an edge between two vertices.

Parameters

parentName{String} name of the parent vertex.  Parameters:
childName{String} name of the child vertex.

removeEdge

removeEdge : function(parentName,
childName)

Removes an edge between two vertices.

Parameters

parentName{String} name of the parent vertex.  Parameters:
childName{String} name of the child vertex.

clone

clone : function()

Clones the graph.

Returns: {Legato.Graph.DirectedGraph} A clone of this graph.

toArray

toArray : function()

Performs the topological sorting of the given graph and returns the array of vertex names in the sorted order.

Returns

{Array(String)} Topologically sorted array of vertex names.

Implements a vertex of the directed graph.
initialize : function()
Constructs a new directed graph.
getVertex : function(name)
Returns: {Legato.Graph.Vertex} Existing vertex for the given name or null if no vertex found.
getOrCreateVertex : function(name)
Returns: {Legato.Graph.Vertex} Either existing or a new vertex for the given name.
addEdge : function(parentName,
childName)
Creates an edge between two vertices.
removeEdge : function(parentName,
childName)
Removes an edge between two vertices.
clone : function()
Clones the graph.
toArray : function()
Performs the topological sorting of the given graph and returns the array of vertex names in the sorted order.
Implements a directed graph.