Edge(from, to, cost)

Base class for graph edges.

new Edge(from, to, cost)

Constructs a new edge.

Parameters:
Name Type Default Description
from Number

The index of the from node.

to Number

The index of the to node.

cost Number 0

The cost of this edge.

Author:

Members

cost :Number

The cost of this edge. This could be for example a distance or time value.

Default Value:
  • 0

from :Number

The index of the from node.

Default Value:
  • -1

to :Number

The index of the to node.

Default Value:
  • -1

Methods

clone() → {Edge}

Creates a new edge and copies all values from this edge.

Returns:
Edge -

A new edge.

copy(edge) → {Edge}

Copies all values from the given edge to this edge.

Parameters:
Name Type Description
edge Edge

The edge to copy.

Returns:
Edge -

A reference to this edge.

fromJSON(json) → {Edge}

Restores this instance from the given JSON object.

Parameters:
Name Type Description
json Object

The JSON object.

Returns:
Edge -

A reference to this edge.

toJSON() → {Object}

Transforms this instance into a JSON object.

Returns:
Object -

The JSON object.