提交 8f0f4be1 编写于 作者: J Jason Park

rename Graph to DirectedGraph, and WeightedGraph to WeightedDirectedGraph

上级 29ed1f4c
......@@ -108,8 +108,8 @@
<script src="js/sigma/plugins/sigma.plugins.dragNodes.min.js"></script>
<script src="js/ace/ace.js"></script>
<script src="js/module/tracer.js"></script>
<script src="js/module/graph.js"></script>
<script src="js/module/weighted_graph.js"></script>
<script src="js/module/directed_graph.js"></script>
<script src="js/module/directed_weighted_graph.js"></script>
<script src="js/module/array2d.js"></script>
<script src="js/module/array1d.js"></script>
<script src="js/script.js"></script>
......
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;
......
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);
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册