提交 0a03a153 编写于 作者: J Jason Park

add Selection Sort

上级 f6fd5293
......@@ -17,8 +17,12 @@ Array1DTracer.prototype.setData = function (D) {
};
// Override
Array1DTracer.prototype._notify = function (idx) {
Array2DTracer.prototype._notify.call(this, 0, idx);
Array1DTracer.prototype._notify = function (idx1, idx2) {
if (idx2 === undefined) {
Array2DTracer.prototype._notify.call(this, 0, idx1);
} else {
Array2DTracer.prototype._notify.call(this, 0, idx1, 0, idx2);
}
};
// Override
......
......@@ -59,9 +59,12 @@ Array2DTracer.prototype.setData = function (D) {
return false;
};
Array2DTracer.prototype._notify = function (x, y) {
this.pushStep({type: 'notifying', x: x, y: y, value: this.D[x][y]}, true);
this.pushStep({type: 'notified', x: x, y: y}, false);
Array2DTracer.prototype._notify = function (x1, y1, x2, y2) {
var second = x2 !== undefined && y2 !== undefined;
this.pushStep({type: 'notifying', x: x1, y: y1, value: this.D[x1][y1]}, !second);
if (second) this.pushStep({type: 'notifying', x: x2, y: y2, value: this.D[x2][y2]}, true);
this.pushStep({type: 'notified', x: x1, y: y1}, false);
if (second) this.pushStep({type: 'notified', x: x2, y: y2}, false);
};
Array2DTracer.prototype._select = function (sx, sy, ex, ey) {
......
......@@ -37,7 +37,6 @@ GraphTracer.prototype.createRandomData = function (N, ratio) {
else G[i].push((Math.random() * (1 / ratio) | 0) == 0 ? 1 : 0);
}
}
console.log(G);
return G;
};
......@@ -86,7 +85,7 @@ GraphTracer.prototype.setTreeData = function (G, root) {
// Override
GraphTracer.prototype.setData = function (G) {
if (Tracer.prototype.setData.call(this, arguments)) return true;
graph.clear();
var nodes = [];
var edges = [];
......
......@@ -34,13 +34,12 @@ WeightedGraphTracer.prototype.createRandomData = function (N, ratio, min, max) {
}
}
}
console.log(G);
return G;
};
// Override
WeightedGraphTracer.prototype.setData = function (G) {
if (Tracer.prototype.setData.call(this, arguments)) return;
if (Tracer.prototype.setData.call(this, arguments)) return true;
graph.clear();
var nodes = [];
......@@ -83,6 +82,8 @@ WeightedGraphTracer.prototype.setData = function (G) {
ratio: 1
});
this.refresh();
return false;
};
GraphTracer.prototype._weight = function (target, weight, delay) {
......@@ -99,7 +100,6 @@ GraphTracer.prototype._leave = function (target, source, weight) {
//Override
WeightedGraphTracer.prototype.processStep = function (step, options) {
console.log(step);
switch (step.type) {
case 'weight':
var targetNode = graph.nodes(n(step.target));
......
......@@ -32,7 +32,7 @@ Tracer.prototype.createRandomData = function (arguments) {
Tracer.prototype.setData = function (arguments) {
var data = JSON.stringify(arguments);
if (lastData == data) return true;
if (lastModule == this.module && lastData == data) return true;
lastData = data;
return false;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册