Class: Graph

Graph

new Graph()

A Graph object with the basic properties
Properties:
Name Type Description
vertices object The vertices of the graph
edges array The edges of the graph
length number Length of the graph
Source:
  • source-jsdoc.js

Classes

Edge
Vertex

Members

edges

Array of edges of the Graph
Source:
  • source-jsdoc.js

length

Length of the Graph, initially set to 0
Source:
  • source-jsdoc.js

vertices

Object for holding vertices of the Graph
Source:
  • source-jsdoc.js

Methods

addEdge() → {Graph.Edge}

Method for adding new Graph.Edge
Source:
  • source-jsdoc.js
Returns:
An instance of a Graph.Edge
Type
Graph.Edge

addVertex(name, value) → {Graph.Vertex}

Add a new Graph.Vertex or updates the value of an existing one
Parameters:
Name Type Description
name string Name of the new vertex
value number Value of the new vertex
Source:
  • source-jsdoc.js
Returns:
New or updated Graph.Vertex
Type
Graph.Vertex
Example
var newVertex = Graph.addVertex("vertex1", 20);