From 469db873e42b5dd6beff41f4bb6114014677f26a Mon Sep 17 00:00:00 2001 From: Oleg Sh Date: Wed, 2 Feb 2022 20:49:01 +0200 Subject: [PATCH] Fix wrong id for edges. --- script/Graph.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/script/Graph.js b/script/Graph.js index 6e65e7d..8db3934 100644 --- a/script/Graph.js +++ b/script/Graph.js @@ -24,6 +24,8 @@ function Graph() Graph.prototype.infinity = 1E8; // Max vertexes Graph.prototype.maxVertexes = 1000; +// Offset for edges ids. +Graph.prototype.edgesOffset = 10000; Graph.prototype.AddNewVertex = function(vertex) { @@ -901,8 +903,11 @@ Graph.prototype.LoadFromXML = function (xmlText, additionalData) // Back comportebility. if (isNaN(loadedEdgeId)) { - loadedEdgeId = 10000; - } + loadedEdgeId = this.edgesOffset; + } else if (loadedEdgeId < this.edgesOffset) + { + loadedEdgeId = this.edgesOffset; + } this.uidGraph = loadedGraphId; this.uidEdge = loadedEdgeId; @@ -925,6 +930,11 @@ Graph.prototype.LoadFromXML = function (xmlText, additionalData) $edges.each(function(){ var edge = new BaseEdge(); edge.LoadFromXML($(this), graph); + // Fix case with wrong id. + if (edge.id < graph.uidEdge) { + edge.id = graph.uidEdge; + graph.uidEdge++; + } edges.push(edge); });