Skip to main content

Graph

Graph<V, E>

Overview needed

Template Parameters

  • V – The type for the vertices of the graph.
  • E – The type for the weight of the edges of the graph.

Constructor

public Graph

new Graph()

*Description needed*

Properties

No publicly accessible properties on Graph

private list: Map<V, Edge<V, E>[]>

Description needed

private reverseList: Map<V, Edge<V, E>[]>

Description needed


Methods

private dfs

dfs(visited, v) => void

Description needed

Parameters

  •  visited: Map<V, false | true>Description needed

  •  v: VDescription needed

public createNode

createNode(value) => void

Description needed

Parameters

  •  value: VDescription needed

public createEdge

createEdge(source, target, weight) => void

Description needed

Parameters

  •  source: VDescription needed

  •  target: VDescription needed

  •  weight: EDescription needed

public isConnected

isConnected() => false | true

Description needed

Returns

  •   false | trueDescription needed

public getSources

getSources() => V[]

Description needed

Returns

  •   V[]Description needed

public getSinks

getSinks() => V[]

Description needed

Returns

  •   V[]Description needed

public getEndNodes

getEndNodes() => V[]

Description needed

Returns

  •   V[]Description needed

public size

size() => number

Description needed

Returns

  •   numberDescription needed

public getDegree

getDegree(node) => number

Description needed

Parameters

  •  node: VDescription needed

Returns

  •   numberDescription needed

public getConnections

getConnections(value) => Edge<V, E>[]

Description needed

Parameters

  •  value: VDescription needed

Returns

public getNodes

getNodes() => V[]

Description needed

Returns

  •   V[]Description needed

private getNodeDepths

getNodeDepths(max) => V[][]

Description needed

Parameters

  •  max: false | trueDescription needed

Returns

  •   V[][]Description needed

public getMaxNodeDepths

getMaxNodeDepths() => V[][]

Used to get the max "depth" of each node where the source nodes have a depth of 0 and each additional layer adds +1 to the depth. If a node has parents at multiple depths such as 1 and 3, then it inherits from the "deeper" one, so the node would have a depth of 4. This should only be called if the isConnected() is true and the graph is acyclic.

Returns

  •   V[][] – A map where each key is each node and the value is the max depth of that node.

public getMinNodeDepths

getMinNodeDepths() => V[][]

Used to get the min "depth" of each node where the source nodes have a depth of 0 and each additional layer adds +1 to the depth. If a node has parents at multiple depths such as 1 and 3, then it inherits from the "shallower" one, so the node would have a depth of 2. This should only be called if the isConnected() is true and the graph is acyclic.

Returns

  •   V[][] – A map where each key is each node and the value is the max depth of that node.

Static Methods

No static methods for Graph


Edge<V, E>

Overview needed

Template Parameters

  • V – The type for the vertices of the edge.
  • E – The type for weight of the edge.

Constructor

public Edge

new Edge(target, weight)

*Description needed*

Parameters

  •  target: VDescription needed

  •  weight: EDescription needed


Properties

No publicly accessible properties on Edge

private target: V

Description needed

private weight: E

Description needed


Methods

public getTarget

getTarget() => V

Description needed

Returns

  •   VDescription needed

public getWeight

getWeight() => E

Description needed

Returns

  •   EDescription needed

Static Methods

No static methods for Edge