mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-04-08 16:56:03 +00:00
Change script location.
Split js code. Added cache and changed loading mechanism for js sources.
This commit is contained in:
56
script/features/algorithms/model/BaseTraversal.js
Normal file
56
script/features/algorithms/model/BaseTraversal.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Find short path.
|
||||
*
|
||||
*/
|
||||
function BaseTraversal(graph, app)
|
||||
{
|
||||
BaseAlgorithmEx.apply(this, arguments);
|
||||
this.visited = [];
|
||||
this.edges = [];
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
// inheritance.
|
||||
BaseTraversal.prototype = Object.create(BaseAlgorithmEx.prototype);
|
||||
// timer interval
|
||||
BaseTraversal.prototype.timerInterval = 500;
|
||||
|
||||
BaseTraversal.prototype.result = function(resultCallback)
|
||||
{
|
||||
var result = {};
|
||||
result["version"] = 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BaseTraversal.prototype.selectVertex = function(vertex)
|
||||
{
|
||||
this.visited = [];
|
||||
this.edges = [];
|
||||
|
||||
if (this.timer)
|
||||
clearTimeout(this.timer);
|
||||
this.timer = null;
|
||||
|
||||
this.visited.push(vertex);
|
||||
|
||||
var context = this;
|
||||
this.timer = setInterval(function()
|
||||
{
|
||||
context.step();
|
||||
}, this.timerInterval);
|
||||
|
||||
this.message = this.getMainMessage();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BaseTraversal.prototype.getObjectSelectedGroup = function(object)
|
||||
{
|
||||
return (this.visited.includes(object) ? 1 : (this.edges.includes(object) ? 1 : 0));
|
||||
}
|
||||
|
||||
BaseTraversal.prototype.instance = function()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user