Fix search Eulerian path/loop if graph has separate nodes.

This commit is contained in:
Oleg Sh
2021-06-12 16:07:37 +02:00
parent d8ed01c438
commit 5076ba07c5
5 changed files with 41 additions and 12 deletions

View File

@@ -99,6 +99,26 @@ Graph.prototype.DeleteVertex = function(vertexObject)
}
}
Graph.prototype.HasConnectedNodes = function(vertexObject)
{
var res = false;
var index = this.vertices.indexOf(vertexObject);
if (index > -1)
{
for (var i = 0; i < this.edges.length; i++)
{
if (this.edges[i].vertex1 == vertexObject || this.edges[i].vertex2 == vertexObject)
{
res = true;
break;
}
}
}
return res;
}
Graph.prototype.FindVertex = function(id)
{
var res = null;