mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-04-08 16:56:03 +00:00
Add creating graph using Edge List.
This commit is contained in:
@@ -846,6 +846,28 @@ Application.prototype.onPostLoadEvent = function()
|
||||
wasLoad = true;
|
||||
}
|
||||
|
||||
var pairs = document.getElementById("inputPair").innerHTML;
|
||||
|
||||
if (pairs.length > 0)
|
||||
{
|
||||
pairs = pairs.replaceAll('>', '>');
|
||||
pairs = pairs.replaceAll('<', '<');
|
||||
|
||||
if (!this.SetPairSmart(pairs))
|
||||
{
|
||||
this.userAction("Pair.Failed");
|
||||
this.ShowPairErrorDialog(pairs);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.userAction("Pair.Success");
|
||||
}
|
||||
|
||||
this.updateMessage();
|
||||
this.redrawGraph();
|
||||
wasLoad = true;
|
||||
}
|
||||
|
||||
if (!wasLoad)
|
||||
{
|
||||
var graphName = this.getParameterByName("graph");
|
||||
@@ -933,6 +955,22 @@ Application.prototype.SetAdjacencyMatrix = function (matrix, separator)
|
||||
return res;
|
||||
}
|
||||
|
||||
Application.prototype.SetPair = function (pair)
|
||||
{
|
||||
var res = true;
|
||||
var r = {};
|
||||
var c = {};
|
||||
if (!this.TestPair(pair))
|
||||
{
|
||||
$.get( "/" + SiteDir + "cgi-bin/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;
|
||||
}
|
||||
|
||||
Application.prototype.GetIncidenceMatrix = function ()
|
||||
{
|
||||
@@ -944,6 +982,11 @@ Application.prototype.TestIncidenceMatrix = function (matrix, rowsObj, colsObj)
|
||||
return this.graph.TestIncidenceMatrix(matrix, rowsObj, colsObj);
|
||||
}
|
||||
|
||||
Application.prototype.TestPair = function (pair)
|
||||
{
|
||||
return this.graph.TestPair(pair);
|
||||
}
|
||||
|
||||
Application.prototype.SetIncidenceMatrix = function (matrix)
|
||||
{
|
||||
var res = true;
|
||||
@@ -1011,6 +1054,22 @@ Application.prototype.SetIncidenceMatrixSmart = function (matrix)
|
||||
return res;
|
||||
}
|
||||
|
||||
Application.prototype.SetPairSmart = function (pair)
|
||||
{
|
||||
var res = false;
|
||||
|
||||
if (this.TestPair(pair))
|
||||
{
|
||||
res = this.SetPair(pair);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Application.prototype.SaveGraphOnDisk = function ()
|
||||
{
|
||||
@@ -1288,6 +1347,34 @@ Application.prototype.ShowIncidenceMatrixErrorDialog = function(matrix)
|
||||
buttons: dialogButtons,
|
||||
});
|
||||
}
|
||||
|
||||
Application.prototype.ShowPairErrorDialog = function(pair)
|
||||
{
|
||||
var dialogButtons = {};
|
||||
|
||||
pair = pair.replaceAll(/\n/g,'%0A');
|
||||
pair = pair.replaceAll('>', '>');
|
||||
pair = pair.replaceAll('<', '<');
|
||||
|
||||
dialogButtons[g_readMatrixHelp] = function() {
|
||||
window.location.assign(g_language == "ru" ? "./wiki/Справка/СписокРебер" : "./wiki/Help/EdgeList");
|
||||
};
|
||||
dialogButtons[g_fix] = function() {
|
||||
window.location.assign("./create_graph_by_edge_list?pair=" + pair);
|
||||
};
|
||||
dialogButtons[g_close] = function() {
|
||||
$( this ).dialog( "close" );
|
||||
};
|
||||
|
||||
$( "#pairErrorInc" ).dialog({
|
||||
resizable: false,
|
||||
title: g_pairWrongFormat,
|
||||
width: 400,
|
||||
modal: true,
|
||||
dialogClass: 'EdgeDialog',
|
||||
buttons: dialogButtons,
|
||||
});
|
||||
}
|
||||
|
||||
Application.prototype.SetFindPathReport = function (value)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user