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. |
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.
-
copy(edge) → {Edge}
-
Copies all values from the given edge to this edge.
Parameters:
Name Type Description edge
Edge The edge to copy.
-
fromJSON(json) → {Edge}
-
Restores this instance from the given JSON object.
Parameters:
Name Type Description json
Object The JSON object.
-
toJSON() → {Object}
-
Transforms this instance into a JSON object.
Returns:
Object -The JSON object.