diff --git a/script/Algorithms.js b/script/Algorithms.js
index 6ace631..d11dac9 100644
--- a/script/Algorithms.js
+++ b/script/Algorithms.js
@@ -250,7 +250,23 @@ BaseAlgorithmEx.prototype.GetNodesPath = function(array, start, count)
var res = [];
for (var index = start; index < start + count; index++)
{
- res.push(array[index].value);
+ if (array[index].type == 4)
+ {
+ res.push(array[index].value);
+ }
+ }
+ return res;
+}
+
+BaseAlgorithmEx.prototype.GetNodesEdgesPath = function(array, start, count)
+{
+ var res = [];
+ for (var index = start; index < start + count; index++)
+ {
+ if (array[index].type == 4 || array[index].type == 5)
+ {
+ res.push(array[index].value);
+ }
}
return res;
}
diff --git a/script/Appilcation.js b/script/Appilcation.js
index 7f5af91..b4f13b4 100644
--- a/script/Appilcation.js
+++ b/script/Appilcation.js
@@ -45,6 +45,7 @@ function Application(document, window)
this.backgroundCommonStyle = new CommonBackgroundStyle();
this.backgroundPrintStyle = new PrintBackgroundStyle();
this.isBackgroundCommonStyleCustom = false;
+ this.renderPathWithEdges = false;
};
// List of graph.
@@ -104,7 +105,12 @@ Application.prototype.redrawGraphTimer = function()
for (i = 0; i < this.renderPath.length - 1; i++)
{
var edge = null;
- if (this.renderMinPath)
+ if (this.renderPathWithEdges)
+ {
+ edge = this.graph.FindEdgeById(this.renderPath[i + 1]);
+ i++;
+ }
+ else if (this.renderMinPath)
{
edge = this.graph.FindEdgeMin(this.renderPath[i], this.renderPath[i + 1]);
}
@@ -124,13 +130,21 @@ Application.prototype.redrawGraphTimer = function()
if (i >= this.renderPath.length - 1)
{
i = 0;
+ if (this.renderPathWithEdges)
+ i = 1;
this.renderPathCounter = 0;
currentLength = 0;
this.renderPathLoops += 1;
}
var edge = null;
- if (this.renderMinPath)
+ var currentVertexId = this.renderPath[i];
+ if (this.renderPathWithEdges)
+ {
+ edge = this.graph.FindEdgeById(this.renderPath[i]);
+ currentVertexId = this.renderPath[i - 1];
+ }
+ else if (this.renderMinPath)
{
edge = this.graph.FindEdgeMin(this.renderPath[i], this.renderPath[i + 1]);
}
@@ -141,7 +155,7 @@ Application.prototype.redrawGraphTimer = function()
var progress = (this.renderPathCounter - currentLength) / edge.GetPixelLength();
- this.RedrawEdgeProgress(context, edge, edge.vertex1.id == this.renderPath[i] ? progress : 1.0 - progress);
+ this.RedrawEdgeProgress(context, edge, edge.vertex1.id == currentVertexId ? progress : 1.0 - progress);
this.renderPathCounter += movePixelStep;
@@ -232,7 +246,16 @@ Application.prototype.updateRenderPathLength = function()
{
for (var i = 0; i < this.renderPath.length - 1; i++)
{
- var edge = this.graph.FindEdge(this.renderPath[i], this.renderPath[i + 1]);
+ var edge = null;
+ if (this.renderPathWithEdges)
+ {
+ edge = this.graph.FindEdgeById(this.renderPath[i + 1]);
+ i++;
+ }
+ else
+ {
+ edge = this.graph.FindEdge(this.renderPath[i], this.renderPath[i + 1]);
+ }
this.renderPathLength += edge.GetPixelLength();
}
}
@@ -260,6 +283,23 @@ Application.prototype.setRenderPath = function(renderPath, renderMinPath)
{
this.renderPath = renderPath;
this.renderMinPath = renderMinPath;
+ this.renderPathWithEdges = false;
+
+ if (this.renderPath.length > 0)
+ {
+ this.startRenderTimer();
+ }
+ else
+ {
+ this.stopRenderTimer();
+ }
+}
+
+Application.prototype.setRenderPathWithEdges = function(renderPath)
+{
+ this.renderPath = renderPath;
+ this.renderMinPath = false;
+ this.renderPathWithEdges = true;
if (this.renderPath.length > 0)
{
@@ -1231,6 +1271,11 @@ Application.prototype.resultCallback = function(paths)
{
this.setRenderPath(paths["paths"][0], "minPath" in paths);
}
+ else if ((paths instanceof Object) && "pathsWithEdges" in paths)
+ {
+ this.setRenderPathWithEdges(paths["pathsWithEdges"][0]);
+ }
+
this.updateMessage();
this.redrawGraph();
}
diff --git a/script/plugins/HamiltonianLoop.js b/script/plugins/HamiltonianLoop.js
index 82240ef..023cc37 100644
--- a/script/plugins/HamiltonianLoop.js
+++ b/script/plugins/HamiltonianLoop.js
@@ -52,9 +52,11 @@ FindHamiltonianLoop.prototype.resultCallback = function(pathObjects, properties,
this.message = result > 0 ? g_hasHamiltonianLoop : g_hasNotHamiltonianLoop;
if (result > 0)
{
- var nodesPath = this.GetNodesPath(results, 1, results.length - 1);
- outputResult["paths"] = [];
- outputResult["paths"].push(nodesPath);
+ var nodesEdgesPath = this.GetNodesEdgesPath(results, 1, results.length - 1);
+ var nodesPath = this.GetNodesPath(results, 1, results.length - 1);
+
+ outputResult["pathsWithEdges"] = [];
+ outputResult["pathsWithEdges"].push(nodesEdgesPath);
this.selectedObjects = [];
for (var i = 0; i < pathObjects.length; i++)
@@ -82,6 +84,12 @@ FindHamiltonianLoop.prototype.getPriority = function()
return -5;
}
+// Algorithm support multi graph
+FindHamiltonianLoop.prototype.IsSupportMultiGraph = function()
+{
+ return true;
+}
+
// Factory for connected components.
function CreateFindHamiltonianLoop(graph, app)
{
diff --git a/script/plugins/HamiltonianPath.js b/script/plugins/HamiltonianPath.js
index 1843c9d..7907690 100644
--- a/script/plugins/HamiltonianPath.js
+++ b/script/plugins/HamiltonianPath.js
@@ -52,9 +52,11 @@ FindHamiltonianPath.prototype.resultCallback = function(pathObjects, properties,
this.message = result > 0 ? g_hasHamiltonianPath : g_hasNotHamiltonianPath;
if (result > 0)
{
- var nodesPath = this.GetNodesPath(results, 1, results.length - 1);
- outputResult["paths"] = [];
- outputResult["paths"].push(nodesPath);
+ var nodesEdgesPath = this.GetNodesEdgesPath(results, 1, results.length - 1);
+ var nodesPath = this.GetNodesPath(results, 1, results.length - 1);
+
+ outputResult["pathsWithEdges"] = [];
+ outputResult["pathsWithEdges"].push(nodesEdgesPath);
this.selectedObjects = [];
for (var i = 0; i < pathObjects.length; i++)
@@ -82,6 +84,11 @@ FindHamiltonianPath.prototype.getPriority = function()
return -5;
}
+FindHamiltonianPath.prototype.IsSupportMultiGraph = function()
+{
+ return true;
+}
+
// Factory for connected components.
function CreateFindHamiltonianPath(graph, app)
{
diff --git a/tpl/home.php b/tpl/home.php
index 6bee446..2210b5b 100755
--- a/tpl/home.php
+++ b/tpl/home.php
@@ -10,7 +10,7 @@
-
+