# Legato.Graph.DirectedGraph

Implements a directed graph.

Summary

Legato.Graph.DirectedGraph | Implements a directed graph.
Properties |
vertices | {Object} Name/{Legato.Graph.Vertex} map.
Functions |
initialize | Constructs a new directed graph.
getVertex | Returns: {Legato.Graph.Vertex} Existing vertex for the given name or null if no vertex found.
getOrCreateVertex | Returns: {Legato.Graph.Vertex} Either existing or a new vertex for the given name.
addEdge | Creates an edge between two vertices.
removeEdge | Removes an edge between two vertices.
clone | Clones the graph.
toArray | Performs 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.