Class: Graph

Graph()

new Graph()

Create an empty graph object. Defaults to unlabeled, undirected, and unweighted graph.
Author:
  • Muhammad Al-Hashimi
Source:

Members

adjMatrix

Graph adjacency matrix, to be created on demand via Graph#makeAdjMatrix method. Should be reset or recreated after changes to vertices and edges.
Default Value:
  • [ ]
Source:

bfs_order

Array of vertex id in BFS order. Stores output of last BFS and should be reset or recreated after changes to vertex and edge sets.
Default Value:
  • [ ]
Source:

connectedComp

Number of connected components (0: no info), is set after a DFS/BFS
Default Value:
  • 0
Source:
See:

dfs_push

Array of vertex id in DFS order. Stores output of last DFS and should be reset or recreated after changes to vertex and edge sets.
Default Value:
  • [ ]
Source:

digraph :boolean

True if graph is directed (digraph), false otherwise
Typeboolean
Default Value:
  • false
Source:

label

An identification text string to label graph
Default Value:
  • empty string
Source:

ne

Number of edges, initially 0
Default Value:
  • 0
Source:

nv

Number of vertices, initially 0
Default Value:
  • 0
Source:

verts :Array.<Vertex>

Vertex list
TypeArray.<Vertex>
Default Value:
  • [ ]
Source:

weighted :boolean

True if graph is weighted, false otherwise
Typeboolean
Default Value:
  • false
Source:

Methods

addEdge()

Insert an edge
Source:

bfs()

Visit connected vertices breadth-first starting at some vertex
Source:

componentInfo()

Get printable connectivity info strings, details depend on implementation.
Source:

dfs()

Visit connected vertices depth-first starting at some vertex
Source:

isConnected()

Test if graph is connected returning true, otherwise false
Source:

listVerts()

List graph vertices using info strings returned by Vertex methods
Source:
See:

makeAdjMatrix()

Create adjacency (or weight, if graph weighted) matrix
Source:

makeGraph()

Create a random graph, details depend on implementation
Source:
See:
To Do:
  • Not part of Project 1. To be implemented in the Final Project.

printGraph()

Print graph information. See implementing function for details.
Source:

readGraph()

Graph reader, defaults to internal format, details depend on implementation
Source:
See:

topoSearch()

Perform a search-like topological traversal of graph vertices. This method iterates on connected components, calling a specified traversal method (e.g., dfs) on each component, see implementing function for details.
Source: