let width; let height; let margin; let nodes_list = []; let nodes = []; let edges = []; let area ; let k ; let t ; function preload() { edges_table = loadTable('3980.edges.csv','csv'); } function setup() { width = 1000; height = 1000; margin = 100; createCanvas(width,height); background(245,255,250); for(var j=0;j nodes[j].getPos().getX() -10 && mouseY < nodes[j].getPos().getY() +10 && mouseY > nodes[j].getPos().getY() -10) { textSize(15); fill(0,0,0); text(nodes[j].getName(),mouseX+5,mouseY-15); } } } function calculate_attractive_force(x,k) { return Math.pow(x,2)/k; } function calculate_repulsive_force(x,k) { return Math.pow(k,2)/x; } function calculate_slope_and_intercept(node1, node2) { let slope; let intercept; slope = (node2.getPos().getY() - node1.getPos().getY())/(node2.getPos().getX() - node1.getPos().getX()); intercept = node1.getPos().getY() - (slope*node1.getPos().getX()); return [slope,intercept]; } class vector { constructor(x,y) { this.x = x; this.y = y; } getX() { return this.x ; } getY() { return this.y ; } } class Node { constructor(name,pos) { this.name = name; this.pos = pos; this.disp = new vector(0,0); } getName() { return this.name; } getPos() { return this.pos; } setPos(pos) { this.pos = pos; } setDisp(x,y) { this.disp = new vector(x,y); } getDisp() { return this.disp; } show() { push(); strokeWeight(1); stroke(139,0,139); fill(11,211,211); ellipse(this.pos.getX(),this.pos.getY(),10,10); pop(); } } class Edge { constructor(node1,node2) { this.node1 = node1; this.node2 = node2; } getNode1() { return this.node1; } getNode2() { return this.node2; } show() { push(); push(); strokeWeight(1); stroke(220,220,220); line(this.node1.getPos().getX(),this.node1.getPos().getY(), this.node2.getPos().getX(),this.node2.getPos().getY()); pop(); pop(); } }