fix create graph by adjacency matrix.

This commit is contained in:
Unick Soft 2019-10-20 11:17:56 +02:00
parent f5878a720d
commit 52c15a5e33
2 changed files with 5 additions and 5 deletions

View File

@ -34,9 +34,9 @@ Graph.prototype.AddNewVertex = function(vertex)
return this.vertices.length - 1;
}
Graph.prototype.AddNewEdgeSafe = function(graph1, graph2, isDirect, weight)
Graph.prototype.AddNewEdgeSafe = function(graph1, graph2, isDirect, weight, replaceIfExists = true)
{
return this.AddNewEdge(new BaseEdge(graph1, graph2, isDirect, weight));
return this.AddNewEdge(new BaseEdge(graph1, graph2, isDirect, weight), replaceIfExists);
}
Graph.prototype.AddNewEdge = function(edge, replaceIfExists)
@ -519,7 +519,7 @@ Graph.prototype.SetAdjacencyMatrix = function (matrix, viewportSize, currentEnum
if (cols[i][j] > 0)
{
var nEdgeIndex = this.AddNewEdgeSafe(this.vertices[i], this.vertices[j], cols[i][j] != cols[j][i], cols[i][j]);
var nEdgeIndex = this.AddNewEdgeSafe(this.vertices[i], this.vertices[j], cols[i][j] != cols[j][i], cols[i][j], true);
if (nEdgeIndex >= 0)
{
bWeightGraph = bWeightGraph || this.edges[nEdgeIndex].weight != 1;
@ -669,7 +669,7 @@ Graph.prototype.SetIncidenceMatrix = function (matrix, viewportSize, currentEnum
}
var nEdgeIndex = this.AddNewEdgeSafe(this.vertices[edgeIndex[0]], this.vertices[edgeIndex[1]],
edgeValue[0] != edgeValue[1], Math.abs(edgeValue[1]));
edgeValue[0] != edgeValue[1], Math.abs(edgeValue[1]), false);
if (nEdgeIndex >= 0)
{
bWeightGraph = bWeightGraph || this.edges[nEdgeIndex].weight != 1;

View File

@ -10,7 +10,7 @@
<script src="<?= Root('i/js/dev/jquery-ui.js')?>"></script>
<script src="<?= Root('i/js/dev/jquery.feedback_me.js')?>"></script>
<script src="<?= Root("script/example.js?v=21")?>" ></script>
<script src="<?= Root("script/example.js?v=22")?>" ></script>
</head>
<!--
<div class="pull-right">