Add output path for find all paths.

This commit is contained in:
Oleg Sh 2022-03-06 22:37:02 +02:00
parent a60535dd6e
commit 5ae3760ba8
10 changed files with 28 additions and 14 deletions

View File

@ -224,7 +224,7 @@
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -262,7 +262,7 @@
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -261,7 +261,7 @@ We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -261,7 +261,7 @@ Tenemos traducciones en griego 🇬🇷.</a> <a href=\"https://github.com/UnickS
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -229,7 +229,7 @@
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -226,7 +226,7 @@
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -227,7 +227,7 @@
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -223,7 +223,7 @@
//FindAllPatches.js
$g_lang['find_all_pathes'] = "Find all paths";
$g_lang['number_of_pathes_from'] = "Number of pathes from ";
$g_lang['number_of_pathes_from'] = "Number of paths from ";
$g_lang['to'] = " to ";
$g_lang['are'] = " is ";
$g_lang['path_n'] = "Path #";

View File

@ -9,7 +9,8 @@ function FindAllPathes(graph, app)
this.selectedObjects = {};
this.foundSubGraphs = {};
this.nSubgraphIndex = 0;
this.nSubGraphCount = 0;
this.nSubGraphCount = 0;
this.foundPaths = {};
}
@ -67,9 +68,17 @@ FindAllPathes.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_numberOfPathesFrom + this.firstObject.mainText +
g_to + this.secondObject.mainText + g_are +
this.nSubGraphCount + " <select style=\"float:right\" id=\"enumSubgraphs\"></select>";
this.nSubGraphCount + ". " + g_pathN + (1 + parseInt(this.nSubgraphIndex)) + ": " + currentPath +
" <select style=\"float:right\" id=\"enumSubgraphs\"></select>";
}
else
{
@ -92,12 +101,12 @@ FindAllPathes.prototype.resultCallback = function(pathObjects, properties, resul
{
this.nSubGraphCount = results.length > 0 && results[0].type == 1 ? results[0].value : 0;
this.setResultMessage();
this.foundSubGraphs = {};
this.foundPaths = {};
for (var i = 0; i < this.nSubGraphCount; i++)
{
this.foundSubGraphs[i] = {};
this.foundPaths[i] = [];
}
var subGraphIndex = 0;
@ -116,6 +125,8 @@ FindAllPathes.prototype.resultCallback = function(pathObjects, properties, resul
var index = subGraphIndex;
var subgGraph = this.foundSubGraphs[index];
subgGraph[nodeId] = true;
this.foundPaths[index].push(nodeId);
if (prevNodeId >= 0)
{
@ -125,6 +136,8 @@ FindAllPathes.prototype.resultCallback = function(pathObjects, properties, resul
prevNodeId = nodeId;
}
}
this.setResultMessage();
}
else
{
@ -151,8 +164,9 @@ FindAllPathes.prototype.messageWasChanged = function()
$('#enumSubgraphs').change(function () {
self.nSubgraphIndex = $('#enumSubgraphs').val();
self.app.redrawGraph();
self.setResultMessage();
self.app.redrawGraph();
self.app.updateMessage();
});
}
}

View File

@ -10,7 +10,7 @@
<script src="<?= Root('i/js/dev/jquery-ui.js')?>"></script>
<script src="<?= Root('i/js/dev/jquery.feedback_me.js')?>"></script>
<script src="<?= Root("script/example.js?v=57")?>" ></script>
<script src="<?= Root("script/example.js?v=58")?>" ></script>
<!-- Yandex.RTB -->
<script>window.yaContextCb=window.yaContextCb||[]</script>