Support negative weight for edges.

This commit is contained in:
Oleg Sh
2024-03-30 15:03:30 +01:00
parent 2e302b9013
commit 61bafa7d51
12 changed files with 37 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=75","/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75","/script/features/draw_graph/api/index.js?v=75","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=75","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=75","/script/features/draw_graph/model/BaseVertexDrawer.js?v=75","/script/features/algorithms/api/index.js?v=75","/script/features/algorithms/model/Algorithms.js?v=75","/script/features/algorithms/model/BaseTraversal.js?v=75","/script/features/base_handler/index.js?v=75","/script/features/default_handler/index.js?v=75","/script/features/add_vertices_handler/index.js?v=75","/script/features/connect_vertices_handler/index.js?v=75","/script/features/delete_objects_handler/index.js?v=75","/script/features/algorithm_handler/index.js?v=75","/script/features/serialization/api/index.js?v=75","/script/features/serialization/model/GraphMLCreator.js?v=75","/script/features/enum_vertices/EnumVertices.js?v=75","/script/pages/editor/model/texts.js?v=75","/script/pages/editor/model/UndoStack.js?v=75","/script/pages/editor/model/DiskSaveLoad.js?v=75","/script/pages/editor/model/Application.js?v=75","/script/pages/editor/ui/ya_metrika.js?v=75","/script/pages/editor/ui/editor.js?v=75","/script/pages/editor/ui/main.js?v=75",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();}
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=76","/script/entities/graph/api/index.js?v=76","/script/shared/point.js?v=76","/script/entities/edge/api/index.js?v=76","/script/entities/edge/model/BaseEdge.js?v=76","/script/entities/edge/model/EdgeModel.js?v=76","/script/entities/vertex/api/index.js?v=76","/script/entities/vertex/model/BaseVertex.js?v=76","/script/entities/vertex/model/VertexModel.js?v=76","/script/entities/graph/model/Graph.js?v=76","/script/features/draw_graph/api/index.js?v=76","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=76","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=76","/script/features/draw_graph/model/BaseVertexDrawer.js?v=76","/script/features/algorithms/api/index.js?v=76","/script/features/algorithms/model/Algorithms.js?v=76","/script/features/algorithms/model/BaseTraversal.js?v=76","/script/features/base_handler/index.js?v=76","/script/features/default_handler/index.js?v=76","/script/features/add_vertices_handler/index.js?v=76","/script/features/connect_vertices_handler/index.js?v=76","/script/features/delete_objects_handler/index.js?v=76","/script/features/algorithm_handler/index.js?v=76","/script/features/serialization/api/index.js?v=76","/script/features/serialization/model/GraphMLCreator.js?v=76","/script/features/enum_vertices/EnumVertices.js?v=76","/script/pages/editor/model/texts.js?v=76","/script/pages/editor/model/UndoStack.js?v=76","/script/pages/editor/model/DiskSaveLoad.js?v=76","/script/pages/editor/model/Application.js?v=76","/script/pages/editor/ui/ya_metrika.js?v=76","/script/pages/editor/ui/editor.js?v=76","/script/pages/editor/ui/main.js?v=76",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);postLoadPage();}
let modulDir="pages/editor/";doInclude([include("shared/utils.js"),include("entities/graph/api/index.js"),include("features/draw_graph/api/index.js"),include("features/algorithms/api/index.js"),include("features/base_handler/index.js"),include("features/default_handler/index.js"),include("features/add_vertices_handler/index.js"),include("features/connect_vertices_handler/index.js"),include("features/delete_objects_handler/index.js"),include("features/algorithm_handler/index.js"),include("features/serialization/api/index.js"),include("features/enum_vertices/EnumVertices.js"),include("model/texts.js",modulDir),include("model/UndoStack.js",modulDir),include("model/DiskSaveLoad.js",modulDir),include("model/Application.js",modulDir),include("ui/ya_metrika.js",modulDir),include("ui/editor.js",modulDir),include("ui/main.js",modulDir)],onloadEditor);}
function gEncodeToHTML(str)
{if(typeof str!=='string')
@@ -291,7 +291,7 @@ Graph.prototype.FindEdgeMin=function(id1,id2)
{res=edge;minWeight=edge.weight;}}}
return res;}
Graph.prototype.FindEdgeMax=function(id1,id2)
{var res=null;var maxWeight=0;for(var i=0;i<this.edges.length;i++)
{var res=null;var maxWeight=-this.infinity;for(var i=0;i<this.edges.length;i++)
{var edge=this.edges[i];if((edge.vertex1.id==id1&&edge.vertex2.id==id2)||(!edge.isDirect&&edge.vertex1.id==id2&&edge.vertex2.id==id1))
{if(edge.weight>maxWeight)
{res=edge;maxWeight=edge.weight;}}}
@@ -2018,4 +2018,4 @@ function postLoadPage()
$(document).ready(function()
{window.onresize=function(event)
{resizeCanvas();}
document.getElementById('canvas').addEventListener("touchstart",touchHandler,true);document.getElementById('canvas').addEventListener("touchmove",touchHandler,true);document.getElementById('canvas').addEventListener("touchend",touchHandler,true);document.getElementById('canvas').addEventListener("touchcancel",touchHandler,true);var isMobile=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);if(!isMobile&&!DisableEmscripten){let fullPathToGraphffoline="features/graphoffline/Graphoffline.Emscripten.js";doIncludeAsync([include(fullPathToGraphffoline),],()=>{Module['onRuntimeInitialized']=onRuntimeInitialized;var process=Module.cwrap('ProcessAlgorithm','string',['string']);function onRuntimeInitialized(){editor.application.setEmscripten(process);}})}});moduleLoader.endCacheLoading();
document.getElementById('canvas').addEventListener("touchstart",touchHandler,true);document.getElementById('canvas').addEventListener("touchmove",touchHandler,true);document.getElementById('canvas').addEventListener("touchend",touchHandler,true);document.getElementById('canvas').addEventListener("touchcancel",touchHandler,true);var isMobile=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i);if(!isMobile&&!DisableEmscripten){let fullPathToGraphffoline="features/graphoffline/Graphoffline.Emscripten.js"+"?v="+globalVersion;doIncludeAsync([include(fullPathToGraphffoline),],()=>{Module['onRuntimeInitialized']=onRuntimeInitialized;var process=Module.cwrap('ProcessAlgorithm','string',['string']);function onRuntimeInitialized(){editor.application.setEmscripten(process);}})}});moduleLoader.endCacheLoading();