gramoloss
Version:
Graph theory package for edition and computation
42 lines (41 loc) • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Vertex = void 0;
const coord_1 = require("./coord");
class Vertex {
constructor(graph, index, stackedIndex, x, y) {
this.index = index;
this.stackedIndex = stackedIndex;
this.graph = graph;
this.neighbors = new Map();
this.inNeighbors = new Map();
this.outNeighbors = new Map();
this.incidentLinks = new Map();
this.pos = new coord_1.Coord(x, y);
this.color = "Neutral";
this.innerLabel = "";
this.outerLabel = "";
}
degree() {
return this.neighbors.size;
}
indegree() {
return this.inNeighbors.size;
}
outdegree() {
return this.outNeighbors.size;
}
distTo(other) {
return Math.sqrt(this.getPos().dist2(other.getPos()));
}
translate(shift) {
this.getPos().translate(shift);
}
getPos() {
return this.pos;
}
isInRectangle(c1, c2) {
return this.getPos().isInRect(c1, c2);
}
}
exports.Vertex = Vertex;