Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | /** * Vertex */ let vertexId = 0 export default class Vertex { /** * Vertex constructor * * @param {Object} point the Point (a Stop, Place, etc.) attached to this vertex * @param {Number} x * @param {Number} y */ constructor(point, x, y) { this.id = vertexId++ this.point = point this.point.graphVertex = this this.x = this.origX = x this.y = this.origY = y this.edges = [] } getId() { return this.id } getRenderX(display) { return display.xScale.compute(this.x) + this.point.placeOffsets.x } getRenderY(display) { return display.yScale.compute(this.y) + this.point.placeOffsets.y } /** * Move to new coordinate * * @param {Number} * @param {Number} */ moveTo(x, y) { this.x = x this.y = y /* this.edges.forEach(function (edge) { edge.calculateVectors(); }); */ } /** * Get array of edges incident to vertex. Allows specification of "incoming" * edge that will not be included in results. * * @param {Edge} inEdge optional incoming edge tp ignore */ incidentEdges(inEdge) { return this.edges.filter((edge) => edge !== inEdge) } /** * Add an edge to the vertex's edge list * * @param {Edge} edge */ addEdge(edge) { const index = this.edges.indexOf(edge) if (index === -1) this.edges.push(edge) } /** * Remove an edge from the vertex's edge list * * @param {Edge} edge */ removeEdge(edge) { const index = this.edges.indexOf(edge) if (index !== -1) this.edges.splice(index, 1) } toString() { return `Vertex ${this.getId()} (${ this.point ? this.point.toString() : 'no point assigned' })` } } |