Update algorithm limits and error handling

This commit is contained in:
Oleg Sh
2025-10-04 19:00:08 +02:00
parent e057a2d5ab
commit 46c05d94fd
31 changed files with 225 additions and 29 deletions

View File

@@ -152,6 +152,17 @@ BaseAlgorithm.prototype.IsSupportNegativeWeight = function()
return false;
}
// Limit by number of vertexes for the algorithm.
BaseAlgorithm.prototype.MaxGraphSize = function()
{
return 1000;
}
BaseAlgorithm.prototype.MaxEgdeNumber = function()
{
return 10000;
}
/**
* Default handler.
* Select using mouse, drag.
@@ -218,20 +229,16 @@ BaseAlgorithmEx.prototype.CalculateAlgorithm = function(algorithmName, otherPara
var $xml = $( xmlDoc );
$results = $xml.find( "result" );
$results.each(function(){
$values = $(this).find( "value" );
$values.each(function(){
var type = $(this).attr('type');
var value = $(this).text();
var res = {};
res.type = type;
res.value = value;
result.push(res);
});
});
// Use native because jqueary hangs for results with 10000+ nodes.
let values = $results[0].getElementsByTagName("value");
for (var j = 0; j < values.length; j++)
{
var type = values[j].getAttribute('type');
var value = values[j].textContent;
result.push({ type: type, value: value });
}
$nodes = $xml.find( "node" );
$nodes.each(function(){

View File

@@ -35,6 +35,16 @@ FindEulerianLoop.prototype.getCategory = function()
return 1;
}
FindEulerianLoop.prototype.MaxGraphSize = function()
{
return 50;
}
FindEulerianLoop.prototype.MaxEgdeNumber = function()
{
return 500;
}
FindEulerianLoop.prototype.result = function(resultCallback)
{
this.outResultCallback = function (result ) { resultCallback(result); };

View File

@@ -35,6 +35,16 @@ FindEulerianPath.prototype.getCategory = function()
return 1;
}
FindEulerianPath.prototype.MaxGraphSize = function()
{
return 50;
}
FindEulerianPath.prototype.MaxEgdeNumber = function()
{
return 500;
}
FindEulerianPath.prototype.result = function(resultCallback)
{
this.outResultCallback = function (result ) { resultCallback(result); };

View File

@@ -46,6 +46,16 @@ FindAllPathes.prototype.getCategory = function()
return 1;
}
FindAllPathes.prototype.MaxGraphSize = function()
{
return 50;
}
FindAllPathes.prototype.MaxEgdeNumber = function()
{
return 40;
}
FindAllPathes.prototype.result = function(resultCallback)
{
if (this.firstObject && this.secondObject)

View File

@@ -47,6 +47,16 @@ FindAllShortestPathes.prototype.getCategory = function()
return 1;
}
FindAllShortestPathes.prototype.MaxGraphSize = function()
{
return 50;
}
FindAllShortestPathes.prototype.MaxEgdeNumber = function()
{
return 40;
}
FindAllShortestPathes.prototype.result = function(resultCallback)
{
if (this.firstObject && this.secondObject)

View File

@@ -47,6 +47,16 @@ FindLongestPath.prototype.getCategory = function()
return 1;
}
FindLongestPath.prototype.MaxGraphSize = function()
{
return 50;
}
FindLongestPath.prototype.MaxEgdeNumber = function()
{
return 40;
}
FindLongestPath.prototype.result = function(resultCallback)
{
if (this.firstObject && this.secondObject)

View File

@@ -35,6 +35,16 @@ FindHamiltonianLoop.prototype.getCategory = function()
return 1;
}
FindHamiltonianLoop.prototype.MaxGraphSize = function()
{
return 30;
}
FindHamiltonianLoop.prototype.MaxEgdeNumber = function()
{
return 450;
}
FindHamiltonianLoop.prototype.result = function(resultCallback)
{
this.outResultCallback = function (result ) { resultCallback(result); };

View File

@@ -35,6 +35,16 @@ FindHamiltonianPath.prototype.getCategory = function()
return 1;
}
FindHamiltonianPath.prototype.MaxGraphSize = function()
{
return 30;
}
FindHamiltonianPath.prototype.MaxEgdeNumber = function()
{
return 450;
}
FindHamiltonianPath.prototype.result = function(resultCallback)
{
this.outResultCallback = function (result ) { resultCallback(result); };

View File

@@ -86,6 +86,16 @@ MaxIndependentSet.prototype.getPriority = function()
return -5;
}
MaxIndependentSet.prototype.MaxGraphSize = function()
{
return 100;
}
MaxIndependentSet.prototype.MaxEgdeNumber = function()
{
return 4000;
}
MaxIndependentSet.prototype.IsSupportNegativeWeight = function()
{
return true;