Improved incidence matrix dialog. Add enumeration for edges.

This commit is contained in:
Oleg Sh
2026-10-03 14:41:23 +02:00
parent b53487dda0
commit c9ff7ab3f9
24 changed files with 333 additions and 54 deletions
+1 -1
View File
@@ -94,5 +94,5 @@
$g_config['vote'] = "./tmp/vote/vote.txt"; $g_config['vote'] = "./tmp/vote/vote.txt";
$g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_"; $g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_";
$g_config['use_js_cache'] = true; $g_config['use_js_cache'] = true;
$g_config['engine_version'] = 109; $g_config['engine_version'] = 110;
?> ?>
+25
View File
@@ -554,6 +554,31 @@ label.switcherText {
padding: 6px; padding: 6px;
} }
.incidence-matrix-controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
margin-top: 8px;
}
.incidence-matrix-controls label {
margin: 0;
white-space: nowrap;
}
#incidenceEdgeEnumeration {
flex: 1 1 150px;
width: auto;
min-width: 150px;
}
#incidenceEdgeNamesList {
width: 100%;
min-width: 300px;
resize: vertical;
}
/* Left text */ /* Left text */
.side-text-wrap { .side-text-wrap {
width: 40px; width: 40px;
+3
View File
@@ -176,6 +176,9 @@
$g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\"> $g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\">
We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>"; We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$g_lang["text_above_edge"] = "Текст над ребро"; $g_lang["text_above_edge"] = "Текст над ребро";
$g_lang["edge_enumeration"] = "Номериране на ребрата";
$g_lang["no_enumeration"] = "Без номериране";
$g_lang["edit_edge_names"] = "Редактиране на текстовете";
$g_lang["select_groupe_mac"] = "Използвайте Cmd⌘ за да изберете няколко обекта."; $g_lang["select_groupe_mac"] = "Използвайте Cmd⌘ за да изберете няколко обекта.";
$g_lang["select_groupe_win"] = "Използвайте Ctrl за да изберете няколко обекта."; $g_lang["select_groupe_win"] = "Използвайте Ctrl за да изберете няколко обекта.";
+3
View File
@@ -178,6 +178,9 @@
$g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\"> $g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\">
我们添加了中文翻译 🇳🇱. 感谢 Xingyi Zhang</a>"; 我们添加了中文翻译 🇳🇱. 感谢 Xingyi Zhang</a>";
$g_lang["text_above_edge"] = "边上的文本"; $g_lang["text_above_edge"] = "边上的文本";
$g_lang["edge_enumeration"] = "边编号";
$g_lang["no_enumeration"] = "不编号";
$g_lang["edit_edge_names"] = "编辑边文本";
$g_lang["select_groupe_mac"] = "使用 Cmd⌘ 选择数个对象."; $g_lang["select_groupe_mac"] = "使用 Cmd⌘ 选择数个对象.";
$g_lang["select_groupe_win"] = "使用 Ctrl 选择数个对象."; $g_lang["select_groupe_win"] = "使用 Ctrl 选择数个对象.";
+3
View File
@@ -177,6 +177,9 @@
$g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\"> $g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\">
Přidali jsme překlad do češtiny 🇨🇿. Děkujeme Jakubovi Mazuchovi!</a>"; Přidali jsme překlad do češtiny 🇨🇿. Děkujeme Jakubovi Mazuchovi!</a>";
$g_lang["text_above_edge"] = "Text nad hranou"; $g_lang["text_above_edge"] = "Text nad hranou";
$g_lang["edge_enumeration"] = "Číslování hran";
$g_lang["no_enumeration"] = "Bez číslování";
$g_lang["edit_edge_names"] = "Upravit texty hran";
$g_lang["select_groupe_mac"] = "Pro označení více objektů použijte klávesy Cmd⌘."; $g_lang["select_groupe_mac"] = "Pro označení více objektů použijte klávesy Cmd⌘.";
$g_lang["select_groupe_win"] = "Pro označení více objektů použijte klávesy Ctrl."; $g_lang["select_groupe_win"] = "Pro označení více objektů použijte klávesy Ctrl.";
+3
View File
@@ -143,6 +143,9 @@
$g_lang["replace_edge"] = "aktulle ersetzen"; $g_lang["replace_edge"] = "aktulle ersetzen";
$g_lang["add_edge"] = "Einfügen (Multigraph)"; $g_lang["add_edge"] = "Einfügen (Multigraph)";
$g_lang["text_above_edge"] = "Text an der Kante"; $g_lang["text_above_edge"] = "Text an der Kante";
$g_lang["edge_enumeration"] = "Kantennummerierung";
$g_lang["no_enumeration"] = "Keine Nummerierung";
$g_lang["edit_edge_names"] = "Kantentexte bearbeiten";
$g_lang["select_groupe_mac"] = "Nutzen Sie Cmd⌘ um mehrere Objekten zu wählen."; $g_lang["select_groupe_mac"] = "Nutzen Sie Cmd⌘ um mehrere Objekten zu wählen.";
$g_lang["select_groupe_win"] = "Nutzen Sie Strg um mehrere Objekten zu wählen."; $g_lang["select_groupe_win"] = "Nutzen Sie Strg um mehrere Objekten zu wählen.";
$g_lang["drag_select_group"] = "Gruppe ziehen"; $g_lang["drag_select_group"] = "Gruppe ziehen";
+3
View File
@@ -179,6 +179,9 @@
$g_lang["french_add"] = "Προσθέσαμε γαλλική μετάφραση 🇫🇷"; $g_lang["french_add"] = "Προσθέσαμε γαλλική μετάφραση 🇫🇷";
$g_lang["greece_add"] = "Προσθέσαμε ελληνική μετάφραση GR"; $g_lang["greece_add"] = "Προσθέσαμε ελληνική μετάφραση GR";
$g_lang["text_above_edge"] = "Κείμενο πάνω από την άκρη"; $g_lang["text_above_edge"] = "Κείμενο πάνω από την άκρη";
$g_lang["edge_enumeration"] = "Αρίθμηση ακμών";
$g_lang["no_enumeration"] = "Χωρίς αρίθμηση";
$g_lang["edit_edge_names"] = "Επεξεργασία κειμένων ακμών";
$g_lang["select_groupe_mac"] = "Χρησιμοποιήστε Cmd⌘ για να επιλέξετε πολλαπλά αντικείμενα."; $g_lang["select_groupe_mac"] = "Χρησιμοποιήστε Cmd⌘ για να επιλέξετε πολλαπλά αντικείμενα.";
$g_lang["select_groupe_win"] = "Χρησιμοποιήστε Ctrl για να επιλέξετε πολλαπλά αντικείμενα."; $g_lang["select_groupe_win"] = "Χρησιμοποιήστε Ctrl για να επιλέξετε πολλαπλά αντικείμενα.";
+3
View File
@@ -178,6 +178,9 @@
$g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\"> $g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\">
We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>"; We have added Dutch translation 🇳🇱. Thank you Willie de Wit</a>";
$g_lang["text_above_edge"] = "Text above edge"; $g_lang["text_above_edge"] = "Text above edge";
$g_lang["edge_enumeration"] = "Edge enumeration";
$g_lang["no_enumeration"] = "No enumeration";
$g_lang["edit_edge_names"] = "Edit edge text";
$g_lang["select_groupe_mac"] = "Use Cmd⌘ to select several objects."; $g_lang["select_groupe_mac"] = "Use Cmd⌘ to select several objects.";
$g_lang["select_groupe_win"] = "Use Ctrl to select several objects."; $g_lang["select_groupe_win"] = "Use Ctrl to select several objects.";
+3
View File
@@ -178,6 +178,9 @@
$g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/el/\" target=\"_blank\"> $g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/el/\" target=\"_blank\">
Tenemos traducciones en griego 🇬🇷.</a> <a href=\"https://github.com/UnickSoft/graphonline/pull/4\" target=\"_blank\">Gracias KyriakosG78</a>"; Tenemos traducciones en griego 🇬🇷.</a> <a href=\"https://github.com/UnickSoft/graphonline/pull/4\" target=\"_blank\">Gracias KyriakosG78</a>";
$g_lang["text_above_edge"] = "Textos sobre arista"; $g_lang["text_above_edge"] = "Textos sobre arista";
$g_lang["edge_enumeration"] = "Numeración de aristas";
$g_lang["no_enumeration"] = "Sin numeración";
$g_lang["edit_edge_names"] = "Editar textos de aristas";
$g_lang["select_groupe_mac"] = "Usa Cmd⌘ para seleccionar varios objetos."; $g_lang["select_groupe_mac"] = "Usa Cmd⌘ para seleccionar varios objetos.";
$g_lang["select_groupe_win"] = "Usa Ctrl para seleccionar varios objetos."; $g_lang["select_groupe_win"] = "Usa Ctrl para seleccionar varios objetos.";
+3
View File
@@ -145,6 +145,9 @@
$g_lang["replace_edge"] = "remplacer l'actuel"; $g_lang["replace_edge"] = "remplacer l'actuel";
$g_lang["add_edge"] = "ajout (multigraphe)"; $g_lang["add_edge"] = "ajout (multigraphe)";
$g_lang["text_above_edge"] = "Texte au-dessus du bord"; $g_lang["text_above_edge"] = "Texte au-dessus du bord";
$g_lang["edge_enumeration"] = "Numérotation des arêtes";
$g_lang["no_enumeration"] = "Sans numérotation";
$g_lang["edit_edge_names"] = "Modifier les textes des arêtes";
$g_lang["select_groupe_mac"] = "Utiliser Cmd⌘ pour sélectionner plusieurs objets."; $g_lang["select_groupe_mac"] = "Utiliser Cmd⌘ pour sélectionner plusieurs objets.";
$g_lang["select_groupe_win"] = "Utiliser Ctrl pour sélectionner plusieurs objets."; $g_lang["select_groupe_win"] = "Utiliser Ctrl pour sélectionner plusieurs objets.";
+3
View File
@@ -143,6 +143,9 @@
$g_lang["replace_edge"] = "vervang huidige"; $g_lang["replace_edge"] = "vervang huidige";
$g_lang["add_edge"] = "Toevoegen (multigraaf)"; $g_lang["add_edge"] = "Toevoegen (multigraaf)";
$g_lang["text_above_edge"] = "Tekst boven de lijn"; $g_lang["text_above_edge"] = "Tekst boven de lijn";
$g_lang["edge_enumeration"] = "Lijnnummering";
$g_lang["no_enumeration"] = "Geen nummering";
$g_lang["edit_edge_names"] = "Lijnteksten bewerken";
$g_lang["select_groupe_mac"] = "Gebruik Cmd⌘ om meerdere objecten te selecteren."; $g_lang["select_groupe_mac"] = "Gebruik Cmd⌘ om meerdere objecten te selecteren.";
$g_lang["select_groupe_win"] = "Gebruik Ctrl om meerdere objecten te selecteren."; $g_lang["select_groupe_win"] = "Gebruik Ctrl om meerdere objecten te selecteren.";
$g_lang["drag_select_group"] = "Sleep groep"; $g_lang["drag_select_group"] = "Sleep groep";
+3
View File
@@ -178,6 +178,9 @@
$g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\"> $g_lang["greek_add"] = "<a class=\"ProgresssBarLink\" href=\"/nl/\" target=\"_blank\">
Dodaliśmy polskie tłumaczenie, Patryk</a>"; Dodaliśmy polskie tłumaczenie, Patryk</a>";
$g_lang["text_above_edge"] = "Tekst nad krawędzią"; $g_lang["text_above_edge"] = "Tekst nad krawędzią";
$g_lang["edge_enumeration"] = "Numerowanie krawędzi";
$g_lang["no_enumeration"] = "Bez numerowania";
$g_lang["edit_edge_names"] = "Edytuj teksty krawędzi";
$g_lang["select_groupe_mac"] = "Użyj Cmd⌘ by wybrać dane obiekty."; $g_lang["select_groupe_mac"] = "Użyj Cmd⌘ by wybrać dane obiekty.";
$g_lang["select_groupe_win"] = "Użyj Ctrl by wybrać dane obiekty."; $g_lang["select_groupe_win"] = "Użyj Ctrl by wybrać dane obiekty.";
+3
View File
@@ -142,6 +142,9 @@
$g_lang["graph_is_general_message"] = ""; $g_lang["graph_is_general_message"] = "";
$g_lang["text_above_edge"] = "Text above edge"; $g_lang["text_above_edge"] = "Text above edge";
$g_lang["edge_enumeration"] = "Numeração das arestas";
$g_lang["no_enumeration"] = "Sem numeração";
$g_lang["edit_edge_names"] = "Editar textos das arestas";
$g_lang["select_groupe_mac"] = "Use Cmd⌘ to select several objects."; $g_lang["select_groupe_mac"] = "Use Cmd⌘ to select several objects.";
$g_lang["select_groupe_win"] = "Use Ctrl to select several objects."; $g_lang["select_groupe_win"] = "Use Ctrl to select several objects.";
+3
View File
@@ -181,6 +181,9 @@
$g_lang["graph_is_multi_message"] = "Мультиграф не поддерживает все алгоритмы"; $g_lang["graph_is_multi_message"] = "Мультиграф не поддерживает все алгоритмы";
$g_lang["graph_is_general_message"] = ""; $g_lang["graph_is_general_message"] = "";
$g_lang["text_above_edge"] = "Текст над дугой"; $g_lang["text_above_edge"] = "Текст над дугой";
$g_lang["edge_enumeration"] = "Нумерация дуг";
$g_lang["no_enumeration"] = "Без нумерации";
$g_lang["edit_edge_names"] = "Редактировать подписи дуг";
$g_lang["select_groupe_mac"] = "Выделите несколько объектов используя Cmd⌘."; $g_lang["select_groupe_mac"] = "Выделите несколько объектов используя Cmd⌘.";
$g_lang["select_groupe_win"] = "Выделите несколько объектов используя Ctrl."; $g_lang["select_groupe_win"] = "Выделите несколько объектов используя Ctrl.";
+3
View File
@@ -77,6 +77,9 @@
$g_lang["zoom_out"] = "Zooma ut"; $g_lang["zoom_out"] = "Zooma ut";
$g_lang["move_workspace"] = "Flytta arbetsytan"; $g_lang["move_workspace"] = "Flytta arbetsytan";
$g_lang["custom"] = "Anpassad text"; $g_lang["custom"] = "Anpassad text";
$g_lang["edge_enumeration"] = "Kantnumrering";
$g_lang["no_enumeration"] = "Ingen numrering";
$g_lang["edit_edge_names"] = "Redigera kanttexter";
$g_lang["enter_vertex_title"] = "Ange text"; $g_lang["enter_vertex_title"] = "Ange text";
$g_lang["rename_vertex"] = "Byt namn på nod"; $g_lang["rename_vertex"] = "Byt namn på nod";
$g_lang["rename_text"] = "Byt namn "; $g_lang["rename_text"] = "Byt namn ";
+3
View File
@@ -179,6 +179,9 @@
$g_lang["graph_is_multi_message"] = "Мультиграф не підтримує всі алгоритми"; $g_lang["graph_is_multi_message"] = "Мультиграф не підтримує всі алгоритми";
$g_lang["graph_is_general_message"] = ""; $g_lang["graph_is_general_message"] = "";
$g_lang["text_above_edge"] = "Текст над дугою"; $g_lang["text_above_edge"] = "Текст над дугою";
$g_lang["edge_enumeration"] = "Нумерація дуг";
$g_lang["no_enumeration"] = "Без нумерації";
$g_lang["edit_edge_names"] = "Редагувати підписи дуг";
$g_lang["select_groupe_mac"] = "Виділіть декілька обʼєктів використовуючи Cmd⌘."; $g_lang["select_groupe_mac"] = "Виділіть декілька обʼєктів використовуючи Cmd⌘.";
$g_lang["select_groupe_win"] = "Виділіть декілька обʼєктів використовуючи Ctrl."; $g_lang["select_groupe_win"] = "Виділіть декілька обʼєктів використовуючи Ctrl.";
+13 -6
View File
@@ -869,7 +869,7 @@ Graph.prototype.TestIncidenceMatrix = function (matrix, rowsObj, colsObj, separa
if (bGoodFormat) if (bGoodFormat)
{ {
for (var i = 0; i < colsObj.cols[0].length; i++) for (var i = 0; i < columnCount; i++)
{ {
var values = []; var values = [];
for (j = 0; j < colsObj.cols.length; ++j) for (j = 0; j < colsObj.cols.length; ++j)
@@ -908,7 +908,8 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
} }
var newVertices = []; var newVertices = [];
var bWeightGraph = false; var bWeightGraph = false;
for (var i = 0; i < cols[0].length; i++) var columnCount = cols.length > 0 ? cols[0].length : 0;
for (var i = 0; i < columnCount; i++)
{ {
var edgeValue = []; var edgeValue = [];
var edgeIndex = []; var edgeIndex = [];
@@ -965,17 +966,18 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
}); });
} }
for (var i = cols.length; i < Math.max(this.vertices.length, cols.length); i++) var rowCount = rows.length > 0 ? rows.length : this.vertices.length;
for (var i = rowCount; i < this.vertices.length; i++)
{ {
this.DeleteVertex(this.vertices[i]); this.DeleteVertex(this.vertices[i]);
i--; i--;
} }
this.VerticesReposition(viewportSize, newVertices); this.VerticesReposition(viewportSize, newVertices);
} }
} }
Graph.prototype.GetIncidenceMatrix = function () Graph.prototype.GetIncidenceMatrix = function (res_columns_width)
{ {
var matrix = ""; var matrix = "";
let cols_width = []; let cols_width = [];
@@ -1001,7 +1003,7 @@ Graph.prototype.GetIncidenceMatrix = function ()
for (var j = 0; j < this.edges.length; j++) for (var j = 0; j < this.edges.length; j++)
{ {
let max_width = 0; let max_width = Math.min(this.edges[j].GetUpText().toString().length, 2);
for (var i = 0; i < this.vertices.length; i++) for (var i = 0; i < this.vertices.length; i++)
{ {
let str = "" + get_edge_weight_str(i, j); let str = "" + get_edge_weight_str(i, j);
@@ -1026,6 +1028,11 @@ Graph.prototype.GetIncidenceMatrix = function ()
matrix = matrix + "\n"; matrix = matrix + "\n";
} }
if (res_columns_width !== undefined) {
res_columns_width.length = 0;
res_columns_width.push(...cols_width);
}
return matrix; return matrix;
} }
+173 -16
View File
@@ -23,23 +23,45 @@ ShowIncidenceMatrix.prototype.show = function()
{ {
var handler = this; var handler = this;
var dialogButtons = {}; var dialogButtons = {};
let edgeNames = this.app.graph.edges.map(function(edge) { return edge.GetUpText(); });
$('#IncidenceMatrixField').unbind(); let edgeEnumSelect = $("#incidenceEdgeEnumeration");
$( "#IncidenceMatrixField" ).on('keyup change', function (eventObject) let edgeNamesDialog = $("#incidenceEdgeNamesDialog");
let edgeNamesList = $("#incidenceEdgeNamesList");
let currentColumns = [];
let currentColumnWidths = [];
let matrixIsValid = false;
let edgeEnumValue = this.app.currentEnumEdgesType || "";
if (edgeEnumValue === "Custom")
{
edgeEnumValue = "";
}
let selectedEdgeEnumValue = edgeEnumValue;
edgeEnumSelect.find("option:not(:first)").remove();
this.app.GetEnumVerticesList().forEach(function(item) {
if (item.value !== "Custom")
{ {
if (!handler.app.TestIncidenceMatrix($( "#IncidenceMatrixField" ).val(), [], [])) edgeEnumSelect.append($("<option>", { value: item.value, text: item.text }));
{ }
$( "#BadIncidenceMatrixFormatMessage" ).show(); });
} edgeEnumSelect.val(edgeEnumValue);
else $("#IncidenceMatrixField").off("keyup change input");
{
$( "#BadIncidenceMatrixFormatMessage" ).hide();
}
});
dialogButtons[g_save] = function() { dialogButtons[g_save] = function() {
handler.app.PushToStack("IncidenceMatrixChanged"); let matrix = ta.val();
handler.app.SetIncidenceMatrixSmart($( "#IncidenceMatrixField" ).val()); let rows = {};
let columns = {};
let validIncidenceMatrix = handler.app.TestIncidenceMatrix(matrix, rows, columns);
handler.app.PushToStack("IncidenceMatrixChanged");
handler.app.SetIncidenceMatrixSmart(matrix);
if (validIncidenceMatrix)
{
handler.app.SetEnumEdgesType(selectedEdgeEnumValue);
handler.app.graph.edges.forEach(function(edge, edgeIndex) {
edge.SetUpText(edgeNames[edgeIndex] || "");
});
handler.app.redrawGraph();
}
$( this ).dialog( "close" ); $( this ).dialog( "close" );
}; };
dialogButtons[g_cancel] = function() { dialogButtons[g_cancel] = function() {
@@ -47,13 +69,16 @@ ShowIncidenceMatrix.prototype.show = function()
}; };
let ta = $("#IncidenceMatrixField"); let ta = $("#IncidenceMatrixField");
let topWrap = $("#incidenceMatrix_top_text");
let sideWrap = $("#incidenceMatrix_side_text"); let sideWrap = $("#incidenceMatrix_side_text");
let incidenceMatrix = this.app.GetIncidenceMatrix();
ta.on("scroll", function() { ta.on("scroll", function() {
topWrap.scrollLeft(ta.scrollLeft());
sideWrap.scrollTop(ta.scrollTop()); sideWrap.scrollTop(ta.scrollTop());
}); });
$( "#IncidenceMatrixField" ).val(this.app.GetIncidenceMatrix().trimEnd()); $( "#IncidenceMatrixField" ).val(incidenceMatrix.trimEnd());
ta.focus()[0].setSelectionRange(0, 0); ta.focus()[0].setSelectionRange(0, 0);
$( "#BadIncidenceMatrixFormatMessage" ).hide(); $( "#BadIncidenceMatrixFormatMessage" ).hide();
@@ -67,6 +92,138 @@ ShowIncidenceMatrix.prototype.show = function()
} }
$("#incidenceMatrix_side_text_text").html(sideText + "\n"); $("#incidenceMatrix_side_text_text").html(sideText + "\n");
let topText = $("#incidenceMatrix_top_text_text");
let renderEdgeNames = function(columns) {
topText.empty();
let columnCount = columns.length > 0 ? columns[0].length : 0;
for (let edgeIndex = 0; edgeIndex < columnCount; edgeIndex++)
{
let edgeName = (edgeNames[edgeIndex] || "").slice(0, 2);
let columnWidth = Math.max(1, edgeName.length, currentColumnWidths[edgeIndex] || 0);
for (let rowIndex = 0; rowIndex < columns.length; rowIndex++)
{
columnWidth = Math.max(columnWidth, String(columns[rowIndex][edgeIndex]).trim().length);
}
topText.append(document.createTextNode(edgeName.slice(0, columnWidth).padStart(columnWidth, " ")));
if (edgeIndex < columnCount - 1)
{
topText.append(document.createTextNode(" "));
}
}
};
let getMatrixColumnWidths = function(matrix, columnCount) {
let widths = Array(columnCount).fill(1);
let rows = matrix.split(/\r?\n/).filter(function(row) { return row.trim().length > 0; });
rows.forEach(function(row) {
let cells = row.split(",");
if (cells.length !== columnCount)
{
return;
}
cells.forEach(function(cell, columnIndex) {
let cellWidth = cell.length;
if (columnIndex > 0 && cell.startsWith(" "))
{
cellWidth--;
}
widths[columnIndex] = Math.max(widths[columnIndex], cellWidth);
});
});
return widths;
};
let getEdgeEnumType = function(value) {
return handler.app.enumVerticesTextList.find(function(enumType) {
return enumType.GetValue() === value && value !== "Custom";
});
};
let applyEdgeEnumeration = function(value) {
if (!matrixIsValid)
{
return;
}
selectedEdgeEnumValue = value;
let enumType = getEdgeEnumType(value);
for (let edgeIndex = 0; edgeIndex < edgeNames.length; edgeIndex++)
{
edgeNames[edgeIndex] = enumType ? enumType.GetVertexText(edgeIndex).toString() : "";
}
renderEdgeNames(currentColumns);
};
edgeEnumSelect.off("change").on("change", function() {
applyEdgeEnumeration($(this).val());
});
$("#editIncidenceEdgeNames").off("click").on("click", function() {
if (!matrixIsValid)
{
return;
}
edgeNamesList.val(edgeNames.join("\n"));
edgeNamesDialog.dialog("open");
});
edgeNamesDialog.dialog({
autoOpen: false,
modal: true,
resizable: false,
width: "auto",
title: $("#EdgeLabel").text().trim(),
buttons: {
[g_save]: function() {
let editedNames = edgeNamesList.val().split(/\r?\n/);
edgeNames = Array.from({ length: edgeNames.length }, function(_, index) {
return editedNames[index] || "";
});
renderEdgeNames(currentColumns);
$(this).dialog("close");
},
[g_cancel]: function() {
$(this).dialog("close");
}
},
dialogClass: 'EdgeDialog'
});
let updateMatrixState = function() {
let rows = {};
let columns = {};
let isValid = handler.app.TestIncidenceMatrix(ta.val(), rows, columns);
if (isValid)
{
let columnCount = columns.cols.length > 0 ? columns.cols[0].length : 0;
currentColumns = columns.cols;
currentColumnWidths = getMatrixColumnWidths(ta.val(), columnCount);
let enumType = getEdgeEnumType(selectedEdgeEnumValue);
if (columnCount < edgeNames.length)
{
edgeNames.length = columnCount;
}
else
{
for (let edgeIndex = edgeNames.length; edgeIndex < columnCount; edgeIndex++)
{
edgeNames.push(enumType ? enumType.GetVertexText(edgeIndex).toString() : "");
}
}
matrixIsValid = true;
edgeEnumSelect.prop("disabled", false);
$("#editIncidenceEdgeNames").prop("disabled", false);
$("#BadIncidenceMatrixFormatMessage").hide();
renderEdgeNames(columns.cols);
}
else
{
matrixIsValid = false;
edgeEnumSelect.prop("disabled", true);
$("#editIncidenceEdgeNames").prop("disabled", true);
$("#BadIncidenceMatrixFormatMessage").show();
}
};
ta.on("input", updateMatrixState);
updateMatrixState();
$( "#incidenceMatrix" ).dialog({ $( "#incidenceMatrix" ).dialog({
resizable: false, resizable: false,
height: "auto", height: "auto",
@@ -77,7 +234,7 @@ ShowIncidenceMatrix.prototype.show = function()
dialogClass: 'EdgeDialog', dialogClass: 'EdgeDialog',
open: function(event, ui) { open: function(event, ui) {
/* Set width for side text */ /* Set width for side text */
$("#incidenceMatrix_top_text").width(ta.width()); topWrap.width(ta.width());
$("#BadIncidenceMatrixFormatMessage").width(ta.width()); $("#BadIncidenceMatrixFormatMessage").width(ta.width());
} }
}); });
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);} moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110",]);{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) {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.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() {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()
@@ -452,7 +452,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount) if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}} {bGoodFormat=false;break;}}
if(bGoodFormat) if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++) {for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j) {var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0) {if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}} {values.push(colsObj.cols[j][i]);}}
@@ -463,7 +463,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj)) {var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++) {rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);} {this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++) var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++) {var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length) {if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph) if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++) var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;} {this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}} this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function() Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {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();} {return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();} {return-this.edges[edge_index].weight.toString();}
else else
{return"0";}};for(var j=0;j<this.edges.length;j++) {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 max_width=Math.min(this.edges[j].GetUpText().toString().length,2);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);} {let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);} cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++) for(var i=0;i<this.vertices.length;i++)
@@ -499,6 +499,7 @@ for(var i=0;i<this.vertices.length;i++)
{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) {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=matrix+"\n";} matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;} return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator) Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined) {if(separator===undefined)
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);} moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110",]);{let modulDir="pages/create_graph_by_matrix/";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) {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.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() {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()
@@ -452,7 +452,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount) if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}} {bGoodFormat=false;break;}}
if(bGoodFormat) if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++) {for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j) {var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0) {if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}} {values.push(colsObj.cols[j][i]);}}
@@ -463,7 +463,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj)) {var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++) {rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);} {this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++) var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++) {var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length) {if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph) if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++) var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;} {this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}} this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function() Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {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();} {return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();} {return-this.edges[edge_index].weight.toString();}
else else
{return"0";}};for(var j=0;j<this.edges.length;j++) {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 max_width=Math.min(this.edges[j].GetUpText().toString().length,2);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);} {let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);} cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++) for(var i=0;i<this.vertices.length;i++)
@@ -499,6 +499,7 @@ for(var i=0;i<this.vertices.length;i++)
{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) {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=matrix+"\n";} matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;} return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator) Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined) {if(separator===undefined)
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=109","/script/pages/create_graph_by_matrix/model/main.js?v=109",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);} moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=110","/script/pages/create_graph_by_matrix/model/main.js?v=110",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);}
{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) {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.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() {return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()
@@ -452,7 +452,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount) if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}} {bGoodFormat=false;break;}}
if(bGoodFormat) if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++) {for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j) {var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0) {if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}} {values.push(colsObj.cols[j][i]);}}
@@ -463,7 +463,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj)) {var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++) {rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);} {this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++) var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++) {var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length) {if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -479,10 +479,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph) if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++) var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;} {this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}} this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function() Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {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();} {return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -491,7 +491,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();} {return-this.edges[edge_index].weight.toString();}
else else
{return"0";}};for(var j=0;j<this.edges.length;j++) {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 max_width=Math.min(this.edges[j].GetUpText().toString().length,2);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);} {let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);} cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++) for(var i=0;i<this.vertices.length;i++)
@@ -499,6 +499,7 @@ for(var i=0;i<this.vertices.length;i++)
{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) {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=matrix+"\n";} matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;} return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator) Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined) {if(separator===undefined)
+16 -10
View File
@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=109","/script/shared/gzip.js?v=109","/script/entities/graph/api/index.js?v=109","/script/shared/point.js?v=109","/script/entities/edge/api/index.js?v=109","/script/entities/edge/model/BaseEdge.js?v=109","/script/entities/edge/model/EdgeModel.js?v=109","/script/entities/vertex/api/index.js?v=109","/script/entities/vertex/model/BaseVertex.js?v=109","/script/entities/vertex/model/VertexModel.js?v=109","/script/entities/graph/model/Graph.js?v=109","/script/features/draw_graph/api/index.js?v=109","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=109","/script/features/draw_graph/model/BackgroundStyle.js?v=109","/script/features/draw_graph/model/EdgeStyle.js?v=109","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=109","/script/features/draw_graph/model/VertexShape.js?v=109","/script/features/draw_graph/model/VertexStyle.js?v=109","/script/features/draw_graph/model/VertexOldStyle.js?v=109","/script/features/draw_graph/model/VertexPrintStyle.js?v=109","/script/features/draw_graph/model/OldEdgeStyle.js?v=109","/script/features/draw_graph/model/PrintEdgeStyle.js?v=109","/script/features/draw_graph/model/VertexNewWhiteStyle.js?v=109","/script/features/draw_graph/model/EdgeNewWhiteStyle.js?v=109","/script/features/draw_graph/model/EdgeNewNightStyle.js?v=109","/script/features/draw_graph/model/VertexNewNightStyle.js?v=109","/script/features/draw_graph/model/EdgeContrastStyle.js?v=109","/script/features/draw_graph/model/VertexContrastStyle.js?v=109","/script/features/draw_graph/model/BaseVertexDrawer.js?v=109","/script/features/draw_graph/model/GraphFullStyle.js?v=109","/script/features/algorithms/api/index.js?v=109","/script/features/algorithms/model/Algorithms.js?v=109","/script/features/algorithms/model/BaseTraversal.js?v=109","/script/features/base_handler/index.js?v=109","/script/features/default_handler/index.js?v=109","/script/features/add_vertices_handler/index.js?v=109","/script/features/connect_vertices_handler/index.js?v=109","/script/features/delete_objects_handler/index.js?v=109","/script/features/algorithm_handler/index.js?v=109","/script/features/select_auto_save_graph_or_not/index.js?v=109","/script/features/graph_preview/index.js?v=109","/script/features/serialization/api/index.js?v=109","/script/features/serialization/model/GraphMLCreator.js?v=109","/script/features/enum_vertices/EnumVertices.js?v=109","/script/pages/editor/model/texts.js?v=109","/script/pages/editor/model/UndoStack.js?v=109","/script/pages/editor/model/DiskSaveLoad.js?v=109","/script/pages/editor/model/Application.js?v=109","/script/pages/editor/ui/ya_metrika.js?v=109","/script/pages/editor/ui/editor.js?v=109","/script/pages/editor/ui/main.js?v=109",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.min.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();} moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=110","/script/shared/gzip.js?v=110","/script/entities/graph/api/index.js?v=110","/script/shared/point.js?v=110","/script/entities/edge/api/index.js?v=110","/script/entities/edge/model/BaseEdge.js?v=110","/script/entities/edge/model/EdgeModel.js?v=110","/script/entities/vertex/api/index.js?v=110","/script/entities/vertex/model/BaseVertex.js?v=110","/script/entities/vertex/model/VertexModel.js?v=110","/script/entities/graph/model/Graph.js?v=110","/script/features/draw_graph/api/index.js?v=110","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=110","/script/features/draw_graph/model/BackgroundStyle.js?v=110","/script/features/draw_graph/model/EdgeStyle.js?v=110","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=110","/script/features/draw_graph/model/VertexShape.js?v=110","/script/features/draw_graph/model/VertexStyle.js?v=110","/script/features/draw_graph/model/VertexOldStyle.js?v=110","/script/features/draw_graph/model/VertexPrintStyle.js?v=110","/script/features/draw_graph/model/OldEdgeStyle.js?v=110","/script/features/draw_graph/model/PrintEdgeStyle.js?v=110","/script/features/draw_graph/model/VertexNewWhiteStyle.js?v=110","/script/features/draw_graph/model/EdgeNewWhiteStyle.js?v=110","/script/features/draw_graph/model/EdgeNewNightStyle.js?v=110","/script/features/draw_graph/model/VertexNewNightStyle.js?v=110","/script/features/draw_graph/model/EdgeContrastStyle.js?v=110","/script/features/draw_graph/model/VertexContrastStyle.js?v=110","/script/features/draw_graph/model/BaseVertexDrawer.js?v=110","/script/features/draw_graph/model/GraphFullStyle.js?v=110","/script/features/algorithms/api/index.js?v=110","/script/features/algorithms/model/Algorithms.js?v=110","/script/features/algorithms/model/BaseTraversal.js?v=110","/script/features/base_handler/index.js?v=110","/script/features/default_handler/index.js?v=110","/script/features/add_vertices_handler/index.js?v=110","/script/features/connect_vertices_handler/index.js?v=110","/script/features/delete_objects_handler/index.js?v=110","/script/features/algorithm_handler/index.js?v=110","/script/features/select_auto_save_graph_or_not/index.js?v=110","/script/features/graph_preview/index.js?v=110","/script/features/serialization/api/index.js?v=110","/script/features/serialization/model/GraphMLCreator.js?v=110","/script/features/enum_vertices/EnumVertices.js?v=110","/script/pages/editor/model/texts.js?v=110","/script/pages/editor/model/UndoStack.js?v=110","/script/pages/editor/model/DiskSaveLoad.js?v=110","/script/pages/editor/model/Application.js?v=110","/script/pages/editor/ui/ya_metrika.js?v=110","/script/pages/editor/ui/editor.js?v=110","/script/pages/editor/ui/main.js?v=110",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.min.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();}
let modulDir="pages/editor/";doInclude([include("shared/utils.js"),include("shared/gzip.js"),include("entities/graph/api/index.js"),include("features/draw_graph/api/index.js"),include("features/algorithms/api/index.js"),include("features/base_handler/index.js"),include("features/default_handler/index.js"),include("features/add_vertices_handler/index.js"),include("features/connect_vertices_handler/index.js"),include("features/delete_objects_handler/index.js"),include("features/algorithm_handler/index.js"),include("features/select_auto_save_graph_or_not/index.js"),include("features/serialization/api/index.js"),include("features/enum_vertices/EnumVertices.js"),include("model/texts.js",modulDir),include("model/UndoStack.js",modulDir),include("model/DiskSaveLoad.js",modulDir),include("model/Application.js",modulDir),include("ui/ya_metrika.js",modulDir),include("ui/editor.js",modulDir),include("ui/main.js",modulDir)],onloadEditor);} let modulDir="pages/editor/";doInclude([include("shared/utils.js"),include("shared/gzip.js"),include("entities/graph/api/index.js"),include("features/draw_graph/api/index.js"),include("features/algorithms/api/index.js"),include("features/base_handler/index.js"),include("features/default_handler/index.js"),include("features/add_vertices_handler/index.js"),include("features/connect_vertices_handler/index.js"),include("features/delete_objects_handler/index.js"),include("features/algorithm_handler/index.js"),include("features/select_auto_save_graph_or_not/index.js"),include("features/serialization/api/index.js"),include("features/enum_vertices/EnumVertices.js"),include("model/texts.js",modulDir),include("model/UndoStack.js",modulDir),include("model/DiskSaveLoad.js",modulDir),include("model/Application.js",modulDir),include("ui/ya_metrika.js",modulDir),include("ui/editor.js",modulDir),include("ui/main.js",modulDir)],onloadEditor);}
function gEncodeToHTML(str) function gEncodeToHTML(str)
{if(typeof str!=='string') {if(typeof str!=='string')
@@ -487,7 +487,7 @@ if(i==0)
if(colsObj.cols[i].length!=columnCount) if(colsObj.cols[i].length!=columnCount)
{bGoodFormat=false;break;}} {bGoodFormat=false;break;}}
if(bGoodFormat) if(bGoodFormat)
{for(var i=0;i<colsObj.cols[0].length;i++) {for(var i=0;i<columnCount;i++)
{var values=[];for(j=0;j<colsObj.cols.length;++j) {var values=[];for(j=0;j<colsObj.cols.length;++j)
{if(colsObj.cols[j][i]!=0) {if(colsObj.cols[j][i]!=0)
{values.push(colsObj.cols[j][i]);}} {values.push(colsObj.cols[j][i]);}}
@@ -498,7 +498,7 @@ Graph.prototype.SetIncidenceMatrix=function(matrix,viewportSize,currentEnumVerti
{var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj)) {var rowsObj={};var colsObj={};if(this.TestIncidenceMatrix(matrix,rowsObj,colsObj))
{rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++) {rows=rowsObj.rows;cols=colsObj.cols;var clonedEdge=this.edges.slice(0);for(var i=0;i<clonedEdge.length;i++)
{this.DeleteEdge(clonedEdge[i]);} {this.DeleteEdge(clonedEdge[i]);}
var newVertices=[];var bWeightGraph=false;for(var i=0;i<cols[0].length;i++) var newVertices=[];var bWeightGraph=false;var columnCount=cols.length>0?cols[0].length:0;for(var i=0;i<columnCount;i++)
{var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++) {var edgeValue=[];var edgeIndex=[];for(var j=0;j<cols.length;j++)
{if(j>=this.vertices.length) {if(j>=this.vertices.length)
{var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);} {var newPos=new Point(0,0);newVertices.push(new BaseVertex(newPos.x,newPos.y,currentEnumVerticesType));this.AddNewVertex(newVertices[newVertices.length-1]);}
@@ -514,10 +514,10 @@ var nEdgeIndex=this.AddNewEdgeSafe(this.vertices[edgeIndex[0]],this.vertices[edg
{bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}} {bWeightGraph=bWeightGraph||this.edges[nEdgeIndex].weight!=1;}}}
if(!bWeightGraph) if(!bWeightGraph)
{this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});} {this.edges.forEach(function(part,index,theArray){theArray[index].useWeight=false;});}
for(var i=cols.length;i<Math.max(this.vertices.length,cols.length);i++) var rowCount=rows.length>0?rows.length:this.vertices.length;for(var i=rowCount;i<this.vertices.length;i++)
{this.DeleteVertex(this.vertices[i]);i--;} {this.DeleteVertex(this.vertices[i]);i--;}
this.VerticesReposition(viewportSize,newVertices);}} this.VerticesReposition(viewportSize,newVertices);}}
Graph.prototype.GetIncidenceMatrix=function() Graph.prototype.GetIncidenceMatrix=function(res_columns_width)
{var matrix="";let cols_width=[];let get_edge_weight_str=(vertex_index,edge_index)=>{if(this.edges[edge_index].vertex1==this.vertices[vertex_index]) {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();} {return this.edges[edge_index].weight.toString();}
else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect) else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&!this.edges[edge_index].isDirect)
@@ -526,7 +526,7 @@ else if(this.edges[edge_index].vertex2==this.vertices[vertex_index]&&this.edges[
{return-this.edges[edge_index].weight.toString();} {return-this.edges[edge_index].weight.toString();}
else else
{return"0";}};for(var j=0;j<this.edges.length;j++) {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 max_width=Math.min(this.edges[j].GetUpText().toString().length,2);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);} {let str=""+get_edge_weight_str(i,j);max_width=Math.max(max_width,str.length);}
cols_width.push(max_width);} cols_width.push(max_width);}
for(var i=0;i<this.vertices.length;i++) for(var i=0;i<this.vertices.length;i++)
@@ -534,6 +534,7 @@ for(var i=0;i<this.vertices.length;i++)
{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) {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=matrix+"\n";} matrix=matrix+"\n";}
if(res_columns_width!==undefined){res_columns_width.length=0;res_columns_width.push(...cols_width);}
return matrix;} return matrix;}
Graph.prototype.SplitMatrixString=function(line,separator) Graph.prototype.SplitMatrixString=function(line,separator)
{if(separator===undefined) {if(separator===undefined)
@@ -1638,7 +1639,7 @@ DiskSaveLoad.LoadAutoSaveGraphFromDisk=function(graphName,callback)
DiskSaveLoad.RemoveAutoSaveGraphFromDisk=function(graphName,callback) DiskSaveLoad.RemoveAutoSaveGraphFromDisk=function(graphName,callback)
{$.ajax({type:"GET",url:"/"+SiteDir+"backend/removeGraph.php?name=autosave_"+graphName}).done(callback);} {$.ajax({type:"GET",url:"/"+SiteDir+"backend/removeGraph.php?name=autosave_"+graphName}).done(callback);}
var globalApplication=null;function Application(document,window,listener) var globalApplication=null;function Application(document,window,listener)
{this.document=document;this.listener=listener;this.initCanvas();this.handler=new DefaultHandler(this);this.savedGraphName="";this.currentEnumVerticesType=new BaseEnumVertices(this,1);this.findPathReport=1;this.isTimerRender=false;globalApplication=this;this.renderPath=[];this.renderTimer=0;this.renderPathLength=0;this.renderPathCounter=0;this.renderPathLoops=0;this.enumVerticesTextList=[new BaseEnumVertices(this,1),new BaseEnumVertices(this,0),new TextEnumVertices(this),new TextEnumVerticesCyr(this),new TextEnumVerticesGreek(this),new TextEnumVerticesCustom(this)];this.algorithmsValues={};this.undoStack=new UndoStack(this.maxUndoStackSize);this.style=new GraphFullStyle(function() {this.document=document;this.listener=listener;this.initCanvas();this.handler=new DefaultHandler(this);this.savedGraphName="";this.currentEnumVerticesType=new BaseEnumVertices(this,1);this.currentEnumEdgesType="";this.findPathReport=1;this.isTimerRender=false;globalApplication=this;this.renderPath=[];this.renderTimer=0;this.renderPathLength=0;this.renderPathCounter=0;this.renderPathLoops=0;this.enumVerticesTextList=[new BaseEnumVertices(this,1),new BaseEnumVertices(this,0),new TextEnumVertices(this),new TextEnumVerticesCyr(this),new TextEnumVerticesGreek(this),new TextEnumVerticesCustom(this)];this.algorithmsValues={};this.undoStack=new UndoStack(this.maxUndoStackSize);this.style=new GraphFullStyle(function()
{this.redrawGraph();}.bind(this));this.edgePrintCommonStyle=DefaultCommonPrintEdgeStyle();this.edgePrintSelectedStyles=FullArrayCopy(DefaultPrintSelectedEdgeStyles);this.vertexPrintCommonStyle=DefaultCommonPrintVertexStyle();this.vertexPrintSelectedVertexStyles=FullArrayCopy(DefaultPrintSelectedGraphStyles);this.backgroundPrintStyle=DefaultPrintBackgroundStyle();this.renderPathWithEdges=false;this.edgePresets=[1,3,5,7,11,42];this.maxEdgePresets=6;this.selectionRect=null;this.processEmscriptenFunction=null;this.defaultEdge=null;this.useDefaultEdge=false;this.lastSavedAutoSave="";this.lastGraphName="";this.lastUsedGraphs=[];};Application.prototype.graph=new Graph();Application.prototype.dragObject=-1;Application.prototype.handler=null;Application.prototype.status={};Application.prototype.graphNameLength=16;Application.prototype.maxUndoStackSize=8;Application.prototype.maxAutosaveSizeForCookie=2000;Application.prototype.autosaveTimeInterval=1000*60;Application.prototype.styliedGraphNamePostfix="ZZcst";Application.prototype.maxLastUsedGraphCount=5;Application.prototype.initCanvas=function() {this.redrawGraph();}.bind(this));this.edgePrintCommonStyle=DefaultCommonPrintEdgeStyle();this.edgePrintSelectedStyles=FullArrayCopy(DefaultPrintSelectedEdgeStyles);this.vertexPrintCommonStyle=DefaultCommonPrintVertexStyle();this.vertexPrintSelectedVertexStyles=FullArrayCopy(DefaultPrintSelectedGraphStyles);this.backgroundPrintStyle=DefaultPrintBackgroundStyle();this.renderPathWithEdges=false;this.edgePresets=[1,3,5,7,11,42];this.maxEdgePresets=6;this.selectionRect=null;this.processEmscriptenFunction=null;this.defaultEdge=null;this.useDefaultEdge=false;this.lastSavedAutoSave="";this.lastGraphName="";this.lastUsedGraphs=[];};Application.prototype.graph=new Graph();Application.prototype.dragObject=-1;Application.prototype.handler=null;Application.prototype.status={};Application.prototype.graphNameLength=16;Application.prototype.maxUndoStackSize=8;Application.prototype.maxAutosaveSizeForCookie=2000;Application.prototype.autosaveTimeInterval=1000*60;Application.prototype.styliedGraphNamePostfix="ZZcst";Application.prototype.maxLastUsedGraphCount=5;Application.prototype.initCanvas=function()
{this.canvas=this.document.getElementById('canvas');console.log(this.canvas.width,this.canvas.height);console.log(this.canvas.getBoundingClientRect());console.log(window.devicePixelRatio);this.SetDefaultTransformations();} {this.canvas=this.document.getElementById('canvas');console.log(this.canvas.width,this.canvas.height);console.log(this.canvas.getBoundingClientRect());console.log(window.devicePixelRatio);this.SetDefaultTransformations();}
Application.prototype.getMousePos=function(canvas,e) Application.prototype.getMousePos=function(canvas,e)
@@ -1807,7 +1808,7 @@ Application.prototype.ToDefaultStateAndRedraw=function()
Application.prototype.getParameterByName=function(name) Application.prototype.getParameterByName=function(name)
{name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^&#]*)"),results=regex.exec(location.search);return results===null?"":decodeURIComponent(results[1].replace(/\+/g," "));} {name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regex=new RegExp("[\\?&]"+name+"=([^&#]*)"),results=regex.exec(location.search);return results===null?"":decodeURIComponent(results[1].replace(/\+/g," "));}
Application.prototype.onPostLoadEvent=function() Application.prototype.onPostLoadEvent=function()
{this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var wasLoad=false;let startAutoSave=true;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0) {this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/,"$1"));var edgeEnumCookie=/(?:^|;\s*)edgeEnumType\s*=\s*([^;]*)/.exec(document.cookie);this.SetEnumEdgesType(edgeEnumCookie?edgeEnumCookie[1]:"");var wasLoad=false;let startAutoSave=true;var matrix=document.getElementById("inputMatrix").innerHTML;var separator=document.getElementById("separator").innerHTML=="space"?" ":",";console.log(matrix);console.log("separator: \""+separator+"\"");matrix=(matrix.length<=0)?this.getParameterByName("matrix"):matrix;if(matrix.length>0)
{if(!this.SetAdjacencyMatrixSmart(matrix,separator)) {if(!this.SetAdjacencyMatrixSmart(matrix,separator))
{userAction("AdjacencyMatrix.Failed");this.listener.ShowAdjacencyMatrixErrorDialog(matrix);} {userAction("AdjacencyMatrix.Failed");this.listener.ShowAdjacencyMatrixErrorDialog(matrix);}
else else
@@ -1863,8 +1864,8 @@ Application.prototype.SetPair=function(pair)
{var res=true;var r={};var c={};if(!this.TestPair(pair)) {var res=true;var r={};var c={};if(!this.TestPair(pair))
{$.get("/"+SiteDir+"backend/addFailedMatrix.php?text=pair&matrix="+encodeURIComponent(pair),function(data){;});res=false;} {$.get("/"+SiteDir+"backend/addFailedMatrix.php?text=pair&matrix="+encodeURIComponent(pair),function(data){;});res=false;}
this.graph.SetPair(pair,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;} this.graph.SetPair(pair,new Point(this.GetRealWidth(),this.GetRealHeight()),this.currentEnumVerticesType);this.AutoAdjustViewport();this.redrawGraph();return res;}
Application.prototype.GetIncidenceMatrix=function() Application.prototype.GetIncidenceMatrix=function(res_columns_width)
{return this.graph.GetIncidenceMatrix();} {return this.graph.GetIncidenceMatrix(res_columns_width);}
Application.prototype.TestIncidenceMatrix=function(matrix,rowsObj,colsObj) Application.prototype.TestIncidenceMatrix=function(matrix,rowsObj,colsObj)
{return this.graph.TestIncidenceMatrix(matrix,rowsObj,colsObj);} {return this.graph.TestIncidenceMatrix(matrix,rowsObj,colsObj);}
Application.prototype.TestPair=function(pair) Application.prototype.TestPair=function(pair)
@@ -1944,6 +1945,11 @@ Application.prototype.SetEnumVerticesType=function(value)
{for(var i=0;i<this.enumVerticesTextList.length;i++) {for(var i=0;i<this.enumVerticesTextList.length;i++)
{if(this.enumVerticesTextList[i].GetValue()==value) {if(this.enumVerticesTextList[i].GetValue()==value)
{this.currentEnumVerticesType=this.enumVerticesTextList[i];document.cookie="enumType="+value;break;}}} {this.currentEnumVerticesType=this.enumVerticesTextList[i];document.cookie="enumType="+value;break;}}}
Application.prototype.SetEnumEdgesType=function(value)
{if(value==="Custom")
{value="";}
var isValidValue=value===""||this.enumVerticesTextList.some(function(enumType){return enumType.GetValue()===value&&value!=="Custom";});if(isValidValue)
{this.currentEnumEdgesType=value;document.cookie="edgeEnumType="+value;}}
Application.prototype.SetFindPathReport=function(value) Application.prototype.SetFindPathReport=function(value)
{this.findPathReport=value;} {this.findPathReport=value;}
Application.prototype.GetFindPathReport=function() Application.prototype.GetFindPathReport=function()
+22 -2
View File
@@ -14,6 +14,7 @@ function Application(document, window, listener)
this.handler = new DefaultHandler(this); this.handler = new DefaultHandler(this);
this.savedGraphName = ""; this.savedGraphName = "";
this.currentEnumVerticesType = new BaseEnumVertices(this, 1);//this.enumVerticesTextList[0]; this.currentEnumVerticesType = new BaseEnumVertices(this, 1);//this.enumVerticesTextList[0];
this.currentEnumEdgesType = "";
this.findPathReport = 1; this.findPathReport = 1;
this.isTimerRender = false; this.isTimerRender = false;
globalApplication = this; globalApplication = this;
@@ -728,6 +729,8 @@ Application.prototype.getParameterByName = function (name)
Application.prototype.onPostLoadEvent = function() Application.prototype.onPostLoadEvent = function()
{ {
this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/, "$1")); this.SetEnumVerticesType(document.cookie.replace(/(?:(?:^|.*;\s*)enumType\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
var edgeEnumCookie = /(?:^|;\s*)edgeEnumType\s*=\s*([^;]*)/.exec(document.cookie);
this.SetEnumEdgesType(edgeEnumCookie ? edgeEnumCookie[1] : "");
var wasLoad = false; var wasLoad = false;
let startAutoSave = true; let startAutoSave = true;
@@ -927,9 +930,9 @@ Application.prototype.SetPair = function (pair)
return res; return res;
} }
Application.prototype.GetIncidenceMatrix = function () Application.prototype.GetIncidenceMatrix = function (res_columns_width)
{ {
return this.graph.GetIncidenceMatrix(); return this.graph.GetIncidenceMatrix(res_columns_width);
} }
Application.prototype.TestIncidenceMatrix = function (matrix, rowsObj, colsObj) Application.prototype.TestIncidenceMatrix = function (matrix, rowsObj, colsObj)
@@ -1218,6 +1221,23 @@ Application.prototype.SetEnumVerticesType = function(value)
} }
} }
Application.prototype.SetEnumEdgesType = function(value)
{
if (value === "Custom")
{
value = "";
}
var isValidValue = value === "" || this.enumVerticesTextList.some(function(enumType) {
return enumType.GetValue() === value && value !== "Custom";
});
if (isValidValue)
{
this.currentEnumEdgesType = value;
document.cookie = "edgeEnumType=" + value;
}
}
Application.prototype.SetFindPathReport = function (value) Application.prototype.SetFindPathReport = function (value)
{ {
+20 -1
View File
@@ -445,6 +445,11 @@
<div class="matrix-wrapper"> <div class="matrix-wrapper">
<div class="corner"></div>
<div class="top-text-wrap" id="incidenceMatrix_top_text">
<div class="top-text" id="incidenceMatrix_top_text_text"></div>
</div>
<div class="side-text-wrap" id="incidenceMatrix_side_text"> <div class="side-text-wrap" id="incidenceMatrix_side_text">
<div class="side-text" id="incidenceMatrix_side_text_text"></div> <div class="side-text" id="incidenceMatrix_side_text_text"></div>
</div> </div>
@@ -452,11 +457,25 @@
<textarea class="matrix" name="incidenceMatrixField" id="IncidenceMatrixField" wrap="off"></textarea> <textarea class="matrix" name="incidenceMatrixField" id="IncidenceMatrixField" wrap="off"></textarea>
</div> </div>
<div class="incidence-matrix-controls">
<label for="incidenceEdgeEnumeration"><?= L('edge_enumeration') ?></label>
<select id="incidenceEdgeEnumeration" class="form-select form-select-sm">
<option value=""><?= L('no_enumeration') ?></option>
</select>
<button type="button" id="editIncidenceEdgeNames" class="btn btn-outline-secondary btn-sm">
<span class="bi bi-pencil" aria-hidden="true"></span> <?= L('edit_edge_names') ?>
</button>
</div>
<p id="BadIncidenceMatrixFormatMessage"><?= L('incidence_matrix_bad_format')?></p> <p id="BadIncidenceMatrixFormatMessage"><?= L('incidence_matrix_bad_format')?></p>
</fieldset> </fieldset>
</form> </form>
</div> </div>
<div id="incidenceEdgeNamesDialog" style="display:none;">
<textarea id="incidenceEdgeNamesList" class="form-control" rows="8" wrap="off"></textarea>
</div>
<div id="floidMatrix"> <div id="floidMatrix">
<form> <form>
<fieldset> <fieldset>