From 8f0f4be10e0a93d5aa8b203f9f600d04bc8fd3d1 Mon Sep 17 00:00:00 2001 From: Jason Park Date: Sun, 22 May 2016 03:47:55 -0500 Subject: [PATCH] rename Graph to DirectedGraph, and WeightedGraph to WeightedDirectedGraph --- index.html | 4 +-- js/module/{graph.js => directed_graph.js} | 28 +++++++++---------- ...ed_graph.js => directed_weighted_graph.js} | 26 ++++++++--------- 3 files changed, 29 insertions(+), 29 deletions(-) rename js/module/{graph.js => directed_graph.js} (92%) rename js/module/{weighted_graph.js => directed_weighted_graph.js} (87%) diff --git a/index.html b/index.html index 0259c81..0c69643 100644 --- a/index.html +++ b/index.html @@ -108,8 +108,8 @@ - - + + diff --git a/js/module/graph.js b/js/module/directed_graph.js similarity index 92% rename from js/module/graph.js rename to js/module/directed_graph.js index e156a81..d536834 100644 --- a/js/module/graph.js +++ b/js/module/directed_graph.js @@ -1,31 +1,31 @@ var s = null, graph = null, sigmaCanvas = null; -function GraphTracer(module) { - if (Tracer.call(this, module || GraphTracer)) { +function DirectedGraphTracer(module) { + if (Tracer.call(this, module || DirectedGraphTracer)) { initGraph(); return true; } return false; } -GraphTracer.prototype = Object.create(Tracer.prototype); -GraphTracer.prototype.constructor = GraphTracer; +DirectedGraphTracer.prototype = Object.create(Tracer.prototype); +DirectedGraphTracer.prototype.constructor = DirectedGraphTracer; // Override -GraphTracer.prototype.resize = function () { +DirectedGraphTracer.prototype.resize = function () { Tracer.prototype.resize.call(this); this.refresh(); }; // Override -GraphTracer.prototype.clear = function () { +DirectedGraphTracer.prototype.clear = function () { Tracer.prototype.clear.call(this); clearGraphColor(); }; -var Graph = { +var DirectedGraph = { random: function (N, ratio) { if (!N) N = 5; if (!ratio) ratio = .3; @@ -41,7 +41,7 @@ var Graph = { } }; -GraphTracer.prototype._setTreeData = function (G, root) { +DirectedGraphTracer.prototype._setTreeData = function (G, root) { root = root || 0; var maxDepth = -1; @@ -84,7 +84,7 @@ GraphTracer.prototype._setTreeData = function (G, root) { }; // Override -GraphTracer.prototype._setData = function (G) { +DirectedGraphTracer.prototype._setData = function (G) { if (Tracer.prototype._setData.call(this, arguments)) return true; graph.clear(); @@ -130,15 +130,15 @@ GraphTracer.prototype._setData = function (G) { return false; }; -GraphTracer.prototype._visit = function (target, source) { +DirectedGraphTracer.prototype._visit = function (target, source) { this.pushStep({type: 'visit', target: target, source: source}, true); }; -GraphTracer.prototype._leave = function (target, source) { +DirectedGraphTracer.prototype._leave = function (target, source) { this.pushStep({type: 'leave', target: target, source: source}, true); }; -GraphTracer.prototype.processStep = function (step, options) { +DirectedGraphTracer.prototype.processStep = function (step, options) { switch (step.type) { case 'visit': case 'leave': @@ -160,14 +160,14 @@ GraphTracer.prototype.processStep = function (step, options) { }; // Override -GraphTracer.prototype.refresh = function () { +DirectedGraphTracer.prototype.refresh = function () { Tracer.prototype.refresh.call(this); s.refresh(); }; // Override -GraphTracer.prototype.prevStep = function () { +DirectedGraphTracer.prototype.prevStep = function () { this.clear(); $('#tab_trace .wrapper').empty(); var finalIndex = this.traceIndex - 1; diff --git a/js/module/weighted_graph.js b/js/module/directed_weighted_graph.js similarity index 87% rename from js/module/weighted_graph.js rename to js/module/directed_weighted_graph.js index df87bd4..db47860 100644 --- a/js/module/weighted_graph.js +++ b/js/module/directed_weighted_graph.js @@ -1,22 +1,22 @@ -function WeightedGraphTracer(module) { - if (GraphTracer.call(this, module || WeightedGraphTracer)) { +function WeightedDirectedGraphTracer(module) { + if (DirectedGraphTracer.call(this, module || WeightedDirectedGraphTracer)) { initWeightedGraph(); return true; } return false; } -WeightedGraphTracer.prototype = Object.create(GraphTracer.prototype); -WeightedGraphTracer.prototype.constructor = WeightedGraphTracer; +WeightedDirectedGraphTracer.prototype = Object.create(DirectedGraphTracer.prototype); +WeightedDirectedGraphTracer.prototype.constructor = WeightedDirectedGraphTracer; // Override -WeightedGraphTracer.prototype.clear = function () { - GraphTracer.prototype.clear.call(this); +WeightedDirectedGraphTracer.prototype.clear = function () { + DirectedGraphTracer.prototype.clear.call(this); clearWeights(); }; -var WeightedGraph = { +var WeightedDirectedGraph = { random: function (N, ratio, min, max) { if (!N) N = 5; if (!ratio) ratio = .3; @@ -39,7 +39,7 @@ var WeightedGraph = { }; // Override -WeightedGraphTracer.prototype._setData = function (G) { +WeightedDirectedGraphTracer.prototype._setData = function (G) { if (Tracer.prototype._setData.call(this, arguments)) return true; graph.clear(); @@ -87,20 +87,20 @@ WeightedGraphTracer.prototype._setData = function (G) { return false; }; -GraphTracer.prototype._weight = function (target, weight, delay) { +DirectedGraphTracer.prototype._weight = function (target, weight, delay) { this.pushStep({type: 'weight', target: target, weight: weight}, delay); }; -GraphTracer.prototype._visit = function (target, source, weight) { +DirectedGraphTracer.prototype._visit = function (target, source, weight) { this.pushStep({type: 'visit', target: target, source: source, weight: weight}, true); }; -GraphTracer.prototype._leave = function (target, source, weight) { +DirectedGraphTracer.prototype._leave = function (target, source, weight) { this.pushStep({type: 'leave', target: target, source: source, weight: weight}, true); }; //Override -WeightedGraphTracer.prototype.processStep = function (step, options) { +WeightedDirectedGraphTracer.prototype.processStep = function (step, options) { switch (step.type) { case 'weight': var targetNode = graph.nodes(n(step.target)); @@ -124,7 +124,7 @@ WeightedGraphTracer.prototype.processStep = function (step, options) { printTrace(visit ? source + ' -> ' + step.target : source + ' <- ' + step.target); break; default: - GraphTracer.prototype.processStep.call(this, step, options); + DirectedGraphTracer.prototype.processStep.call(this, step, options); } }; -- GitLab