Add longest path algorithm.

This commit is contained in:
Oleg Sh
2022-03-20 19:59:40 +02:00
parent 79e5be1f66
commit 1d21cc3727
15 changed files with 291 additions and 0 deletions

View File

@@ -196,6 +196,27 @@ Graph.prototype.FindEdgeMin = function(id1, id2)
return res;
}
Graph.prototype.FindEdgeMax = function(id1, id2)
{
var res = null;
var maxWeight = 0;
for (var i = 0; i < this.edges.length; i++)
{
var edge = this.edges[i];
if ((edge.vertex1.id == id1 && edge.vertex2.id == id2)
|| (!edge.isDirect && edge.vertex1.id == id2 && edge.vertex2.id == id1))
{
if (edge.weight > maxWeight)
{
res = edge;
maxWeight = edge.weight;
}
}
}
return res;
}
Graph.prototype.FindEdgeMinIgnoreDirection = function(id1, id2)
{
var res = null;