diff --git a/script/Application.js b/script/Application.js index 1a042f1..2bbeae1 100644 --- a/script/Application.js +++ b/script/Application.js @@ -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 ++) diff --git a/script/BaseEdge.js b/script/BaseEdge.js index ca8d8ac..8d20f53 100755 --- a/script/BaseEdge.js +++ b/script/BaseEdge.js @@ -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) diff --git a/script/EventHandlers.js b/script/EventHandlers.js index 666674c..2395446 100644 --- a/script/EventHandlers.js +++ b/script/EventHandlers.js @@ -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 + " " + g_selectGroupText + ""; - 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 + "
  • " + g_selectedEdgeStyle + "
  • "; } - if (hasVertexes) { + if (hasVertices) { this.message = this.message + "
  • " + g_commonVertexStyle + "
  • "; this.message = this.message + "
  • " + g_selectedVertexStyle + "
  • "; } @@ -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); }); diff --git a/script/Graph.js b/script/Graph.js index 87c6ed3..05945cf 100644 --- a/script/Graph.js +++ b/script/Graph.js @@ -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); } } diff --git a/script/plugins/ConnectedComponent.js b/script/plugins/ConnectedComponent.js index 062bb39..95a598a 100755 --- a/script/plugins/ConnectedComponent.js +++ b/script/plugins/ConnectedComponent.js @@ -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; diff --git a/script/plugins/GraphReorder.js b/script/plugins/GraphReorder.js index f31fda1..60c79c9 100755 --- a/script/plugins/GraphReorder.js +++ b/script/plugins/GraphReorder.js @@ -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); diff --git a/script/plugins/MinimumSpanningTree.js b/script/plugins/MinimumSpanningTree.js index 8c354cd..4ce9a6b 100755 --- a/script/plugins/MinimumSpanningTree.js +++ b/script/plugins/MinimumSpanningTree.js @@ -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; } diff --git a/script/plugins/RadiusAndDiameter.js b/script/plugins/RadiusAndDiameter.js index edabec3..d3af88b 100755 --- a/script/plugins/RadiusAndDiameter.js +++ b/script/plugins/RadiusAndDiameter.js @@ -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; diff --git a/script/plugins/VerticesDegree.js b/script/plugins/VerticesDegree.js index 71a61c2..3da6d6d 100755 --- a/script/plugins/VerticesDegree.js +++ b/script/plugins/VerticesDegree.js @@ -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() diff --git a/script/texts.js b/script/texts.js index 123c97f..40a5a48 100644 --- a/script/texts.js +++ b/script/texts.js @@ -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";