mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-02-16 02:30:51 +00:00
Add Salesman Problem algorithms.
This commit is contained in:
@@ -94,5 +94,5 @@
|
||||
$g_config['vote'] = "./tmp/vote/vote.txt";
|
||||
$g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_";
|
||||
$g_config['use_js_cache'] = true;
|
||||
$g_config['engine_version'] = 102;
|
||||
$g_config['engine_version'] = 103;
|
||||
?>
|
||||
|
||||
@@ -335,4 +335,10 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -337,4 +337,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -336,4 +336,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
@@ -294,4 +294,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -333,4 +333,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -338,4 +338,10 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -337,4 +337,10 @@ Tenemos traducciones en griego 🇬🇷.</a> <a href=\"https://github.com/UnickS
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -304,4 +304,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -301,4 +301,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -337,4 +337,10 @@ Dodaliśmy polskie tłumaczenie, Patryk</a>";
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -302,4 +302,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -342,4 +342,10 @@
|
||||
$g_lang['graph_is_to_large'] = "Граф слишком большой для этого алгоритма (<span id=\"current_graph_size\">X</span> вершин, <span id=\"current_edge_number\">X</span> дуг).";
|
||||
$g_lang['algorith_supports_max_limit'] = "Алгоритм поддерживает графы размером не больше <span id=\"algorithm_max_limit\">X</span> вершин и <span id=\"algorithm_edge_limit\">X</span> дуг.";
|
||||
$g_lang['error'] = "Ошибка";
|
||||
|
||||
$g_lang['salesman_problem'] = "Задача коммивояжёра";
|
||||
$g_lang['no_solution'] = "Решения не существует";
|
||||
$g_lang['shortest_loop_is'] = "Кратчайшие цикл имеет длинну ";
|
||||
$g_lang['salesman_path_problem'] = "Задача коммивояжёра для пути";
|
||||
$g_lang['shortest_path_is'] = "Кратчайшие путь имеет длинну ";
|
||||
?>
|
||||
|
||||
@@ -298,4 +298,10 @@
|
||||
$g_lang['graph_is_to_large'] = "The graph is too large for this algorithm (<span id=\"current_graph_size\">X</span> vertices, <span id=\"current_edge_number\">X</span> edges).";
|
||||
$g_lang['algorith_supports_max_limit'] = "The algorithm supports graphs of size no larger than <span id=\"algorithm_max_limit\">X</span> vertices and <span id=\"algorithm_edge_limit\">X</span> edges.";
|
||||
$g_lang['error'] = "Error";
|
||||
|
||||
$g_lang['salesman_problem'] = "Salesman Problem";
|
||||
$g_lang['no_solution'] = "The solution doesn't exist";
|
||||
$g_lang['shortest_loop_is'] = "The length of shortest possible loop is ";
|
||||
$g_lang['salesman_path_problem'] = "Salesman Path Problem";
|
||||
$g_lang['shortest_path_is'] = "The length of shortest path is ";
|
||||
?>
|
||||
|
||||
@@ -340,4 +340,10 @@
|
||||
$g_lang['graph_is_to_large'] = "Граф слишком большой для этого алгоритма (<span id=\"current_graph_size\">X</span> вершин, <span id=\"current_edge_number\">X</span> дуг).";
|
||||
$g_lang['algorith_supports_max_limit'] = "Алгоритм поддерживает графы размером не больше <span id=\"algorithm_max_limit\">X</span> вершин и <span id=\"algorithm_edge_limit\">X</span> дуг.";
|
||||
$g_lang['error'] = "Ошибка";
|
||||
|
||||
$g_lang['salesman_problem'] = "Задача коммивояжёра";
|
||||
$g_lang['no_solution'] = "Решения не существует";
|
||||
$g_lang['shortest_loop_is'] = "Кратчайшие цикл имеет длинну ";
|
||||
$g_lang['salesman_path_problem'] = "Задача коммивояжёра для пути";
|
||||
$g_lang['shortest_path_is'] = "Кратчайшие путь имеет длинну ";
|
||||
?>
|
||||
|
||||
@@ -30,7 +30,9 @@ function loadAsyncAlgorithms(onFinish) {
|
||||
"ShortestPath.js",
|
||||
"VerticesDegree.js",
|
||||
"MaxIndependentSet.js",
|
||||
"FindAllShortestPatches.js"];
|
||||
"FindAllShortestPatches.js",
|
||||
"SalesmanProblem.js",
|
||||
"SalesmanProblemPath.js"];
|
||||
|
||||
doIncludeAsync (pluginsList.map((plugin) => include ("model/plugins/" + plugin, modulDir)), onFinish);
|
||||
}
|
||||
|
||||
125
script/features/algorithms/model/plugins/SalesmanProblem.js
Normal file
125
script/features/algorithms/model/plugins/SalesmanProblem.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Find Salesman Problem Loop.
|
||||
*
|
||||
*/
|
||||
function SalesmanProblem(graph, app)
|
||||
{
|
||||
BaseAlgorithmEx.apply(this, arguments);
|
||||
this.message = g_processing;
|
||||
this.selectedObjects = [];
|
||||
}
|
||||
|
||||
|
||||
// inheritance.
|
||||
SalesmanProblem.prototype = Object.create(BaseAlgorithmEx.prototype);
|
||||
|
||||
|
||||
SalesmanProblem.prototype.getName = function(local)
|
||||
{
|
||||
return g_salesmanProblem;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.getId = function()
|
||||
{
|
||||
return "OlegSh.SalesmanProblem";
|
||||
}
|
||||
|
||||
// @return message for user.
|
||||
SalesmanProblem.prototype.getMessage = function(local)
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.getCategory = function()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.MaxGraphSize = function()
|
||||
{
|
||||
return 18;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.MaxEgdeNumber = function()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.result = function(resultCallback)
|
||||
{
|
||||
this.outResultCallback = function (result ) { resultCallback(result); };
|
||||
self = this;
|
||||
this.CalculateAlgorithm("slsmen",
|
||||
[
|
||||
{name: "start", value: 0}
|
||||
], function (pathObjects, properties, results)
|
||||
{
|
||||
self.resultCallback(pathObjects, properties, results);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.resultCallback = function(pathObjects, properties, results)
|
||||
{
|
||||
let result = results.length > 0 && results[0].value > 0 && results[0].type == 1;
|
||||
let dist = results.length > 1 && (results[1].type == 1 || results[1].type == 2) ? results[1].value : 0;
|
||||
|
||||
var outputResult = {};
|
||||
outputResult["version"] = 1;
|
||||
|
||||
this.message = result > 0 ? g_shortestLoopIs + (dist * 1).toString() : g_noSolution;
|
||||
if (result > 0)
|
||||
{
|
||||
var nodesEdgesPath = this.GetNodesEdgesPath(results, 1, results.length - 1);
|
||||
var nodesPath = this.GetNodesPath(results, 1, results.length - 1);
|
||||
|
||||
this.message = this.message + ": ";
|
||||
|
||||
outputResult["pathsWithEdges"] = [];
|
||||
outputResult["pathsWithEdges"].push(nodesEdgesPath);
|
||||
|
||||
for (var i = 0; i < nodesPath.length; i++)
|
||||
{
|
||||
this.message = this.message + this.graph.FindVertex(nodesPath[i]).mainText + ((i < nodesPath.length - 1) ? "⇒" : "");
|
||||
}
|
||||
this.selectedObjects = [];
|
||||
|
||||
for (var i = 0; i < pathObjects.length; i++)
|
||||
{
|
||||
this.selectedObjects[pathObjects[i].id] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
this.outResultCallback(outputResult);
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.getObjectSelectedGroup = function(object)
|
||||
{
|
||||
return (object.id in this.selectedObjects) ? this.selectedObjects[object.id] : 0;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.getPriority = function()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Algorithm support multi graph
|
||||
SalesmanProblem.prototype.IsSupportMultiGraph = function()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SalesmanProblem.prototype.IsSupportNegativeWeight = function()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Factory for connected components.
|
||||
function CreateSalesmanProblem(graph, app)
|
||||
{
|
||||
return new SalesmanProblem(graph, app)
|
||||
}
|
||||
|
||||
// Gerister connected component.
|
||||
RegisterAlgorithm (CreateSalesmanProblem);
|
||||
144
script/features/algorithms/model/plugins/SalesmanProblemPath.js
Normal file
144
script/features/algorithms/model/plugins/SalesmanProblemPath.js
Normal file
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* Find Salesman Problem Path.
|
||||
*
|
||||
*/
|
||||
function SalesmanProblemPath(graph, app)
|
||||
{
|
||||
BaseAlgorithmEx.apply(this, arguments);
|
||||
this.message = g_startTraversal;
|
||||
this.selectedObjects = [];
|
||||
this.startVertex = null
|
||||
}
|
||||
|
||||
|
||||
// inheritance.
|
||||
SalesmanProblemPath.prototype = Object.create(BaseAlgorithmEx.prototype);
|
||||
|
||||
|
||||
SalesmanProblemPath.prototype.getName = function(local)
|
||||
{
|
||||
return g_salesmanProblemPath;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.getId = function()
|
||||
{
|
||||
return "OlegSh.SalesmanProblemPath";
|
||||
}
|
||||
|
||||
// @return message for user.
|
||||
SalesmanProblemPath.prototype.getMessage = function(local)
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.getCategory = function()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.MaxGraphSize = function()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.MaxEgdeNumber = function()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.result = function(resultCallback)
|
||||
{
|
||||
if (!this.startVertex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.outResultCallback = function (result ) { resultCallback(result); };
|
||||
self = this;
|
||||
this.CalculateAlgorithm("slsmenpath",
|
||||
[
|
||||
{name: "start", value: this.startVertex.id}
|
||||
], function (pathObjects, properties, results)
|
||||
{
|
||||
self.resultCallback(pathObjects, properties, results);
|
||||
});
|
||||
this.startVertex = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.selectVertex = function(vertex)
|
||||
{
|
||||
this.startVertex = vertex;
|
||||
this.message = g_processing;
|
||||
return true;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.resultCallback = function(pathObjects, properties, results)
|
||||
{
|
||||
let result = results.length > 0 && results[0].value > 0 && results[0].type == 1;
|
||||
let dist = results.length > 1 && (results[1].type == 1 || results[1].type == 2) ? results[1].value : 0;
|
||||
|
||||
var outputResult = {};
|
||||
outputResult["version"] = 1;
|
||||
|
||||
this.message = result > 0 ? g_shortestPathIs + (dist * 1).toString() : g_noSolution;
|
||||
if (result > 0)
|
||||
{
|
||||
var nodesEdgesPath = this.GetNodesEdgesPath(results, 1, results.length - 1);
|
||||
var nodesPath = this.GetNodesPath(results, 1, results.length - 1);
|
||||
|
||||
this.message = this.message + ": ";
|
||||
|
||||
outputResult["pathsWithEdges"] = [];
|
||||
outputResult["pathsWithEdges"].push(nodesEdgesPath);
|
||||
|
||||
for (var i = 0; i < nodesPath.length; i++)
|
||||
{
|
||||
this.message = this.message + this.graph.FindVertex(nodesPath[i]).mainText + ((i < nodesPath.length - 1) ? "⇒" : "");
|
||||
}
|
||||
this.selectedObjects = [];
|
||||
|
||||
for (var i = 0; i < pathObjects.length; i++)
|
||||
{
|
||||
this.selectedObjects[pathObjects[i].id] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
this.outResultCallback(outputResult);
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.getObjectSelectedGroup = function(object)
|
||||
{
|
||||
return (object.id in this.selectedObjects) ? this.selectedObjects[object.id] : 0;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.getPriority = function()
|
||||
{
|
||||
return -0.9;
|
||||
}
|
||||
|
||||
// Algorithm support multi graph
|
||||
SalesmanProblemPath.prototype.IsSupportMultiGraph = function()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.IsSupportNegativeWeight = function()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
SalesmanProblemPath.prototype.instance = function()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Factory for connected components.
|
||||
function CreateSalesmanProblemPath(graph, app)
|
||||
{
|
||||
return new SalesmanProblemPath(graph, app)
|
||||
}
|
||||
|
||||
// Gerister connected component.
|
||||
RegisterAlgorithm (CreateSalesmanProblemPath);
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=102","/script/shared/point.js?v=102","/script/entities/edge/api/index.js?v=102","/script/entities/edge/model/BaseEdge.js?v=102","/script/entities/edge/model/EdgeModel.js?v=102","/script/entities/vertex/api/index.js?v=102","/script/entities/vertex/model/BaseVertex.js?v=102","/script/entities/vertex/model/VertexModel.js?v=102","/script/entities/graph/model/Graph.js?v=102",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
|
||||
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=103","/script/shared/point.js?v=103","/script/entities/edge/api/index.js?v=103","/script/entities/edge/model/BaseEdge.js?v=103","/script/entities/edge/model/EdgeModel.js?v=103","/script/entities/vertex/api/index.js?v=103","/script/entities/vertex/model/BaseVertex.js?v=103","/script/entities/vertex/model/VertexModel.js?v=103","/script/entities/graph/model/Graph.js?v=103",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
|
||||
{let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point)
|
||||
{return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point)
|
||||
{return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=102","/script/shared/point.js?v=102","/script/entities/edge/api/index.js?v=102","/script/entities/edge/model/BaseEdge.js?v=102","/script/entities/edge/model/EdgeModel.js?v=102","/script/entities/vertex/api/index.js?v=102","/script/entities/vertex/model/BaseVertex.js?v=102","/script/entities/vertex/model/VertexModel.js?v=102","/script/entities/graph/model/Graph.js?v=102",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
|
||||
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=103","/script/shared/point.js?v=103","/script/entities/edge/api/index.js?v=103","/script/entities/edge/model/BaseEdge.js?v=103","/script/entities/edge/model/EdgeModel.js?v=103","/script/entities/vertex/api/index.js?v=103","/script/entities/vertex/model/BaseVertex.js?v=103","/script/entities/vertex/model/VertexModel.js?v=103","/script/entities/graph/model/Graph.js?v=103",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
|
||||
{let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point)
|
||||
{return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point)
|
||||
{return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=102","/script/shared/point.js?v=102","/script/entities/edge/api/index.js?v=102","/script/entities/edge/model/BaseEdge.js?v=102","/script/entities/edge/model/EdgeModel.js?v=102","/script/entities/vertex/api/index.js?v=102","/script/entities/vertex/model/BaseVertex.js?v=102","/script/entities/vertex/model/VertexModel.js?v=102","/script/entities/graph/model/Graph.js?v=102","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=102","/script/pages/create_graph_by_matrix/model/main.js?v=102",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);}
|
||||
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=103","/script/shared/point.js?v=103","/script/entities/edge/api/index.js?v=103","/script/entities/edge/model/BaseEdge.js?v=103","/script/entities/edge/model/EdgeModel.js?v=103","/script/entities/vertex/api/index.js?v=103","/script/entities/vertex/model/BaseVertex.js?v=103","/script/entities/vertex/model/VertexModel.js?v=103","/script/entities/graph/model/Graph.js?v=103","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=103","/script/pages/create_graph_by_matrix/model/main.js?v=103",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);}
|
||||
{let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point)
|
||||
{return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point)
|
||||
{return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -224,6 +224,12 @@ var g_length_is = "length is ";
|
||||
|
||||
var g_error = "Error";
|
||||
|
||||
var g_salesmanProblem = "Salesman Problem";
|
||||
var g_noSolution = "The solution doesn't exist";
|
||||
var g_shortestLoopIs = "The length of shortest possible loop is ";
|
||||
var g_salesmanProblemPath = "Salesman Path Problem";
|
||||
var g_shortestPathIs = "The length of shortest path is ";
|
||||
|
||||
function loadTexts()
|
||||
{
|
||||
g_textsSelectAndMove = document.getElementById("SelectAndMoveObject").innerHTML;
|
||||
@@ -455,4 +461,10 @@ function loadTexts()
|
||||
g_length_is = document.getElementById("lengthIs").innerHTML;
|
||||
|
||||
g_error = document.getElementById("error").innerHTML;
|
||||
|
||||
g_salesmanProblem = document.getElementById("salesmanProblem").innerHTML;
|
||||
g_noSolution = document.getElementById("noSolution").innerHTML;
|
||||
g_shortestLoopIs = document.getElementById("shortestLoopIs").innerHTML;
|
||||
g_salesmanProblemPath = document.getElementById("salesmanProblemPath").innerHTML;
|
||||
g_shortestPathIs = document.getElementById("shortestPathIs").innerHTML;
|
||||
}
|
||||
@@ -721,6 +721,8 @@ Editor.prototype.createAlgorithmMenu = function()
|
||||
dialogClass: 'EdgeDialog',
|
||||
buttons: dialogButtons,
|
||||
});
|
||||
userAction("graph_to_big/" + algorithm.getId() + "/" + self.application.graph.vertices.length +
|
||||
"+vertices/" + self.application.graph.edges.length + "+edges");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -997,6 +997,12 @@
|
||||
<p id="numberOfShortestPathesFrom" class="translation"><?= L('number_of_shortest_pathes_from')?></p>
|
||||
<p id="lengthIs" class="translation"><?= L('length_is')?></p>
|
||||
<p id="error" class="translation"><?= L('error')?></p>
|
||||
|
||||
<p id="salesmanProblem" class="translation"><?= L('salesman_problem')?></p>
|
||||
<p id="noSolution" class="translation"><?= L('no_solution')?></p>
|
||||
<p id="shortestLoopIs" class="translation"><?= L('shortest_loop_is')?></p>
|
||||
<p id="salesmanProblemPath" class="translation"><?= L('salesman_path_problem')?></p>
|
||||
<p id="shortestPathIs" class="translation"><?= L('shortest_path_is')?></p>
|
||||
</section>
|
||||
|
||||
<script src="<?= RootCacheJS("script/pages/editor/api/index.js")?>" ></script>
|
||||
|
||||
Reference in New Issue
Block a user