diff --git a/README.md b/README.md index a7b9c0a..473017d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ In files: /wiki/local/config.php /en/wiki/local/config.php -7. Maybe you need to disable autoredirect to https. Commends lines: +7. Maybe you need to disable autoredirect to https. Comments or remove lines: ``` RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] diff --git a/cgi-bin/GraphOffline/OSX/GraphCGI.exe b/cgi-bin/GraphOffline/OSX/GraphCGI.exe new file mode 100644 index 0000000..f59c05b Binary files /dev/null and b/cgi-bin/GraphOffline/OSX/GraphCGI.exe differ diff --git a/cgi-bin/GraphOffline/Windows/GraphCGI.exe b/cgi-bin/GraphOffline/Windows/GraphCGI.exe new file mode 100644 index 0000000..58ac8d0 Binary files /dev/null and b/cgi-bin/GraphOffline/Windows/GraphCGI.exe differ diff --git a/script/Algorithms.js b/script/Algorithms.js index 38a25c3..6ace631 100644 --- a/script/Algorithms.js +++ b/script/Algorithms.js @@ -219,7 +219,11 @@ BaseAlgorithmEx.prototype.CalculateAlgorithm = function(queryString, resultCallb $edges.each(function(){ var source = $(this).attr('source'); var target = $(this).attr('target'); - var edge = graph.FindEdge(source, target); + var edge = graph.FindEdge(source, target); + if (typeof $(this).attr('id') !== 'undefined') + { + edge = graph.FindEdgeById($(this).attr('id')); + } pathObjects.push(edge); $data = $(this).find("data"); diff --git a/script/Appilcation.js b/script/Appilcation.js index cf65ba1..2796c2f 100644 --- a/script/Appilcation.js +++ b/script/Appilcation.js @@ -103,7 +103,16 @@ Application.prototype.redrawGraphTimer = function() var i = 0 for (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.renderMinPath) + { + edge = this.graph.FindEdgeMin(this.renderPath[i], this.renderPath[i + 1]); + } + else + { + edge = this.graph.FindEdge(this.renderPath[i], this.renderPath[i + 1]); + } + currentLength += edge.GetPixelLength(); if (currentLength > this.renderPathCounter) { @@ -120,7 +129,15 @@ Application.prototype.redrawGraphTimer = function() this.renderPathLoops += 1; } - var edge = this.graph.FindEdge(this.renderPath[i], this.renderPath[i + 1]); + var edge = null; + if (this.renderMinPath) + { + edge = this.graph.FindEdgeMin(this.renderPath[i], this.renderPath[i + 1]); + } + else + { + edge = this.graph.FindEdge(this.renderPath[i], this.renderPath[i + 1]); + } var progress = (this.renderPathCounter - currentLength) / edge.GetPixelLength(); @@ -239,9 +256,10 @@ Application.prototype.stopRenderTimer = function() } } -Application.prototype.setRenderPath = function(renderPath) +Application.prototype.setRenderPath = function(renderPath, renderMinPath) { - this.renderPath = renderPath; + this.renderPath = renderPath; + this.renderMinPath = renderMinPath; if (this.renderPath.length > 0) { @@ -537,68 +555,6 @@ Application.prototype.FindAllEdges = function(id1, id2) return this.graph.FindAllEdges(id1, id2); } -Application.prototype.FindPath = function(graph1, graph2) -{ - var creator = new GraphMLCreater(this.graph.vertices, this.graph.edges); - var app = this; - - $.ajax({ - type: "POST", - url: "/" + SiteDir + "cgi-bin/GraphCGI.exe?dsp=cgiInput&start=" + graph1.id + "&finish=" + graph2.id + "&report=xml", - data: creator.GetXMLString(), - dataType: "text" - }) - .done(function( msg ) - { - $('#debug').text(msg); - xmlDoc = $.parseXML( msg ); - var $xml = $( xmlDoc ); - - $nodes = $xml.find( "node" ); - - var pathObjects = new Array(); - var shortDistObjects = {}; - - $nodes.each(function(){ - var id = $(this).attr('id'); - $data = $(this).find("data"); - $data.each(function(){ - if ("hightlightNode" == $(this).attr('key') && $(this).text() == "1") - { - pathObjects.push(app.FindVertex(id)); - } - if ("lowestDistance" == $(this).attr('key')) - { - shortDistObjects[id] = $(this).text(); - } - }); - }); - - $edges = $xml.find( "edge" ); - - $edges.each(function(){ - var source = $(this).attr('source'); - var target = $(this).attr('target'); - pathObjects.push(app.FindEdge(source, target)); - }); - - var $graph = $xml.find( "graph" ); - $graph.each(function(){ - var shortPathResult = $(this).attr('result'); - app.handler.SetShortPath(shortPathResult); - }); - - app.handler.SetObjects(pathObjects); - app.handler.SetShortDist(shortDistObjects); - - app.redrawGraph(); - app.updateMessage(); - }); - - // return empty, will set later. - return []; -} - Application.prototype.SetHandlerMode = function(mode) { var manipolationHandlers = ["default", "addGraph", "addArc", "delete", "findPath", "connectedComponent", "eulerianLoop"]; @@ -1270,7 +1226,7 @@ Application.prototype.resultCallback = function(paths) console.log(paths); if ((paths instanceof Object) && "paths" in paths) { - this.setRenderPath(paths["paths"][0]); + this.setRenderPath(paths["paths"][0], "minPath" in paths); } this.updateMessage(); this.redrawGraph(); diff --git a/script/Graph.js b/script/Graph.js index 303e743..4ca56c9 100644 --- a/script/Graph.js +++ b/script/Graph.js @@ -120,6 +120,21 @@ Graph.prototype.FindEdge = function(id1, id2) return this.FindEdgeAny(id1, id2); } +Graph.prototype.FindEdgeById = function(edgeId) +{ + var res = null; + for (var i = 0; i < this.edges.length; i++) + { + if (this.edges[i].id == edgeId) + { + res = this.edges[i]; + break; + } + } + + return res; +} + Graph.prototype.FindEdgeAny = function(id1, id2) { var res = null; diff --git a/script/GraphMLCreater.js b/script/GraphMLCreater.js index 13e6023..21e7443 100644 --- a/script/GraphMLCreater.js +++ b/script/GraphMLCreater.js @@ -40,15 +40,18 @@ GraphMLCreater.prototype.GetXMLString = function() } for (var i = 0; i < this.arcs.length; i++) { - var weightData = ""; + var weightData = ""; + var arc = this.arcs[i]; + if (this.arcs[i].weight != defaultWeight) { - weightData = ""+ this.arcs[i].weight + ""; + weightData = "" + arc.weight + ""; } - xmlBoby = xmlBoby + "" + weightData + "" : "/>") } diff --git a/script/plugins/Floid.js b/script/plugins/Floid.js index 8d864ee..a15a7b0 100755 --- a/script/plugins/Floid.js +++ b/script/plugins/Floid.js @@ -53,6 +53,7 @@ FloidAlgorithm.prototype.result = function(resultCallback) // Remove all edges. this.egdesCopy = this.graph.edges.slice(); this.removeAllEdges(); + this.isGraphMulti = this.graph.isMulti(); this.graph.hasDirect = false; @@ -206,7 +207,13 @@ FloidAlgorithm.prototype.restore = function() for (var i = 0; i < this.egdesCopy.length; i ++) { - this.graph.AddNewEdgeSafe(this.egdesCopy[i].vertex1, this.egdesCopy[i].vertex2, this.egdesCopy[i].isDirect, this.egdesCopy[i].weight); + var edge = this.graph.AddNewEdgeSafe(this.egdesCopy[i].vertex1, + this.egdesCopy[i].vertex2, + this.egdesCopy[i].isDirect, + this.egdesCopy[i].weight, + this.isGraphMulti); + + //edge.model = this.egdesCopy[i].model; } } @@ -216,6 +223,12 @@ FloidAlgorithm.prototype.updateMessage = function(save) "" } +// Algorithm support multi graph +FloidAlgorithm.prototype.IsSupportMultiGraph = function () +{ + return false; +} + // Factory for connected components. function CreateFloidAlgorithm(graph, app) { diff --git a/script/plugins/MinimumSpanningTree.js b/script/plugins/MinimumSpanningTree.js index f0d51db..2613b8e 100755 --- a/script/plugins/MinimumSpanningTree.js +++ b/script/plugins/MinimumSpanningTree.js @@ -73,6 +73,7 @@ MinimumSpanningTree.prototype.result = function(resultCallback) var result = {}; result["version"] = 1; + result["minPath"] = true; return result; } @@ -145,6 +146,12 @@ MinimumSpanningTree.prototype.getPriority = function() return -9.5; } +// Algorithm support multi graph +MinimumSpanningTree.prototype.IsSupportMultiGraph = function () +{ + return true; +} + // Factory for algorithm. function CreateMinimumSpanningTree(graph, app) diff --git a/script/plugins/ShortestPath.js b/script/plugins/ShortestPath.js index 8acb224..6b7e80e 100644 --- a/script/plugins/ShortestPath.js +++ b/script/plugins/ShortestPath.js @@ -55,6 +55,7 @@ FindShortPathNew.prototype.resultCallback = function(pathObjects, properties, re { var outputResult = {}; outputResult["version"] = 1; + outputResult["minPath"] = true; this.pathObjects = pathObjects; this.properties = properties; @@ -205,6 +206,12 @@ FindShortPathNew.prototype.getPriority = function() return -10; } +// Algorithm support multi graph +FindShortPathNew.prototype.IsSupportMultiGraph = function () +{ + return true; +} + // Factory for connected components. function CreateFindShortPathNew(graph, app) diff --git a/tpl/home.php b/tpl/home.php index 7814a90..e4a05e6 100755 --- a/tpl/home.php +++ b/tpl/home.php @@ -173,6 +173,7 @@ + +