Vertexes -> Vertices pt2

This commit is contained in:
Ivan
2022-07-11 16:00:52 +05:00
parent c6b0da2329
commit 87ef9dbe43
10 changed files with 84 additions and 84 deletions

View File

@@ -47,18 +47,18 @@ FindConnectedComponentNew.prototype.calculate = function(fillUpText = false)
{
this.connectedComponentNumber = 0;
this.component = {};
var tempVertexes = this.graph.vertices.slice();
var tempVertices = this.graph.vertices.slice();
connectedVertex = getVertexToVertexArray(this.graph, true);
var connectedComponentNumber = 0;
while (tempVertexes.length > 0)
while (tempVertices.length > 0)
{
connectedComponentNumber++;
var stack = [];
stack.push(tempVertexes[0]);
stack.push(tempVertices[0]);
tempVertexes.splice(0, 1);
tempVertices.splice(0, 1);
indexInStack = 0;
@@ -80,7 +80,7 @@ FindConnectedComponentNew.prototype.calculate = function(fillUpText = false)
if (stack.indexOf(nextVertex) < 0)
{
stack.push(nextVertex);
tempVertexes.splice(tempVertexes.indexOf(nextVertex), 1);
tempVertices.splice(tempVertices.indexOf(nextVertex), 1);
if (connectedEdge)
{
this.component[connectedEdge.id] = connectedComponentNumber;

View File

@@ -73,7 +73,7 @@ GraphReorder.prototype.result = function(resultCallback)
var vertexData = [];
for(i = 0; i < this.vertices.length; i++) // loop through vertices
{
// Has no in newVertexes.
// Has no in newVertices.
var currentVertex = {};
currentVertex.object = this.vertices[i];
currentVertex.net_force = new Point (0, 0);

View File

@@ -2,7 +2,7 @@
function MinimumSpanningTree(graph, app)
{
BaseAlgorithm.apply(this, arguments);
this.isNotConneted = false;
this.isNotConnected = false;
this.MST = 0;
this.edges = [];
}
@@ -25,7 +25,7 @@ MinimumSpanningTree.prototype.getId = function()
// @return message for user.
MinimumSpanningTree.prototype.getMessage = function(local)
{
if (!this.isNotConneted )
if (!this.isNotConnected )
{
return g_SpanningTreeResult + this.MST + ". " +
(this.graph.hasDirectEdge() ? g_SpanningTreeIgnoreDir : "");
@@ -40,16 +40,16 @@ MinimumSpanningTree.prototype.result = function(resultCallback)
{
this.MST = 0;
this.edges = [];
this.isNotConneted = true;
var tempVertexes = this.graph.vertices.slice();
this.isNotConnected = true;
var tempVertices = this.graph.vertices.slice();
connectedVertex = getVertexToVertexArray(this.graph, true);
// We ignore orientation for this algorithm.
//if (!this.graph.hasDirectEdge())
{
res = this.resultStartedFrom(tempVertexes[0], connectedVertex);
this.isNotConneted = res.isNotConneted;
if (!this.isNotConneted)
res = this.resultStartedFrom(tempVertices[0], connectedVertex);
this.isNotConnected = res.isNotConnected;
if (!this.isNotConnected)
{
this.MST = res.MST;
this.edges = res.edges;
@@ -57,12 +57,12 @@ MinimumSpanningTree.prototype.result = function(resultCallback)
}
/*else
{
for (var i = 0; i < tempVertexes.length; i++)
for (var i = 0; i < tempVertices.length; i++)
{
res = this.resultStartedFrom(tempVertexes[i], connectedVertex);
if (!res.isNotConneted)
res = this.resultStartedFrom(tempVertices[i], connectedVertex);
if (!res.isNotConnected)
{
this.isNotConneted = res.isNotConneted;
this.isNotConnected = res.isNotConnected;
if (this.MST == 0 || res.MST < this.MST)
{
console.log(res);
@@ -85,7 +85,7 @@ MinimumSpanningTree.prototype.resultStartedFrom = function(vertex, connectedVert
var res = {};
res.MST = 0;
res.edges = [];
res.isNotConneted = false;
res.isNotConnected = false;
var inTree = [];
inTree.push(vertex);
@@ -133,14 +133,14 @@ MinimumSpanningTree.prototype.resultStartedFrom = function(vertex, connectedVert
}
}
res.isNotConneted = (inTree.length < this.graph.vertices.length);
res.isNotConnected = (inTree.length < this.graph.vertices.length);
return res;
}
MinimumSpanningTree.prototype.getObjectSelectedGroup = function(object)
{
return this.isNotConneted ? 0 :
return this.isNotConnected ? 0 :
(object instanceof BaseVertex || this.edges.indexOf(object) >= 0) ? 1 : 0;
}

View File

@@ -9,8 +9,8 @@ function RadiusAndDiameter(graph, app)
this.radius = 0;
this.diameterSelectedObjects = [];
this.radiusSelectedObjects = [];
this.centerVertexes = [];
this.peripheralVertexes = [];
this.centerVertices = [];
this.peripheralVertices = [];
this.isNotConnected = false;
this.isOneVertex = false;
}
@@ -148,12 +148,12 @@ RadiusAndDiameter.prototype.result = function(resultCallback)
if (eccentricity[i].value == this.radius)
{
this.centerVertexes.push(this.graph.vertices[i].id);
this.centerVertices.push(this.graph.vertices[i].id);
this.graph.vertices[i].upText = g_vertexCentral;
}
if (eccentricity[i].value == this.diameter)
{
this.peripheralVertexes.push(this.graph.vertices[i].id);
this.peripheralVertices.push(this.graph.vertices[i].id);
this.graph.vertices[i].upText = g_vertexPeripheral;
}
}
@@ -203,8 +203,8 @@ RadiusAndDiameter.prototype.getObjectSelectedGroup = function(object)
{
var res = (this.diameterSelectedObjects.includes(object)) ? 1 : 0;
res = (this.radiusSelectedObjects.includes(object)) ? 2 : res;
//res = (this.centerVertexes.includes(object.id)) ? 3 : res;
//res = (this.peripheralVertexes.includes(object.id)) ? 4 : res;
//res = (this.centerVertices.includes(object.id)) ? 3 : res;
//res = (this.peripheralVertices.includes(object.id)) ? 4 : res;
return res;

View File

@@ -16,7 +16,7 @@ VerticesDegree.prototype = Object.create(BaseAlgorithm.prototype);
VerticesDegree.prototype.getName = function(local)
{
return g_VerticesDegreeName; //local == "ru" ? "Рассчитать степень вершин" : "Calculate vertexes degree";
return g_VerticesDegreeName; //local == "ru" ? "Рассчитать степень вершин" : "Calculate vertices degree";
}
VerticesDegree.prototype.getId = function()