Constructor
new Vertex(value, xopt, yopt)
Properties:
Name | Type | Description |
---|---|---|
id |
Number | The id of this vertex. |
value |
Atom | The atom associated with this vertex. |
position |
Vector2 | The position of this vertex. |
previousPosition |
Vector2 | The position of the previous vertex. |
parentVertexId |
Number | null | The id of the previous vertex. |
children |
Array.<Number> | The ids of the children of this vertex. |
spanningTreeChildren |
Array.<Number> | The ids of the children of this vertex as defined in the spanning tree defined by the SMILES. |
edges |
Array.<Number> | The ids of edges associated with this vertex. |
positioned |
Boolean | A boolean indicating whether or not this vertex has been positioned. |
angle |
Number | The angle of this vertex. |
dir |
Number | The direction of this vertex. |
neighbourCount |
Number | The number of neighbouring vertices. |
neighbours |
Array.<Number> | The vertex ids of neighbouring vertices. |
neighbouringElements |
Array.<String> | The element symbols associated with neighbouring vertices. |
forcePositioned |
Boolean | A boolean indicating whether or not this vertex was positioned using a force-based approach. |
The constructor for the class Vertex.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
Atom | The value associated with this vertex. |
||
x |
Number |
<optional> |
0
|
The initial x coordinate of the positional vector of this vertex. |
y |
Number |
<optional> |
0
|
The initial y coordinate of the positional vector of this vertex. |
Methods
addChild(vertexId)
Add a child vertex id to this vertex.
Parameters:
Name | Type | Description |
---|---|---|
vertexId |
Number | The id of a vertex to be added as a child to this vertex. |
addRingbondChild(vertexId, ringbondIndex)
Add a child vertex id to this vertex as the second child of the neighbours array, except this vertex is the first vertex of the SMILE string, then it is added as the first. This is used to get the correct ordering of neighbours for parity calculations. If a hydrogen is implicitly attached to the chiral center, insert as the third child.
Parameters:
Name | Type | Description |
---|---|---|
vertexId |
Number | The id of a vertex to be added as a child to this vertex. |
ringbondIndex |
Number | The index of the ringbond. |
clone() → {Vertex}
Clones this vertex and returns the clone.
Returns:
A clone of this vertex.
- Type
- Vertex
equals(vertex) → {Boolean}
Returns true if this vertex and the supplied vertex both have the same id, else returns false.
Parameters:
Name | Type | Description |
---|---|---|
vertex |
Vertex | The vertex to check. |
Returns:
A boolean indicating whether or not the two vertices have the same id.
- Type
- Boolean
getAngle(referenceVectoropt, returnAsDegreesopt) → {Number}
Returns the angle of this vertexes positional vector. If a reference vector is supplied in relations to this vector, else in relations to the coordinate system.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
referenceVector |
Vector2 |
<optional> |
null
|
The reference vector. |
returnAsDegrees |
Boolean |
<optional> |
false
|
If true, returns angle in degrees, else in radians. |
Returns:
The angle of this vertex.
- Type
- Number
getDrawnNeighbours(vertices) → {Array.<Number>}
Returns an array of ids of neighbouring vertices that will be drawn (vertex.value.isDrawn === true).
Parameters:
Name | Type | Description |
---|---|---|
vertices |
Array.<Vertex> | An array containing the vertices associated with the current molecule. |
Returns:
An array containing the ids of neighbouring vertices that will be drawn.
- Type
- Array.<Number>
getNeighbourCount() → {Number}
Returns the number of neighbours of this vertex.
Returns:
The number of neighbours.
- Type
- Number
getNeighbours(vertexIdopt) → {Array.<Number>}
Returns an array of ids of neighbouring vertices.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
vertexId |
Number |
<optional> |
null
|
If a value is supplied, the vertex with this id is excluded from the returned indices. |
Returns:
An array containing the ids of neighbouring vertices.
- Type
- Array.<Number>
getNextInRing(vertices, ringId, previousVertexId) → {Number}
Gets the next vertex in the ring in opposide direction to the supplied vertex id.
Parameters:
Name | Type | Description |
---|---|---|
vertices |
Array.<Vertex> | The array of vertices for the current molecule. |
ringId |
Number | The id of the ring containing this vertex. |
previousVertexId |
Number | The id of the previous vertex. The next vertex will be opposite from the vertex with this id as seen from this vertex. |
Returns:
The id of the next vertex in the ring.
- Type
- Number
getSpanningTreeNeighbours(vertexIdopt) → {Array.<Number>}
Returns a list of ids of vertices neighbouring this one in the original spanning tree, excluding the ringbond connections.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
vertexId |
Number |
<optional> |
null
|
If supplied, the vertex with this id is excluded from the array returned. |
Returns:
An array containing the ids of the neighbouring vertices.
- Type
- Array.<Number>
getTextDirection(vertices) → {String}
Returns the suggested text direction when text is added at the position of this vertex.
Parameters:
Name | Type | Description |
---|---|---|
vertices |
Array.<Vertex> | The array of vertices for the current molecule. |
Returns:
The suggested direction of the text.
- Type
- String
isTerminal() → {Boolean}
Returns true if this vertex is terminal (has no parent or child vertices), otherwise returns false. Always returns true if associated value has property hasAttachedPseudoElements set to true.
Returns:
A boolean indicating whether or not this vertex is terminal.
- Type
- Boolean
setParentVertexId(parentVertexId)
Set the vertex id of the parent.
Parameters:
Name | Type | Description |
---|---|---|
parentVertexId |
Number | The parents vertex id. |
setPosition(x, y)
Set the 2D coordinates of the vertex.
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | The x component of the coordinates. |
y |
Number | The y component of the coordinates. |
setPositionFromVector(v)
Set the 2D coordinates of the vertex from a Vector2.
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 | A 2D vector. |