var table; var sub; var s = 50; var v1 = []; var v2 = []; var edges = []; var count1 = 50; var width = 1200; var length = 1200; function preload() { table = loadStrings('0.txt'); //sub = subset(table, 0, 50); } var temp1; var temp2; function setup() { createCanvas(1300, 1300); for (var i = 0; i < s; i++) { temp = split(table[i], ' '); temp1 = new Vertex(temp[0], 50, count1); temp2 = new Vertex(temp[1],count1, 50); v1.push(temp1); v2.push(temp2); edges.push(new Edge(temp1, temp2)); count1 = count1 + 20; } } function draw() { //matrix //generate lines w/for loop var count = 50; //for(var i = 0; i < table.getRowCount(); i++) { for(var i = 0; i <= s; i++) { //vertical line(count, 50, count, 1050); //horizontal line(50, count, 1050, count); count = count + 20; } //display labels vertical count = 65; for(var i = 0; i < v1.length; i++) { text(v1[i].id, 10, count); //v1[i].x = count; //v1[i].y = count; count = count + 20; } //display labels horizontal count = 50; for(var i = 0; i < v1.length; i++) { if(i % 2 == 0) { text(v1[i].id, count, 40); } else { text(v1[i].id, count, 30); } //v2[i].x = count; //v2[i].y = count; count = count + 20; } //display rectangles/edges for(var i = 0; i < v1.length; i++) { for (var j = 0; j < v2.length; j++) { if (v1[i] == v2[j]) { fill('green'); rect(edges[i].v1.y, edges[i].v2.x, 20, 20); } } } } //vertex object function Vertex(id, x, y) { this.x = x; this.y = y; this.pos = [this.x, this.y]; this.id = id; this.disp; this.display = function() { ellipse(this.x, this.y, 8, 8); } } //edge object function Edge(v1, v2) { this.v1 = v1; this.v2 = v2; this.display = function() { } }