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

@ -963,7 +963,7 @@ Application.prototype.SetIncidenceMatrix = function (matrix)
Application.prototype.Test = function ()
{
this.graph.VertexesReposition(new Point(this.GetRealWidth(), this.GetRealHeight()), this.graph.vertices);
this.graph.VerticesReposition(new Point(this.GetRealWidth(), this.GetRealHeight()), this.graph.vertices);
this.redrawGraph();
}
@ -1146,7 +1146,7 @@ Application.prototype.LoadGraphFromString = function (str)
this.graph = graph;
if (this.graph.isNeedReposition())
{
this.graph.VertexesReposition(new Point(this.GetRealWidth(), this.GetRealHeight()), this.graph.vertices);
this.graph.VerticesReposition(new Point(this.GetRealWidth(), this.GetRealHeight()), this.graph.vertices);
}
this.AutoAdjustViewport();
this.updateMessage();
@ -1813,7 +1813,7 @@ Application.prototype._RedrawGraph = function(context, backgroundPosition, backg
this.RedrawSelectionRect(context);
}
Application.prototype.GetSelectedVertexes = function()
Application.prototype.GetSelectedVertices = function()
{
var res = [];
for (i = 0; i < this.graph.vertices.length; i ++)

View File

@ -213,11 +213,11 @@ BaseEdge.prototype.GetEdgePositions = function()
direction1.normalize(1.0);
direction2.normalize(1.0);
var vertexes = [];
vertexes.push({vertex : this.vertex1, direction : direction1, position : position1, diameter : d1});
vertexes.push({vertex : this.vertex2, direction : direction2, position : position2, diameter : d2});
var vertices = [];
vertices.push({vertex : this.vertex1, direction : direction1, position : position1, diameter : d1});
vertices.push({vertex : this.vertex2, direction : direction2, position : position2, diameter : d2});
vertexes.forEach(function(data)
vertices.forEach(function(data)
{
var shape = data.vertex.currentStyle.GetStyle({}, data.vertex).shape;
if (shape == VertexCircleShape)

View File

@ -637,14 +637,14 @@ DefaultHandler.prototype.MouseUp = function(pos)
customEnum.ShowDialog(callback, g_rename, g_renameVertex, handler.selectedObject.mainText);
});
$('#message').on('click', '#changeCommonStyle', function(){
var selectedVertexes = handler.app.GetSelectedVertexes();
var selectedVertices = handler.app.GetSelectedVertices();
var setupVertexStyle = new SetupVertexStyle(handler.app);
setupVertexStyle.show(0, selectedVertexes);
setupVertexStyle.show(0, selectedVertices);
});
$('#message').on('click', '#changeSelectedStyle', function(){
var selectedVertexes = handler.app.GetSelectedVertexes();
var selectedVertices = handler.app.GetSelectedVertices();
var setupVertexStyle = new SetupVertexStyle(handler.app);
setupVertexStyle.show(1, selectedVertexes);
setupVertexStyle.show(1, selectedVertices);
});
}
else if (this.selectedObject != null && (this.selectedObject instanceof BaseEdge))
@ -745,14 +745,14 @@ DefaultHandler.prototype.MouseUp = function(pos)
{
this.message = g_dragGroupText + " <span class=\"hidden-phone\">" + g_selectGroupText + "</span>";
var hasVertexes = false;
var hasVertices = false;
var hasEdges = false;
for(var i = 0; i < this.selectedObjects.length; i ++)
{
var object = this.selectedObjects[i];
if (object instanceof BaseVertex)
{
hasVertexes = true;
hasVertices = true;
}
else if (object instanceof BaseEdge)
{
@ -779,7 +779,7 @@ DefaultHandler.prototype.MouseUp = function(pos)
this.message = this.message + " <li><a href=\"#\" id=\"changeSelectedStyleEdge\">" + g_selectedEdgeStyle + "</a></li>";
}
if (hasVertexes) {
if (hasVertices) {
this.message = this.message + " <li><a href=\"#\" id=\"changeCommonStyleVertex\">" + g_commonVertexStyle + "</a></li>";
this.message = this.message + " <li><a href=\"#\" id=\"changeSelectedStyleVertex\">" + g_selectedVertexStyle + "</a></li>";
}
@ -883,16 +883,16 @@ DefaultHandler.prototype.MouseUp = function(pos)
});
}
if (hasVertexes) {
if (hasVertices) {
$('#message').on('click', '#changeCommonStyleVertex', function(){
var selectedVertexes = handler.app.GetSelectedVertexes();
var selectedVertices = handler.app.GetSelectedVertices();
var setupVertexStyle = new SetupVertexStyle(handler.app);
setupVertexStyle.show(0, selectedVertexes);
setupVertexStyle.show(0, selectedVertices);
});
$('#message').on('click', '#changeSelectedStyleVertex', function(){
var selectedVertexes = handler.app.GetSelectedVertexes();
var selectedVertices = handler.app.GetSelectedVertices();
var setupVertexStyle = new SetupVertexStyle(handler.app);
setupVertexStyle.show(1, selectedVertexes);
setupVertexStyle.show(1, selectedVertices);
});
}
}
@ -1729,13 +1729,13 @@ function SetupVertexStyle(app)
// inheritance.
SetupVertexStyle.prototype = Object.create(BaseHandler.prototype);
SetupVertexStyle.prototype.show = function(index, selectedVertexes)
SetupVertexStyle.prototype.show = function(index, selectedVertices)
{
var handler = this;
var dialogButtons = {};
var graph = this.app.graph;
var app = this.app;
this.forAll = selectedVertexes == null;
this.forAll = selectedVertices == null;
var forAll = this.forAll;
var self = this;
@ -1745,7 +1745,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
self.originStyle = (self.index == 0 ? app.vertexCommonStyle : app.vertexSelectedVertexStyles[self.index - 1]);
if (!forAll)
{
self.originStyle = selectedVertexes[0].getStyleFor(self.index);
self.originStyle = selectedVertices[0].getStyleFor(self.index);
}
self.style = FullObjectCopy(self.originStyle);
}
@ -1754,7 +1754,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
var fillFields = function()
{
var fullStyle = self.style.GetStyle({}, forAll ? undefined : selectedVertexes[0]);
var fullStyle = self.style.GetStyle({}, forAll ? undefined : selectedVertices[0]);
$( "#vertexFillColor" ).val(fullStyle.fillStyle);
$( "#vertexStrokeColor" ).val(fullStyle.strokeStyle);
@ -1762,7 +1762,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
$( "#upVertexTextColor" ).val(fullStyle.upTextColor);
$( "#vertexStrokeSize" ).val(fullStyle.lineWidth);
$( "#vertexShape" ).val(fullStyle.shape);
$( "#vertexSize" ).val(forAll ? app.GetDefaultVertexSize() : selectedVertexes[0].model.diameter);
$( "#vertexSize" ).val(forAll ? app.GetDefaultVertexSize() : selectedVertices[0].model.diameter);
$( "#commonTextPosition" ).val(fullStyle.commonTextPosition);
if (self.index > 0 || self.index == "all")
@ -1811,7 +1811,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
var redrawVertex = function()
{
var fullStyle = self.style.GetStyle({}, forAll ? undefined : selectedVertexes[0]);
var fullStyle = self.style.GetStyle({}, forAll ? undefined : selectedVertices[0]);
if (fullStyle.fillStyle != $( "#vertexFillColor" ).val())
self.style.fillStyle = $( "#vertexFillColor" ).val();
@ -1851,7 +1851,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
baseVertex.model.diameter = diameter;
if (!forAll)
baseVertex.ownStyles = selectedVertexes[0].ownStyles;
baseVertex.ownStyles = selectedVertices[0].ownStyles;
graphDrawer.Draw(baseVertex, self.style.GetStyle({}, baseVertex));
@ -1885,7 +1885,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
}
else
{
selectedVertexes.forEach(function(vertex) {
selectedVertices.forEach(function(vertex) {
vertex.model.diameter = diameter;
});
}
@ -1919,7 +1919,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
}
else
{
selectedVertexes.forEach(function(vertex) {
selectedVertices.forEach(function(vertex) {
indexes.forEach(function(index) {
vertex.resetOwnStyle(index);
});
@ -1963,7 +1963,7 @@ SetupVertexStyle.prototype.show = function(index, selectedVertexes)
{
if (JSON.stringify(self.originStyle) !== JSON.stringify(self.style))
{
selectedVertexes.forEach(function(vertex) {
selectedVertices.forEach(function(vertex) {
indexes.forEach(function(index) {
vertex.setOwnStyle(index.index, index.style);
});

View File

@ -22,14 +22,14 @@ function Graph()
// infinity
Graph.prototype.infinity = 1E8;
// Max vertexes
Graph.prototype.maxVertexes = 1000;
// Max vertices
Graph.prototype.maxVertices = 1000;
// Offset for edges ids.
Graph.prototype.edgesOffset = 10000;
Graph.prototype.AddNewVertex = function(vertex)
{
if (this.vertices.length <= this.maxVertexes)
if (this.vertices.length <= this.maxVertices)
{
vertex.SetId (this.uidGraph);
this.uidGraph = this.uidGraph + 1;
@ -350,7 +350,7 @@ Graph.prototype.TestAdjacencyMatrix = function (matrix, rowsObj, colsObj, separa
}
Graph.prototype.IsVertexesHasSamePosition = function (position, vertexCount)
Graph.prototype.IsVerticesHaveSamePosition = function (position, vertexCount)
{
var res = false;
@ -399,7 +399,7 @@ Graph.prototype.GetRandomPositionOfVertex = function (matrix, vertexIndex, viewp
point = new Point(Math.random() * viewportSize.x, Math.random() * viewportSize.y);
}
if (this.IsVertexesHasSamePosition (point, matrix.length))
if (this.IsVerticesHaveSamePosition (point, matrix.length))
{
point.offset (Math.random() * diameter + + (Math.random() ? -1 : 1) * 4 * diameter,
Math.random() * diameter + + (Math.random() ? -1 : 1) * 4 * diameter);
@ -412,7 +412,7 @@ Graph.prototype.GetRandomPositionOfVertex = function (matrix, vertexIndex, viewp
return point;
}
Graph.prototype.VertexesReposition = function (viewportSize, newVertexes)
Graph.prototype.VerticesReposition = function (viewportSize, newVertices)
{
var maxGravityDistanceSqr = Math.max(viewportSize.x, viewportSize.y) / 5.0;
maxGravityDistanceSqr = maxGravityDistanceSqr * maxGravityDistanceSqr;
@ -434,10 +434,10 @@ Graph.prototype.VertexesReposition = function (viewportSize, newVertexes)
}
var startAngel = Math.random() * 180.0;
for(i = 0; i < newVertexes.length; i++) // loop through vertices
for(i = 0; i < newVertices.length; i++) // loop through vertices
{
newVertexes[i].position.orbit(new Point(viewportSize.x / 2, viewportSize.y / 2), (viewportSize.x - diameter * 2) / 2,
(viewportSize.y - diameter * 2) / 2, 360 * i / newVertexes.length + startAngel);
newVertices[i].position.orbit(new Point(viewportSize.x / 2, viewportSize.y / 2), (viewportSize.x - diameter * 2) / 2,
(viewportSize.y - diameter * 2) / 2, 360 * i / newVertices.length + startAngel);
}
var k = 0;
@ -445,11 +445,11 @@ Graph.prototype.VertexesReposition = function (viewportSize, newVertexes)
while (k < 1000 && bChanged)
{
var vertexData = [];
for(i = 0; i < newVertexes.length; i++) // loop through vertices
for(i = 0; i < newVertices.length; i++) // loop through vertices
{
// Has no in newVertexes.
// Has no in newVertices.
var currentVertex = {};
currentVertex.object = newVertexes[i];
currentVertex.object = newVertices[i];
currentVertex.net_force = new Point (0, 0);
currentVertex.velocity = new Point (0, 0);
vertexData.push(currentVertex);
@ -520,10 +520,10 @@ Graph.prototype.VertexesReposition = function (viewportSize, newVertexes)
var bbox = this.getGraphBBox();
if (bbox.size().length() > viewportSize.length() * 1000)
{
for(i = 0; i < newVertexes.length; i++) // loop through vertices
for(i = 0; i < newVertices.length; i++) // loop through vertices
{
newVertexes[i].position.orbit(new Point(viewportSize.x / 2, viewportSize.y / 2), (viewportSize.x - diameter * 2) / 2,
(viewportSize.y - diameter * 2) / 2, 360 * i / newVertexes.length + startAngel);
newVertices[i].position.orbit(new Point(viewportSize.x / 2, viewportSize.y / 2), (viewportSize.x - diameter * 2) / 2,
(viewportSize.y - diameter * 2) / 2, 360 * i / newVertices.length + startAngel);
}
}
else
@ -539,9 +539,9 @@ Graph.prototype.VertexesReposition = function (viewportSize, newVertexes)
for (var i = 1; i < count; i++)
{
for(j = 0; j < newVertexes.length; j++) // loop through vertices
for(j = 0; j < newVertices.length; j++) // loop through vertices
{
newVertexes[j].position.rotate(center, angle);
newVertices[j].position.rotate(center, angle);
}
var newBBox = this.getGraphBBox();
@ -554,9 +554,9 @@ Graph.prototype.VertexesReposition = function (viewportSize, newVertexes)
}
// Rotate to best aspect.
for(j = 0; j < newVertexes.length; j++) // loop through vertices
for(j = 0; j < newVertices.length; j++) // loop through vertices
{
newVertexes[j].position.rotate(center, - angle * (count - bestIndex - 1));
newVertices[j].position.rotate(center, - angle * (count - bestIndex - 1));
}
}
}
@ -584,7 +584,7 @@ Graph.prototype.SetAdjacencyMatrix = function (matrix, viewportSize, currentEnum
this.DeleteEdge (clonedEdge[i]);
}
var newVertexes = [];
var newVertices = [];
var bWeightGraph = false;
for (var i = 0; i < rows.length; i++)
@ -594,8 +594,8 @@ Graph.prototype.SetAdjacencyMatrix = function (matrix, viewportSize, currentEnum
if (j >= this.vertices.length)
{
var newPos = this.GetRandomPositionOfVertex (matrix, j, viewportSize);
newVertexes.push(new BaseVertex(newPos.x, newPos.y, currentEnumVerticesType));
this.AddNewVertex(newVertexes[newVertexes.length - 1]);
newVertices.push(new BaseVertex(newPos.x, newPos.y, currentEnumVerticesType));
this.AddNewVertex(newVertices[newVertices.length - 1]);
}
if (cols[i][j] > 0)
@ -624,7 +624,7 @@ Graph.prototype.SetAdjacencyMatrix = function (matrix, viewportSize, currentEnum
i--;
}
this.VertexesReposition(viewportSize, newVertexes);
this.VerticesReposition(viewportSize, newVertices);
}
}
@ -709,7 +709,7 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
{
this.DeleteEdge (clonedEdge[i]);
}
var newVertexes = [];
var newVertices = [];
var bWeightGraph = false;
for (var i = 0; i < cols[0].length; i++)
{
@ -721,8 +721,8 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
{
var newPos = new Point(0, 0);//this.GetRandomPositionOfVertex (matrix, j, viewportSize);
newVertexes.push(new BaseVertex(newPos.x, newPos.y, currentEnumVerticesType));
this.AddNewVertex(newVertexes[newVertexes.length - 1]);
newVertices.push(new BaseVertex(newPos.x, newPos.y, currentEnumVerticesType));
this.AddNewVertex(newVertices[newVertices.length - 1]);
}
if (cols[j][i] != 0)
@ -774,7 +774,7 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
i--;
}
this.VertexesReposition(viewportSize, newVertexes);
this.VerticesReposition(viewportSize, newVertices);
}
}

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()

View File

@ -127,7 +127,7 @@ var g_minimumSpanningTree = "Search of minimum spanning tree";
var g_modernGraphStyleName = "Visualization based on weight";
var g_RadiusAndDiameter = "Search graph radius and diameter";
var g_findShortPathName = "Find shortest path using Dijkstra's algorithm";
var g_VerticesDegreeName = "Calculate vertexes degree";
var g_VerticesDegreeName = "Calculate vertices degree";
var g_SpanningTreeResult = "Min Spanning Tree is";
var g_SpanningTreeIgnoreDir = "We ignored edges direction for calculation";
var g_SpanningTreeNotConnected = "Graph is not connected";