From ea61466fe07f994ef9ba14c354b96ea826a3a9d9 Mon Sep 17 00:00:00 2001 From: Oleg Sh Date: Wed, 24 Dec 2025 16:17:38 +0100 Subject: [PATCH] Enhance matrix display functionality and formatting. --- core/config/main.php | 2 +- i/css/home.css | 69 +++++++++++ lang/ru/home.php | 4 +- script/entities/graph/model/Graph.js | 113 +++++++++++++----- .../algorithms/model/plugins/Floid.js | 42 ++++++- .../features/show_adjacency_matrix/index.js | 41 ++++++- script/features/show_distance_matrix/index.js | 97 ++++++++++++--- .../features/show_incidence_matrix/index.js | 27 ++++- .../api/index.js.cache | 49 +++++--- .../api/index.js.cache | 49 +++++--- .../create_graph_by_matrix/api/index.js.cache | 49 +++++--- script/pages/editor/api/index.js.cache | 53 ++++---- script/pages/editor/model/Application.js | 4 +- tpl/home.php | 48 ++++++-- 14 files changed, 510 insertions(+), 137 deletions(-) diff --git a/core/config/main.php b/core/config/main.php index 6c661da..aec6e24 100755 --- a/core/config/main.php +++ b/core/config/main.php @@ -94,5 +94,5 @@ $g_config['vote'] = "./tmp/vote/vote.txt"; $g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_"; $g_config['use_js_cache'] = true; - $g_config['engine_version'] = 103; + $g_config['engine_version'] = 104; ?> diff --git a/i/css/home.css b/i/css/home.css index 71f3c17..184b9fb 100755 --- a/i/css/home.css +++ b/i/css/home.css @@ -60,6 +60,7 @@ overflow: scroll; width : 100%; height: 300px; + min-width: 400px; overflow-wrap: normal; } @@ -68,6 +69,7 @@ overflow: scroll; width : 100%; height: 300px; + min-width: 400px; overflow-wrap: normal; } @@ -76,6 +78,7 @@ overflow: scroll; width : 100%; height: 300px; + min-width: 400px; overflow-wrap: normal; } @@ -372,14 +375,17 @@ #AdjacencyMatrixField { height: 200px; + min-width: 200px; } #IncidenceMatrixField { height: 200px; + min-width: 200px; } #IncidenceMatrixField { height: 200px; + min-width: 200px; } #addVertex @@ -495,4 +501,67 @@ label.switcherText { #autoSaveOrOriginalGraph .btn-xs{ font-size: 12px; +} + +/* Common matrix parameters */ +.ui-widget textarea.matrix, +.top-text, +.side-text { + font-family: ui-monospace, Consolas, monospace; + font-size: 14px; + line-height: 1.4; + white-space: pre; + box-sizing: border-box; +} + +/* GRID 2×2 */ +.matrix-wrapper { + display: grid; + grid-template-columns: max-content auto; + grid-template-rows: auto auto; + width: 100%; +} + +/* Empty corner */ +.corner { + width: 40px; + height: 40px; + display: grid; + place-items: center; +} + +/* Top text */ +.top-text-wrap { + /* width: 120px; */ /* ← Set in JS */ + width: 10px; + height: 40px; + overflow: hidden; +} + +.top-text { + padding: 6px; +} + +/* Left text */ +.side-text-wrap { + width: 40px; + height: 300px; /* ← Same as textarea */ + overflow: hidden; +} + +@media only screen and (max-width: 650px) { + .side-text-wrap { + height: 200px; /* ← Same as textarea */ + } +} + +.side-text { + padding: 6px; +} + +/* TEXTAREA */ +.ui-widget textarea.matrix { + padding: 6px; + overflow: auto; + resize: both; } \ No newline at end of file diff --git a/lang/ru/home.php b/lang/ru/home.php index 097acec..4fa8df6 100755 --- a/lang/ru/home.php +++ b/lang/ru/home.php @@ -345,7 +345,7 @@ $g_lang['salesman_problem'] = "Задача коммивояжёра"; $g_lang['no_solution'] = "Решения не существует"; - $g_lang['shortest_loop_is'] = "Кратчайшие цикл имеет длинну "; + $g_lang['shortest_loop_is'] = "Кратчайший цикл имеет длинну "; $g_lang['salesman_path_problem'] = "Задача коммивояжёра для пути"; - $g_lang['shortest_path_is'] = "Кратчайшие путь имеет длинну "; + $g_lang['shortest_path_is'] = "Кратчайший путь имеет длинну "; ?> diff --git a/script/entities/graph/model/Graph.js b/script/entities/graph/model/Graph.js index 0542f2f..9a5db2f 100644 --- a/script/entities/graph/model/Graph.js +++ b/script/entities/graph/model/Graph.js @@ -289,31 +289,70 @@ Graph.prototype.FindAllEdges = function(id1, id2) return res; } -Graph.prototype.GetAdjacencyMatrixStr = function () +Graph.prototype.GetAdjacencyMatrixStr = function (res_columns_width) { var matrix = ""; + let cols_width = []; + + let get_edge_weight_str = (vertex_1, vertex_2) => { + var res = ""; + + var edge = this.FindEdgeMin (vertex_1.id, vertex_2.id); + if (edge != null) + { + res += edge.weight; + } + else + { + res += "0"; + } + + return res; + } + + // Calculate max width for each column + for (var j = 0; j < this.vertices.length; j++) + { + cols_width.push(0); + for (var i = 0; i < this.vertices.length; i++) + { + let weight_str = get_edge_weight_str(this.vertices[i], this.vertices[j]); + let weight_len = weight_str.length; + // Make the length at least 2 if vertex name length > 1 + if (this.vertices[j].mainText.toString().length > weight_len && weight_len == 1) + { + weight_len = 2; + } + if (weight_len > cols_width[j]) + { + cols_width[j] = weight_len; + } + } + } + for (var i = 0; i < this.vertices.length; i++) { for (var j = 0; j < this.vertices.length; j++) { - var edge = this.FindEdgeMin (this.vertices[i].id, this.vertices[j].id); - if (edge != null) + let weight_str = get_edge_weight_str(this.vertices[i], this.vertices[j]); + if (weight_str.length < cols_width[j]) { - matrix += edge.weight; - } - else - { - matrix += "0"; + weight_str = " ".repeat(cols_width[j] - weight_str.length) + weight_str; } + matrix += weight_str; if (j != this.vertices.length) { matrix += ", "; } - } matrix = matrix + "\n"; } + + if (res_columns_width !== undefined) { + res_columns_width.length = 0; + res_columns_width.push(...cols_width); + } return matrix; } @@ -939,32 +978,50 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum Graph.prototype.GetIncidenceMatrix = function () { var matrix = ""; + let cols_width = []; + + let get_edge_weight_str = (vertex_index, edge_index) => { + if (this.edges[edge_index].vertex1 == this.vertices[vertex_index]) + { + return this.edges[edge_index].weight.toString(); + } + else if (this.edges[edge_index].vertex2 == this.vertices[vertex_index] && !this.edges[edge_index].isDirect) + { + return this.edges[edge_index].weight.toString(); + } + else if (this.edges[edge_index].vertex2 == this.vertices[vertex_index] && this.edges[edge_index].isDirect) + { + return -this.edges[edge_index].weight.toString(); + } + else + { + return "0"; + } + }; + + for (var j = 0; j < this.edges.length; j++) + { + let max_width = 0; + for (var i = 0; i < this.vertices.length; i++) + { + let str = "" + get_edge_weight_str(i, j); + max_width = Math.max(max_width, str.length); + } + cols_width.push(max_width); + } + for (var i = 0; i < this.vertices.length; i++) { for (var j = 0; j < this.edges.length; j++) { - if (this.edges[j].vertex1 == this.vertices[i]) - { - matrix += this.edges[j].weight; - } - else if (this.edges[j].vertex2 == this.vertices[i] && !this.edges[j].isDirect) - { - matrix += this.edges[j].weight; - } - else if (this.edges[j].vertex2 == this.vertices[i] && this.edges[j].isDirect) - { - matrix += -this.edges[j].weight; - } - else - { - matrix += "0"; - } - + let weight_str = get_edge_weight_str(i, j); + weight_str = " ".repeat(cols_width[j] - weight_str.length) + weight_str; + + matrix += "" + weight_str; if (j != this.edges.length - 1) { matrix += ", "; - } - + } } matrix = matrix + "\n"; } diff --git a/script/features/algorithms/model/plugins/Floid.js b/script/features/algorithms/model/plugins/Floid.js index 438cede..8aee28a 100644 --- a/script/features/algorithms/model/plugins/Floid.js +++ b/script/features/algorithms/model/plugins/Floid.js @@ -139,7 +139,37 @@ FloidAlgorithm.prototype.messageWasChanged = function() dialogButtons[g_close] = function() { $( this ).dialog( "close" ); }; - $( "#FloidMatrixField" ).val(self.GetFloidMatrix()); + let ta = $("#FloidMatrixField"); + let topWrap = $("#floidMatrix_top_text"); + let sideWrap = $("#floidMatrix_side_text"); + ta.on("scroll", function() { + topWrap.scrollLeft(ta.scrollLeft()); + sideWrap.scrollTop(ta.scrollTop()); + }); + + let columns_width = []; + $( "#FloidMatrixField" ).val(self.GetFloidMatrix(columns_width).trimEnd()); + ta.focus()[0].setSelectionRange(0, 0); + /* Make side and top text */ + let sideText = ""; + let topText = ""; + for (let i = 0; i < self.graph.vertices.length; i++) + { + /* Each vertex name max 3 symbols */ + sideText += self.graph.vertices[i].mainText.toString().slice(0, 3) + "\n"; + + let col_width = columns_width[i]; + let col_text = self.graph.vertices[i].mainText.toString(); + if (col_width < col_text.length) + { + col_text = col_text.slice(0, col_width); + } + col_text = col_text.padStart(col_width, " "); + topText += col_text + " "; + } + $("#floidMatrix_top_text_text").html(topText); + $("#floidMatrix_side_text_text").html(sideText + "\n"); + $( "#floidMatrix" ).dialog({ resizable: false, height: "auto", @@ -147,7 +177,11 @@ FloidAlgorithm.prototype.messageWasChanged = function() modal: true, title: g_minDistMatrixText, buttons: dialogButtons, - dialogClass: 'EdgeDialog' + dialogClass: 'EdgeDialog', + open: function(event, ui) { + /* Set width for side text */ + $("#floidMatrix_top_text").width(ta.width()); + } }); }; } @@ -157,9 +191,9 @@ FloidAlgorithm.prototype.messageWasChanged = function() }); } -FloidAlgorithm.prototype.GetFloidMatrix = function() +FloidAlgorithm.prototype.GetFloidMatrix = function(res_columns_width) { - return this.graph.GetAdjacencyMatrixStr(); + return this.graph.GetAdjacencyMatrixStr(res_columns_width); } diff --git a/script/features/show_adjacency_matrix/index.js b/script/features/show_adjacency_matrix/index.js index a8653d7..33ee964 100644 --- a/script/features/show_adjacency_matrix/index.js +++ b/script/features/show_adjacency_matrix/index.js @@ -46,8 +46,40 @@ ShowAdjacencyMatrix.prototype.show = function() $( this ).dialog( "close" ); }; - $( "#AdjacencyMatrixField" ).val(this.app.GetAdjacencyMatrix()); + let ta = $("#AdjacencyMatrixField"); + let topWrap = $("#adjacencyMatrix_top_text"); + let sideWrap = $("#adjacencyMatrix_side_text"); + + ta.on("scroll", function() { + topWrap.scrollLeft(ta.scrollLeft()); + sideWrap.scrollTop(ta.scrollTop()); + }); + + let res_columns_width = []; + ta.val(this.app.GetAdjacencyMatrix(res_columns_width).trimEnd()); + ta.focus()[0].setSelectionRange(0, 0); + $( "#BadMatrixFormatMessage" ).hide(); + + /* Make side and top text */ + let sideText = ""; + let topText = ""; + for (let i = 0; i < this.app.graph.vertices.length; i++) + { + /* Each vertex name max 3 symbols */ + sideText += this.app.graph.vertices[i].mainText.toString().slice(0, 3) + "\n"; + + let col_width = res_columns_width[i]; + let col_text = this.app.graph.vertices[i].mainText.toString(); + if (col_width < col_text.length) + { + col_text = col_text.slice(0, col_width); + } + col_text = col_text.padStart(col_width, " "); + topText += col_text + " "; + } + $("#adjacencyMatrix_top_text_text").html(topText); + $("#adjacencyMatrix_side_text_text").html(sideText + "\n"); if (this.app.graph.isMulti()) $( "#AdjacencyMatrixMultiGraphDesc").show(); @@ -61,6 +93,11 @@ ShowAdjacencyMatrix.prototype.show = function() modal: true, title: g_adjacencyMatrixText, buttons: dialogButtons, - dialogClass: 'EdgeDialog' + dialogClass: 'EdgeDialog', + open: function(event, ui) { + /* Set width for side text */ + $("#adjacencyMatrix_top_text").width(ta.width()); + $("#BadMatrixFormatMessage").width(ta.width()); + } }); } diff --git a/script/features/show_distance_matrix/index.js b/script/features/show_distance_matrix/index.js index 2ce1c0b..4420840 100644 --- a/script/features/show_distance_matrix/index.js +++ b/script/features/show_distance_matrix/index.js @@ -20,25 +20,55 @@ ShowDistanceMatrix.prototype.firstObject = null; // Path ShowDistanceMatrix.prototype.pathObjects = null; -ShowDistanceMatrix.prototype.GetIncidenceMatrix = function (rawMatrix) +ShowDistanceMatrix.prototype.GetIncidenceMatrix = function (rawMatrix, res_columns_width) { + let get_weight_str = function (i, j) + { + let str = ""; + if (i == j) + { + str += "0"; + } + else if ((new Graph()).infinity == rawMatrix[i][j]) + { + str += '\u221E'; + } + else + { + str += rawMatrix[i][j]; + } + return str; + }; + + for (var j = 0; j < rawMatrix.length; j++) + { + let max_length = 0; + for (var i = 0; i < rawMatrix.length; i++) + { + let str = get_weight_str(i, j); + let weight_len = str.length; + // Make the length at least 2 if vertex name length > 1 + if (this.app.graph.vertices[j].mainText.toString().length > weight_len && weight_len == 1) + { + weight_len = 2; + } + max_length = Math.max(max_length, weight_len); + } + res_columns_width.push(max_length); + } + var matrix = ""; for (var i = 0; i < rawMatrix.length; i++) { for (var j = 0; j < rawMatrix[i].length; j++) { - if (i == j) - { - matrix += "0"; - } - else if ((new Graph()).infinity == rawMatrix[i][j]) - { - matrix += '\u221E'; - } - else - { - matrix += rawMatrix[i][j]; - } + let weight_str = get_weight_str(i, j); + if (weight_str.length < res_columns_width[j]) + { + weight_str = " ".repeat(res_columns_width[j] - weight_str.length) + weight_str; + } + + matrix += weight_str; if (j != rawMatrix[i].length - 1) { @@ -63,7 +93,39 @@ ShowDistanceMatrix.prototype.show = function() var handler = g_Algorithms[g_AlgorithmIds.indexOf("OlegSh.FloidAlgorithm")](this.app.graph, this.app); - $( "#FloidMatrixField" ).val(this.GetIncidenceMatrix(handler.resultMatrix())); + let ta = $("#FloidMatrixField"); + let topWrap = $("#floidMatrix_top_text"); + let sideWrap = $("#floidMatrix_side_text"); + + ta.on("scroll", function() { + topWrap.scrollLeft(ta.scrollLeft()); + sideWrap.scrollTop(ta.scrollTop()); + }); + + let res_columns_width = []; + + ta.val(this.GetIncidenceMatrix(handler.resultMatrix(), res_columns_width).trimEnd()); + ta.focus()[0].setSelectionRange(0, 0); + + /* Make side and top text */ + let sideText = ""; + let topText = ""; + for (let i = 0; i < this.app.graph.vertices.length; i++) + { + /* Each vertex name max 3 symbols */ + sideText += this.app.graph.vertices[i].mainText.toString().slice(0, 3) + "\n"; + + let col_width = res_columns_width[i]; + let col_text = this.app.graph.vertices[i].mainText.toString(); + if (col_width < col_text.length) + { + col_text = col_text.slice(0, col_width); + } + col_text = col_text.padStart(col_width, " "); + topText += col_text + " "; + } + $("#floidMatrix_top_text_text").html(topText); + $("#floidMatrix_side_text_text").html(sideText + "\n"); $( "#floidMatrix" ).dialog({ resizable: false, @@ -72,6 +134,11 @@ ShowDistanceMatrix.prototype.show = function() modal: true, title: g_minDistMatrixText, buttons: dialogButtons, - dialogClass: 'EdgeDialog' + dialogClass: 'EdgeDialog', + open: function(event, ui) { + /* Set width for side text */ + $("#floidMatrix_top_text").width(ta.width()); + } }); + } diff --git a/script/features/show_incidence_matrix/index.js b/script/features/show_incidence_matrix/index.js index e4bd53c..94bbd71 100644 --- a/script/features/show_incidence_matrix/index.js +++ b/script/features/show_incidence_matrix/index.js @@ -46,9 +46,27 @@ ShowIncidenceMatrix.prototype.show = function() $( this ).dialog( "close" ); }; - $( "#IncidenceMatrixField" ).val(this.app.GetIncidenceMatrix()); + let ta = $("#IncidenceMatrixField"); + let sideWrap = $("#incidenceMatrix_side_text"); + + ta.on("scroll", function() { + sideWrap.scrollTop(ta.scrollTop()); + }); + + $( "#IncidenceMatrixField" ).val(this.app.GetIncidenceMatrix().trimEnd()); + ta.focus()[0].setSelectionRange(0, 0); + $( "#BadIncidenceMatrixFormatMessage" ).hide(); + /* Make side and top text */ + let sideText = ""; + for (let i = 0; i < this.app.graph.vertices.length; i++) + { + /* Each vertex name max 3 symbols */ + sideText += this.app.graph.vertices[i].mainText.toString().slice(0, 3) + "\n"; + } + $("#incidenceMatrix_side_text_text").html(sideText + "\n"); + $( "#incidenceMatrix" ).dialog({ resizable: false, height: "auto", @@ -56,6 +74,11 @@ ShowIncidenceMatrix.prototype.show = function() modal: true, title: g_incidenceMatrixText, buttons: dialogButtons, - dialogClass: 'EdgeDialog' + dialogClass: 'EdgeDialog', + open: function(event, ui) { + /* Set width for side text */ + $("#incidenceMatrix_top_text").width(ta.width()); + $("#BadIncidenceMatrixFormatMessage").width(ta.width()); + } }); } diff --git a/script/pages/create_graph_by_edge_list/api/index.js.cache b/script/pages/create_graph_by_edge_list/api/index.js.cache index b3232f6..6a0de0e 100644 --- a/script/pages/create_graph_by_edge_list/api/index.js.cache +++ b/script/pages/create_graph_by_edge_list/api/index.js.cache @@ -1,4 +1,4 @@ -moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=103","/script/shared/point.js?v=103","/script/entities/edge/api/index.js?v=103","/script/entities/edge/model/BaseEdge.js?v=103","/script/entities/edge/model/EdgeModel.js?v=103","/script/entities/vertex/api/index.js?v=103","/script/entities/vertex/model/BaseVertex.js?v=103","/script/entities/vertex/model/VertexModel.js?v=103","/script/entities/graph/model/Graph.js?v=103",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} +moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=104","/script/shared/point.js?v=104","/script/entities/edge/api/index.js?v=104","/script/entities/edge/model/BaseEdge.js?v=104","/script/entities/edge/model/EdgeModel.js?v=104","/script/entities/vertex/api/index.js?v=104","/script/entities/vertex/model/BaseVertex.js?v=104","/script/entities/vertex/model/VertexModel.js?v=104","/script/entities/graph/model/Graph.js?v=104",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} {let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point) {return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point) {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function() @@ -309,16 +309,26 @@ Graph.prototype.FindAllEdges=function(id1,id2) {var edge=this.edges[i];if((edge.vertex1.id==id1&&edge.vertex2.id==id2)||(!edge.isDirect&&edge.vertex1.id==id2&&edge.vertex2.id==id1)) {res.push(edge);}} return res;} -Graph.prototype.GetAdjacencyMatrixStr=function() -{var matrix="";for(var i=0;i{var res="";var edge=this.FindEdgeMin(vertex_1.id,vertex_2.id);if(edge!=null) +{res+=edge.weight;} else -{matrix+="0";} -if(j!=this.vertices.length) +{res+="0";} +return res;} +for(var j=0;jweight_len&&weight_len==1) +{weight_len=2;} +if(weight_len>cols_width[j]) +{cols_width[j]=weight_len;}}} +for(var i=0;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[edge_index].isDirect) +{return-this.edges[edge_index].weight.toString();} else -{matrix+="0";} -if(j!=this.edges.length-1) +{return"0";}};for(var j=0;j{var res="";var edge=this.FindEdgeMin(vertex_1.id,vertex_2.id);if(edge!=null) +{res+=edge.weight;} else -{matrix+="0";} -if(j!=this.vertices.length) +{res+="0";} +return res;} +for(var j=0;jweight_len&&weight_len==1) +{weight_len=2;} +if(weight_len>cols_width[j]) +{cols_width[j]=weight_len;}}} +for(var i=0;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[edge_index].isDirect) +{return-this.edges[edge_index].weight.toString();} else -{matrix+="0";} -if(j!=this.edges.length-1) +{return"0";}};for(var j=0;j{var res="";var edge=this.FindEdgeMin(vertex_1.id,vertex_2.id);if(edge!=null) +{res+=edge.weight;} else -{matrix+="0";} -if(j!=this.vertices.length) +{res+="0";} +return res;} +for(var j=0;jweight_len&&weight_len==1) +{weight_len=2;} +if(weight_len>cols_width[j]) +{cols_width[j]=weight_len;}}} +for(var i=0;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[edge_index].isDirect) +{return-this.edges[edge_index].weight.toString();} else -{matrix+="0";} -if(j!=this.edges.length-1) +{return"0";}};for(var j=0;j{var res="";var edge=this.FindEdgeMin(vertex_1.id,vertex_2.id);if(edge!=null) +{res+=edge.weight;} else -{matrix+="0";} -if(j!=this.vertices.length) +{res+="0";} +return res;} +for(var j=0;jweight_len&&weight_len==1) +{weight_len=2;} +if(weight_len>cols_width[j]) +{cols_width[j]=weight_len;}}} +for(var i=0;i{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) +{return this.edges[edge_index].weight.toString();} +else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[edge_index].isDirect) +{return-this.edges[edge_index].weight.toString();} else -{matrix+="0";} -if(j!=this.edges.length-1) +{return"0";}};for(var j=0;j
-

-

- +

+

+
+
+ +
+
+
+ +
+
+
+ + +

@@ -412,8 +424,17 @@
-

- +

+ +
+ +
+
+
+ + +
+

@@ -422,8 +443,21 @@
-

- +

+ +
+
+ +
+
+
+ +
+
+
+ + +