mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-06-17 14:22:02 +00:00
Added distance matrix
This commit is contained in:
@@ -515,6 +515,11 @@ Application.prototype.SetHandlerMode = function(mode)
|
|||||||
var showIncidenceMatrix = new ShowIncidenceMatrix(this);
|
var showIncidenceMatrix = new ShowIncidenceMatrix(this);
|
||||||
showIncidenceMatrix.show();
|
showIncidenceMatrix.show();
|
||||||
}
|
}
|
||||||
|
else if (mode == "showDistanceMatrix")
|
||||||
|
{
|
||||||
|
var showDistanceMatrix = new ShowDistanceMatrix(this);
|
||||||
|
showDistanceMatrix.show();
|
||||||
|
}
|
||||||
else if (mode == "connectedComponent")
|
else if (mode == "connectedComponent")
|
||||||
{
|
{
|
||||||
this.handler = new ConnectedComponentGraphHandler(this);
|
this.handler = new ConnectedComponentGraphHandler(this);
|
||||||
|
|||||||
@@ -572,6 +572,80 @@ ShowIncidenceMatrix.prototype.show = function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show distance matrix.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function ShowDistanceMatrix(app)
|
||||||
|
{
|
||||||
|
BaseHandler.apply(this, arguments);
|
||||||
|
this.app = app;
|
||||||
|
this.message = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// inheritance.
|
||||||
|
ShowDistanceMatrix.prototype = Object.create(BaseHandler.prototype);
|
||||||
|
// First selected.
|
||||||
|
ShowDistanceMatrix.prototype.firstObject = null;
|
||||||
|
// Path
|
||||||
|
ShowDistanceMatrix.prototype.pathObjects = null;
|
||||||
|
|
||||||
|
ShowDistanceMatrix.prototype.GetIncidenceMatrix = function (rawMatrix)
|
||||||
|
{
|
||||||
|
var matrix = "";
|
||||||
|
for (var i = 0; i < rawMatrix.length; i++)
|
||||||
|
{
|
||||||
|
for (var j = 0; j < rawMatrix[i].length; j++)
|
||||||
|
{
|
||||||
|
if ((new Graph()).infinity == rawMatrix[i][j])
|
||||||
|
{
|
||||||
|
matrix += '\u221E';
|
||||||
|
}
|
||||||
|
else if (i == j)
|
||||||
|
{
|
||||||
|
matrix += "0";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
matrix += rawMatrix[i][j];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j != rawMatrix[i].length - 1)
|
||||||
|
{
|
||||||
|
matrix += ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
matrix = matrix + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowDistanceMatrix.prototype.show = function()
|
||||||
|
{
|
||||||
|
var handler = this;
|
||||||
|
var dialogButtons = {};
|
||||||
|
|
||||||
|
dialogButtons[g_close] = function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
};
|
||||||
|
|
||||||
|
var handler = g_Algorithms[g_AlgorithmIds.indexOf("OlegSh.FloidAlgorithm")](this.app.graph, this.app);
|
||||||
|
|
||||||
|
$( "#FloidMatrixField" ).val(this.GetIncidenceMatrix(handler.resultMatrix()));
|
||||||
|
|
||||||
|
$( "#floidMatrix" ).dialog({
|
||||||
|
resizable: false,
|
||||||
|
height: "auto",
|
||||||
|
width: "auto",
|
||||||
|
modal: true,
|
||||||
|
title: g_minDistMatrixText,
|
||||||
|
buttons: dialogButtons,
|
||||||
|
dialogClass: 'EdgeDialog'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save dialog Graph handler.
|
* Save dialog Graph handler.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -279,6 +279,11 @@ function postLoadPage()
|
|||||||
userAction(this.id);
|
userAction(this.id);
|
||||||
application.SetHandlerMode("showIncidenceMatrix");
|
application.SetHandlerMode("showIncidenceMatrix");
|
||||||
}
|
}
|
||||||
|
document.getElementById('ShowDistanceMatrix').onclick = function ()
|
||||||
|
{
|
||||||
|
userAction(this.id);
|
||||||
|
application.SetHandlerMode("showDistanceMatrix");
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('GroupRename').onclick = function ()
|
document.getElementById('GroupRename').onclick = function ()
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-2
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<script src="<?= Root('i/js/dev/jquery-ui.js')?>"></script>
|
<script src="<?= Root('i/js/dev/jquery-ui.js')?>"></script>
|
||||||
<script src="<?= Root('i/js/dev/jquery.feedback_me.js')?>"></script>
|
<script src="<?= Root('i/js/dev/jquery.feedback_me.js')?>"></script>
|
||||||
<script src="<?= Root("script/example.js?v=6")?>" ></script>
|
<script src="<?= Root("script/example.js?v=7")?>" ></script>
|
||||||
</head>
|
</head>
|
||||||
<!--
|
<!--
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@@ -64,6 +64,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<button type="button" class="btn btn-default btn-sm btn-submenu" id="ShowIncidenceMatrix"><span class="glyphicon glyphicon-th fa-fw"></span> <?= L('show_incidence_matrix')?> </button>
|
<button type="button" class="btn btn-default btn-sm btn-submenu" id="ShowIncidenceMatrix"><span class="glyphicon glyphicon-th fa-fw"></span> <?= L('show_incidence_matrix')?> </button>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="button" class="btn btn-default btn-sm btn-submenu" id="ShowDistanceMatrix"><span class="glyphicon glyphicon-th fa-fw"></span> <?= L('distMatrixText')?> </button>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button type="button" class="btn btn-default btn-sm btn-submenu" id="GroupRename"><span class="glyphicon glyphicon-pencil fa-fw"></span> <?= L('group_rename')?> </button>
|
<button type="button" class="btn btn-default btn-sm btn-submenu" id="GroupRename"><span class="glyphicon glyphicon-pencil fa-fw"></span> <?= L('group_rename')?> </button>
|
||||||
</li>
|
</li>
|
||||||
@@ -305,7 +308,7 @@
|
|||||||
<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="voteDialog">
|
<div id="voteDialog">
|
||||||
<form>
|
<form>
|
||||||
|
|||||||
Reference in New Issue
Block a user