diff --git a/cgi-bin/GraphOffline/Win/GraphCGI.exe b/cgi-bin/GraphOffline/Win/GraphCGI.exe index 3a917e4..5bf5ff0 100644 Binary files a/cgi-bin/GraphOffline/Win/GraphCGI.exe and b/cgi-bin/GraphOffline/Win/GraphCGI.exe differ diff --git a/lang/de/home.php b/lang/de/home.php index 0c7cb29..8460deb 100644 --- a/lang/de/home.php +++ b/lang/de/home.php @@ -230,4 +230,9 @@ $g_lang['path_n'] = "Path #"; $g_lang['selected_finish_vertex'] = "Select finish vertex"; $g_lang['selected_start_vertex'] = "Select start vertex"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; + $g_lang['distance_from'] = "Distance from "; + $g_lang['path_to'] = "Path to "; ?> diff --git a/lang/el/home.php b/lang/el/home.php index 40c8759..88a454d 100644 --- a/lang/el/home.php +++ b/lang/el/home.php @@ -268,4 +268,9 @@ $g_lang['path_n'] = "Path #"; $g_lang['selected_finish_vertex'] = "Select finish vertex"; $g_lang['selected_start_vertex'] = "Select start vertex"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; + $g_lang['distance_from'] = "Distance from "; + $g_lang['path_to'] = "Path to "; ?> diff --git a/lang/en/home.php b/lang/en/home.php index 7cdd514..7c67671 100755 --- a/lang/en/home.php +++ b/lang/en/home.php @@ -267,4 +267,9 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit"; $g_lang['path_n'] = "Path #"; $g_lang['selected_finish_vertex'] = "Select finish vertex"; $g_lang['selected_start_vertex'] = "Select start vertex"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; + $g_lang['distance_from'] = "Distance from "; + $g_lang['path_to'] = "Path to "; ?> diff --git a/lang/es/home.php b/lang/es/home.php index 95eea5a..ee9b581 100755 --- a/lang/es/home.php +++ b/lang/es/home.php @@ -266,5 +266,10 @@ Tenemos traducciones en griego 🇬🇷. diff --git a/lang/fr/home.php b/lang/fr/home.php index e325645..372db26 100644 --- a/lang/fr/home.php +++ b/lang/fr/home.php @@ -234,5 +234,10 @@ $g_lang['are'] = " are "; $g_lang['path_n'] = "Path #"; $g_lang['selected_finish_vertex'] = "Select finish vertex"; - $g_lang['selected_start_vertex'] = "Select start vertex"; + $g_lang['selected_start_vertex'] = "Select start vertex"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; + $g_lang['distance_from'] = "Distance from "; + $g_lang['path_to'] = "Path to "; ?> \ No newline at end of file diff --git a/lang/nl/home.php b/lang/nl/home.php index aadeb06..82a2ab0 100644 --- a/lang/nl/home.php +++ b/lang/nl/home.php @@ -231,5 +231,10 @@ $g_lang['are'] = " are "; $g_lang['path_n'] = "Path #"; $g_lang['selected_finish_vertex'] = "Select finish vertex"; - $g_lang['selected_start_vertex'] = "Select start vertex"; + $g_lang['selected_start_vertex'] = "Select start vertex"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; + $g_lang['distance_from'] = "Distance from "; + $g_lang['path_to'] = "Path to "; ?> diff --git a/lang/pt/home.php b/lang/pt/home.php index a7933d3..0c77568 100644 --- a/lang/pt/home.php +++ b/lang/pt/home.php @@ -232,5 +232,10 @@ $g_lang['are'] = " are "; $g_lang['path_n'] = "Path #"; $g_lang['selected_finish_vertex'] = "Select finish vertex"; - $g_lang['selected_start_vertex'] = "Select start vertex"; + $g_lang['selected_start_vertex'] = "Select start vertex"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; + $g_lang['distance_from'] = "Distance from "; + $g_lang['path_to'] = "Path to "; ?> diff --git a/lang/ru/home.php b/lang/ru/home.php index 7ad5da8..58e271a 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -268,4 +268,9 @@ $g_lang['path_n'] = "Путь №"; $g_lang['selected_finish_vertex'] = "Выделите конечную вершину"; $g_lang['selected_start_vertex'] = "Выделите начальную вершину"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Найти все кратчайшие пути от вершины"; + $g_lang['distance_from'] = "Расстояние от "; + $g_lang['path_to'] = "Путь до "; ?> diff --git a/lang/sv/home.php b/lang/sv/home.php index ee7aa28..2b59752 100644 --- a/lang/sv/home.php +++ b/lang/sv/home.php @@ -229,4 +229,9 @@ $g_lang['path_n'] = "Path #"; $g_lang['selected_finish_vertex'] = "Select finish vertex"; $g_lang['selected_start_vertex'] = "Select start vertex"; + + // FindShortPatchsFromOne.js + $g_lang['find_all_paths_from_vertex'] = "Find all shortest paths from vertex"; + $g_lang['distance_from'] = "Distance from "; + $g_lang['path_to'] = "Path to "; ?> diff --git a/script/plugins/FindShortPatchsFromOne.js b/script/plugins/FindShortPatchsFromOne.js new file mode 100644 index 0000000..296129b --- /dev/null +++ b/script/plugins/FindShortPatchsFromOne.js @@ -0,0 +1,212 @@ +/** + * Find short path. + * + */ +function FindShortPatchsFromOne(graph, app) +{ + BaseAlgorithmEx.apply(this, arguments); + this.message = g_selectStartVertex; + this.selectedObjects = {}; + this.foundSubGraphs = {}; + this.nSubgraphIndex = 0; + this.nSubGraphCount = 0; + this.lastVertexInPath = []; + this.lengthOfPath = []; +} + + +// inheritance. +FindShortPatchsFromOne.prototype = Object.create(BaseAlgorithmEx.prototype); +// First selected. +FindShortPatchsFromOne.prototype.firstObject = null; +// Path +FindShortPatchsFromOne.prototype.pathObjects = null; +// Infinity +FindShortPatchsFromOne.prototype.infinityValue = 1E9 - 1; + +FindShortPatchsFromOne.prototype.getName = function(local) +{ + return g_findAllPathesFromVertex; +} + +FindShortPatchsFromOne.prototype.getId = function() +{ + return "Abin.FindShortPatchsFromOne"; +} + +// @return message for user. +FindShortPatchsFromOne.prototype.getMessage = function(local) +{ + return this.message; +} + +FindShortPatchsFromOne.prototype.result = function(resultCallback) +{ + if (this.firstObject) + { + this.outResultCallback = function (result ) { resultCallback(result); }; + self = this; + this.CalculateAlgorithm("blf=cgiInput&start=" + this.firstObject.id + "&report=xml", function (pathObjects, properties, results) + { + self.resultCallback(pathObjects, properties, results); + }); + } + return null; +} + +FindShortPatchsFromOne.prototype.setResultMessage = function() +{ + if (this.nSubGraphCount > 0) + { + this.message = g_distanceFrom + this.firstObject.mainText + + g_to + this.lastVertexInPath[this.nSubgraphIndex] + g_are + + this.lengthOfPath[this.nSubgraphIndex] + " "; + } + else + { + this.message = g_pathNotExists; + } +} + +FindShortPatchsFromOne.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) + { + this.nSubGraphCount = results.length > 0 && results[0].type == 1 ? results[0].value : 0; + + this.foundSubGraphs = {}; + for (var i = 0; i < this.nSubGraphCount; i++) + { + this.foundSubGraphs[i] = {}; + this.lengthOfPath.push(0); + this.lastVertexInPath.push(0); + } + + var subGraphIndex = 0; + var prevNodeId = -1; + for (var i = 0; i < results.length; i++) + { + if (results[i].type == 6) + { + subGraphIndex++; + prevNodeId = -1; + } + + if (results[i].type == 4) + { + var nodeId = parseInt(results[i].value); + var index = subGraphIndex; + var subgGraph = this.foundSubGraphs[index]; + subgGraph[nodeId] = true; + var vertex = this.graph.FindVertex(nodeId); + this.lastVertexInPath[index] = vertex != null ? vertex.mainText : ""; + + if (prevNodeId >= 0) + { + var edgeObject = this.graph.FindEdgeMin(prevNodeId, nodeId); + subgGraph[edgeObject.id] = true; + this.lengthOfPath[index] += edgeObject.GetWeight(); + } + prevNodeId = nodeId; + } + } + + this.setResultMessage(); + } + else + { + this.firstObject = null; + this.message = g_pathNotExists; + } + + this.outResultCallback(outputResult); +} + +FindShortPatchsFromOne.prototype.messageWasChanged = function() +{ + var self = this; + + if ($('#enumSubgraphs')) + { + for (var i = 0; i < this.nSubGraphCount; i++) + { + $('#enumSubgraphs').append(""); + } + + $('#enumSubgraphs').change(function () { + self.nSubgraphIndex = $('#enumSubgraphs').val(); + self.app.redrawGraph(); + self.setResultMessage(); + }); + } +} + +FindShortPatchsFromOne.prototype.selectVertex = function(vertex) +{ + this.pathObjects = null; + this.shortDist = null; + + this.deselectAll(); + + this.firstObject = vertex; + this.selectedObjects = {}; + this.message = "Processing..."; + + return true; +} + +FindShortPatchsFromOne.prototype.deselectAll = function() +{ + this.firstObject = null; + this.selectedObjects = {}; + this.foundSubGraphs = {}; + this.nSubgraphIndex = 0; + this.nSubGraphCount = 0; + this.message = g_selectStartVertex; + this.lastVertexInPath = []; + this.lengthOfPath = []; + + return true; +} + +FindShortPatchsFromOne.prototype.instance = function() +{ + return false; +} + +FindShortPatchsFromOne.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); +} + +FindShortPatchsFromOne.prototype.getPriority = function() +{ + return -9.4; +} + +// Algorithm support multi graph +FindShortPatchsFromOne.prototype.IsSupportMultiGraph = function() +{ + return true; +} + +// Factory for connected components. +function CreateFindShortPatchsFromOne(graph, app) +{ + return new FindShortPatchsFromOne(graph, app) +} + +// Gerister connected component. +RegisterAlgorithm (CreateFindShortPatchsFromOne); diff --git a/script/texts.js b/script/texts.js index fd0a0d0..3779668 100644 --- a/script/texts.js +++ b/script/texts.js @@ -179,6 +179,11 @@ var g_pathN = "Path #"; var g_selectFinishVertex = "Select finish vertex"; var g_selectStartVertex = "Select start vertex"; +// FindShortPatchsFromOne.js +var g_findAllPathesFromVertex = "Find all shortest paths from vertex"; +var g_distanceFrom = "Distance from "; +var g_pathTo = "Path to "; + function loadTexts() { g_textsSelectAndMove = document.getElementById("SelectAndMoveObject").innerHTML; @@ -365,4 +370,9 @@ function loadTexts() g_pathN = document.getElementById("PathN").innerHTML; g_selectFinishVertex = document.getElementById("SelectFinishVertex").innerHTML; g_selectStartVertex = document.getElementById("SelectStartVertex").innerHTML; + + // FindShortPatchsFromOne.js + g_findAllPathesFromVertex = document.getElementById("findAllPathsFromVertex").innerHTML; + g_distanceFrom = document.getElementById("distanceFrom").innerHTML; + g_pathTo = document.getElementById("pathTo").innerHTML; } diff --git a/tpl/home.php b/tpl/home.php index 442f2e0..c5dd79d 100755 --- a/tpl/home.php +++ b/tpl/home.php @@ -10,7 +10,7 @@ - +