Add find all shortest pathes between two vertexes.

This commit is contained in:
Oleg Sh 2025-08-13 22:06:28 +02:00
parent a5120569f3
commit d3416b63b3
23 changed files with 358 additions and 9 deletions

View File

@ -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'] = 99;
$g_config['engine_version'] = 100;
?>

View File

@ -327,4 +327,7 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -329,4 +329,7 @@
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -328,4 +328,7 @@
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -286,4 +286,7 @@
$g_lang["max_clique_not_found"] = "Max Clique is not found";
$g_lang["max_clique_size_is"] = "Max Clique size is ";
$g_lang["max_clique_contains"] = ". Clique contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -325,4 +325,7 @@
$g_lang["max_clique_not_found"] = "Max Clique is not found";
$g_lang["max_clique_size_is"] = "Max Clique size is ";
$g_lang["max_clique_contains"] = ". Clique contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -330,4 +330,7 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -329,4 +329,7 @@ Tenemos traducciones en griego 🇬🇷.</a> <a href=\"https://github.com/UnickS
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -296,4 +296,7 @@
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -293,4 +293,7 @@
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -329,4 +329,7 @@ Dodaliśmy polskie tłumaczenie, Patryk</a>";
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -294,4 +294,7 @@
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -334,4 +334,7 @@
$g_lang["max_independent_set_not_found"] = "Максимальное независимое множество не найдена";
$g_lang["max_independent_set_size_is"] = "Размер Максимального независимого множества равен ";
$g_lang["max_independent_set_contains"] = ". Множества содержит следующие вершины: ";
$g_lang['find_all_shortest_pathes'] = "Найти все кратчайшие пути между вершинами";
$g_lang['number_of_shortest_pathes_from'] = "Количество кратчайших путей из ";
?>

View File

@ -285,4 +285,12 @@
$g_lang['open_last_used_graph'] = "Open Recent Graph";
$g_lang['vertex_name_place_holder'] = "vertex name";
$g_lang["max_independent_set"] = "Max Independent Set";
$g_lang["max_independent_set_not_found"] = "Max Independent Set is not found";
$g_lang["max_independent_set_size_is"] = "Max Independent Set size is ";
$g_lang["max_independent_set_contains"] = ". Set contains these vertecies: ";
$g_lang['find_all_shortest_pathes'] = "Find all shortest paths between 2 vertices";
$g_lang['number_of_shortest_pathes_from'] = "Number of shortest paths from ";
?>

View File

@ -332,4 +332,7 @@
$g_lang["max_independent_set_not_found"] = "Максимальное независимое множество не найдена";
$g_lang["max_independent_set_size_is"] = "Размер Максимального независимого множества равен ";
$g_lang["max_independent_set_contains"] = ". Множества содержит следующие вершины: ";
$g_lang['find_all_shortest_pathes'] = "Найти все кратчайшие пути между вершинами";
$g_lang['number_of_shortest_pathes_from'] = "Количество кратчайших путей из ";
?>

View File

@ -29,7 +29,8 @@ function loadAsyncAlgorithms(onFinish) {
"RadiusAndDiameter.js",
"ShortestPath.js",
"VerticesDegree.js",
"MaxIndependentSet.js"];
"MaxIndependentSet.js",
"FindAllShortestPatches.js"];
doIncludeAsync (pluginsList.map((plugin) => include ("model/plugins/" + plugin, modulDir)), onFinish);
}

View File

@ -0,0 +1,292 @@
/**
* Find all shortest pathes.
*
*/
function FindAllShortestPathes(graph, app)
{
BaseAlgorithmEx.apply(this, arguments);
this.message = g_selectStartVertex;
this.selectedObjects = {};
this.foundSubGraphs = {};
this.nSubgraphIndex = 0;
this.nSubGraphCount = 0;
this.foundPaths = {};
}
// inheritance.
FindAllShortestPathes.prototype = Object.create(BaseAlgorithmEx.prototype);
// First selected.
FindAllShortestPathes.prototype.firstObject = null;
// Second selected.
FindAllShortestPathes.prototype.secondObject = null;
// Path
FindAllShortestPathes.prototype.pathObjects = null;
// Infinity
FindAllShortestPathes.prototype.infinityValue = 1E9 - 1;
FindAllShortestPathes.prototype.getName = function(local)
{
return g_FindAllShortestPathes;
}
FindAllShortestPathes.prototype.getId = function()
{
return "OlegSh.FindAllShortestPathes";
}
// @return message for user.
FindAllShortestPathes.prototype.getMessage = function(local)
{
return this.message;
}
FindAllShortestPathes.prototype.getCategory = function()
{
return 1;
}
FindAllShortestPathes.prototype.result = function(resultCallback)
{
if (this.firstObject && this.secondObject)
{
this.outResultCallback = function (result ) { resultCallback(result); };
self = this;
this.CalculateAlgorithm("prnpaths", [
{name: "start", value: this.firstObject.id},
{name: "finish", value: this.secondObject.id}
],
function (pathObjects, properties, results)
{
self.resultCallback(pathObjects, properties, results);
});
}
return null;
}
FindAllShortestPathes.prototype.setResultMessage = function()
{
if (this.nSubGraphCount > 0)
{
var currentPath = "";
var first = true;
this.foundPaths[this.nSubgraphIndex].forEach((nodeId) => {
currentPath += (first ? "" : "⇒") + this.graph.FindVertex(nodeId).mainText;
first = false;
});
this.message = g_numberOfShortestPathesFrom + this.firstObject.mainText +
g_to + this.secondObject.mainText + g_are +
this.nSubGraphCount + ". " + g_pathN + (1 + parseInt(this.nSubgraphIndex)) + ": " + currentPath +
" <select style=\"float:right\" id=\"enumSubgraphs\"></select>";
}
else
{
this.message = g_pathNotExists;
}
}
FindAllShortestPathes.prototype.resultCallback = function(pathObjects, properties, results)
{
var outputResult = {};
outputResult["version"] = 1;
outputResult["minPath"] = true;
this.pathObjects = pathObjects;
this.properties = properties;
var bFound = results.length > 0 && results[0].value < this.infinityValue && (results[0].type == 1 || results[0].type == 2);
if (bFound)
{
let patches_len = {};
let min_len = 1E10;
// Search minimal patches
{
let current_len = 0;
var subGraphIndex = 0;
var prevNodeId = -1;
let any_found = false;
for (var i = 0; i < results.length; i++)
{
if (results[i].type == 6)
{
patches_len[subGraphIndex] = current_len;
subGraphIndex++;
prevNodeId = -1;
min_len = Math.min(min_len, current_len);
current_len = 0;
}
if (results[i].type == 4)
{
any_found = true;
var nodeId = parseInt(results[i].value);
var index = subGraphIndex;
if (prevNodeId >= 0)
{
var edgeObject = this.graph.FindEdgeMin(prevNodeId, nodeId);
current_len = current_len + edgeObject.GetWeight();
}
prevNodeId = nodeId;
}
}
if (any_found)
{
patches_len[subGraphIndex] = current_len;
min_len = Math.min(min_len, current_len);
}
}
let min_pathes_count = 0;
for (const [key, value] of Object.entries(patches_len)) {
if (value == min_len)
{
min_pathes_count = min_pathes_count + 1;
}
}
this.nSubGraphCount = min_pathes_count;
this.foundSubGraphs = {};
this.foundPaths = {};
for (var i = 0; i < this.nSubGraphCount; i++)
{
this.foundSubGraphs[i] = {};
this.foundPaths[i] = [];
}
var subGraphIndex = 0;
var prevNodeId = -1;
for (var i = 0; i < results.length; i++)
{
if (results[i].type == 6)
{
subGraphIndex++;
prevNodeId = -1;
}
if (patches_len[subGraphIndex] > min_len)
{
// Skip
continue;
}
if (results[i].type == 4)
{
var nodeId = parseInt(results[i].value);
var index = subGraphIndex;
var subgGraph = this.foundSubGraphs[index];
subgGraph[nodeId] = true;
this.foundPaths[index].push(nodeId);
if (prevNodeId >= 0)
{
var edgeObject = this.graph.FindEdgeMin(prevNodeId, nodeId);
subgGraph[edgeObject.id] = true;
}
prevNodeId = nodeId;
}
}
this.setResultMessage();
}
else
{
this.secondObject = null;
this.firstObject = null;
this.message = g_pathNotExists;
}
this.outResultCallback(outputResult);
}
FindAllShortestPathes.prototype.messageWasChanged = function()
{
var self = this;
if ($('#enumSubgraphs'))
{
for (var i = 0; i < this.nSubGraphCount; i++)
{
$('#enumSubgraphs').append("<option value=\"" + i + "\"" + (self.nSubgraphIndex==i ? "selected": "") + ">" +
g_pathN + (i + 1) +
"</option>");
}
$('#enumSubgraphs').change(function () {
self.nSubgraphIndex = $('#enumSubgraphs').val();
self.setResultMessage();
self.app.redrawGraph();
self.app.updateMessage();
});
}
}
FindAllShortestPathes.prototype.selectVertex = function(vertex)
{
this.pathObjects = null;
this.shortDist = null;
if (this.firstObject)
{
this.message = g_processing;
this.secondObject = vertex;
this.selectedObjects = [];
}
else
{
this.firstObject = vertex;
this.secondObject = null;
this.selectedObjects = {};
this.message = g_selectFinishVertex;
}
return true;
}
FindAllShortestPathes.prototype.deselectAll = function()
{
this.firstObject = null;
this.secondObject = null;
this.selectedObjects = {};
this.foundSubGraphs = {};
this.nSubgraphIndex = 0;
this.nSubGraphCount = 0;
this.message = g_selectStartVertex;
return true;
}
FindAllShortestPathes.prototype.instance = function()
{
return false;
}
FindAllShortestPathes.prototype.getObjectSelectedGroup = function(object)
{
return (this.nSubgraphIndex in this.foundSubGraphs && object.id in this.foundSubGraphs[this.nSubgraphIndex]) ? 1 :
(object.id in this.selectedObjects) ? this.selectedObjects[object.id] : ((object == this.firstObject || object == object.secondObject) ? 1 : 0);
}
FindAllShortestPathes.prototype.getPriority = function()
{
return -9.46;
}
FindAllShortestPathes.prototype.IsSupportNegativeWeight = function()
{
return true;
}
// Factory for connected components.
function CreateFindAllShortestPathes(graph, app)
{
return new FindAllShortestPathes(graph, app)
}
// Gerister connected component.
RegisterAlgorithm (CreateFindAllShortestPathes);

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=99","/script/shared/point.js?v=99","/script/entities/edge/api/index.js?v=99","/script/entities/edge/model/BaseEdge.js?v=99","/script/entities/edge/model/EdgeModel.js?v=99","/script/entities/vertex/api/index.js?v=99","/script/entities/vertex/model/BaseVertex.js?v=99","/script/entities/vertex/model/VertexModel.js?v=99","/script/entities/graph/model/Graph.js?v=99",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=100","/script/shared/point.js?v=100","/script/entities/edge/api/index.js?v=100","/script/entities/edge/model/BaseEdge.js?v=100","/script/entities/edge/model/EdgeModel.js?v=100","/script/entities/vertex/api/index.js?v=100","/script/entities/vertex/model/BaseVertex.js?v=100","/script/entities/vertex/model/VertexModel.js?v=100","/script/entities/graph/model/Graph.js?v=100",]);{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()

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=99","/script/shared/point.js?v=99","/script/entities/edge/api/index.js?v=99","/script/entities/edge/model/BaseEdge.js?v=99","/script/entities/edge/model/EdgeModel.js?v=99","/script/entities/vertex/api/index.js?v=99","/script/entities/vertex/model/BaseVertex.js?v=99","/script/entities/vertex/model/VertexModel.js?v=99","/script/entities/graph/model/Graph.js?v=99",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=100","/script/shared/point.js?v=100","/script/entities/edge/api/index.js?v=100","/script/entities/edge/model/BaseEdge.js?v=100","/script/entities/edge/model/EdgeModel.js?v=100","/script/entities/vertex/api/index.js?v=100","/script/entities/vertex/model/BaseVertex.js?v=100","/script/entities/vertex/model/VertexModel.js?v=100","/script/entities/graph/model/Graph.js?v=100",]);{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()

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=99","/script/shared/point.js?v=99","/script/entities/edge/api/index.js?v=99","/script/entities/edge/model/BaseEdge.js?v=99","/script/entities/edge/model/EdgeModel.js?v=99","/script/entities/vertex/api/index.js?v=99","/script/entities/vertex/model/BaseVertex.js?v=99","/script/entities/vertex/model/VertexModel.js?v=99","/script/entities/graph/model/Graph.js?v=99","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=99","/script/pages/create_graph_by_matrix/model/main.js?v=99",]);{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=100","/script/shared/point.js?v=100","/script/entities/edge/api/index.js?v=100","/script/entities/edge/model/BaseEdge.js?v=100","/script/entities/edge/model/EdgeModel.js?v=100","/script/entities/vertex/api/index.js?v=100","/script/entities/vertex/model/BaseVertex.js?v=100","/script/entities/vertex/model/VertexModel.js?v=100","/script/entities/graph/model/Graph.js?v=100","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=100","/script/pages/create_graph_by_matrix/model/main.js?v=100",]);{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

View File

@ -218,6 +218,9 @@ var g_MaxIndependentSetNotFound = "Max Independent Set is not found";
var g_MaxIndependentSetSizeIs = "Max Independent Set size is ";
var g_MaxIndependentSetContains = ". Set contains these vertecies: ";
var g_FindAllShortestPathes = "Find all shortest paths";
var g_numberOfShortestPathesFrom = "Number of shortest paths from ";
function loadTexts()
{
g_textsSelectAndMove = document.getElementById("SelectAndMoveObject").innerHTML;
@ -443,4 +446,7 @@ function loadTexts()
g_MaxIndependentSetNotFound = document.getElementById("maxIndependentSetNotFound").innerHTML;
g_MaxIndependentSetSizeIs = document.getElementById("maxIndependentSetSizeIs").innerHTML;
g_MaxIndependentSetContains = document.getElementById("maxIndependentSetContains").innerHTML;
g_FindAllShortestPathes = document.getElementById("findAllShortestPathes").innerHTML;
g_numberOfShortestPathesFrom = document.getElementById("numberOfShortestPathesFrom").innerHTML;
}

View File

@ -987,6 +987,9 @@
<p id="maxIndependentSetNotFound" class="translation"><?= L('max_independent_set_not_found')?></p>
<p id="maxIndependentSetSizeIs" class="translation"><?= L('max_independent_set_size_is')?></p>
<p id="maxIndependentSetContains" class="translation"><?= L('max_independent_set_contains')?></p>
<p id="findAllShortestPathes" class="translation"><?= L('find_all_shortest_pathes')?></p>
<p id="numberOfShortestPathesFrom" class="translation"><?= L('number_of_shortest_pathes_from')?></p>
</section>
<script src="<?= RootCacheJS("script/pages/editor/api/index.js")?>" ></script>