new Node(x, y)
A node in grid. This class holds some basic information about a node and custom attributes may be added, depending on the algorithms' needs. Note: if you want to monitor how your algorithm works, it's better to use the `set' and `get' methods when accessing the nodes' attriubtes since it will be easier to add hooks.
- Source:
- ./src/core/Node.js, line 13
Parameters:
Name | Type | Description |
---|---|---|
x |
number | The x coordinate of the node on the grid. |
y |
number | The y coordinate of the node on the grid. |
Properties
-
<private> parent :Array.<number, number>
-
This node's parent node. This variable will be used to construct the path after the search is done.
- Source:
- ./src/core/Node.js, line 38
-
<private> walkable :boolean
-
Whether this node can be walked through.
- Source:
- ./src/core/Node.js, line 31
-
<private> x :number
-
The x coordinate of the node on the grid.
- Source:
- ./src/core/Node.js, line 19
-
<private> y :number
-
The y coordinate of the node on the grid.
- Source:
- ./src/core/Node.js, line 25
Methods
-
get(attr) → {*}
-
Generic getter of the attribute of the node.
- Source:
- ./src/core/Node.js, line 60
Parameters:
Name Type Description attr
string Attribute name Returns:
The value of the attribute.- Type
- *
-
set(attr, value)
-
Generic setter of the attribute of the node.
- Source:
- ./src/core/Node.js, line 50
Parameters:
Name Type Description attr
string Attribute name. value
* Attribute value.