Support multigraph for algorithms:

- Find all paths.
- Find longest path.
- Find all shortest paths.
This commit is contained in:
Oleg Sh
2025-08-16 13:58:09 +02:00
parent d3416b63b3
commit dfeac352c1
27 changed files with 89 additions and 59 deletions

View File

@@ -110,13 +110,11 @@ FindAllPathes.prototype.resultCallback = function(pathObjects, properties, resul
}
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)
@@ -126,14 +124,15 @@ FindAllPathes.prototype.resultCallback = function(pathObjects, properties, resul
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.foundPaths[index].push(nodeId);
}
if (results[i].type == 5)
{
var edgeId = parseInt(results[i].value);
var index = subGraphIndex;
var subgGraph = this.foundSubGraphs[index];
subgGraph[edgeId] = true;
}
}
@@ -226,6 +225,11 @@ FindAllPathes.prototype.IsSupportNegativeWeight = function()
return true;
}
FindAllPathes.prototype.IsSupportMultiGraph = function()
{
return true;
}
// Factory for connected components.
function CreateFindAllPathes(graph, app)
{