A method for realizing orthogonal connection of flow chart nodes

By building scale layer and grid layer, combining adaptive grid refinement and improving Dijkstra algorithm, the problem of unreasonable selection of orthogonal connection paths of flowchart nodes is solved, and the aesthetics and readability of the flowchart is improved, and the image and readability of the flowchart is realized. More intuitive logical presentation and higher user experience.

CN118864652BActive Publication Date: 2025-01-14GUODIAN NANJING AUTOMATION

Patent Information

Application Number
CN202411336295.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-01-14
Estimated Expiration
2044-09-25

AI Technical Summary

Technical Problem

In the prior art, when the flowchart nodes are connected orthogonally, it is difficult to effectively optimize path selection, resulting in insufficient aesthetics and readability of the flowchart. The Dijkstra algorithm has limitations in dealing with multiple shortest paths and path aesthetics.

Method used

By building scale layer and grid layer, using the adaptive grid refinement algorithm and the improved Dijkstra algorithm, the shortest path between the starting node and the terminating node is calculated, and the best orthogonal connection path is extracted from it, taking into account the path in a comprehensive way. Factors such as length, number of inflection points, overlap between the connection and the node boundary, and connection through the node.

Benefits of technology

It significantly improves the readability and aesthetics of the flowchart, allowing the flowchart to display logical relationships more intuitively, improves the user experience, and avoids the connection chaos and node occlusion problems in traditional methods, improving the overall aesthetics of the flowchart degree and normative.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118864652B_ABST
    Figure CN118864652B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for realizing orthogonal connection of flow chart nodes, and relates to the field of information technology. The method comprises the following steps: processing the boundary boxes of the starting node and the ending node in the flow chart respectively to obtain the processed node positions and boundary information; constructing the scale layer, grid layer and reference points of the flow chart in sequence based on the processed node positions and boundary information, and establishing an optimized grid route map according to the adjacent relationship between the reference points; calculating the shortest path between the starting node and the ending node in the optimized grid route map, and extracting the best orthogonal connection path from the shortest path calculation result. The present invention comprehensively considers factors such as path length, number of inflection points, overlap between the connection line and the node boundary, and connection line crossing nodes by improving the Dijkstra algorithm, so as to generate more beautiful and standardized orthogonal connection lines of flow chart nodes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and in particular to a method for realizing orthogonal connection of flow chart nodes. Background Art

[0002] In the field of information technology, flowcharts are widely used in various business scenarios as an intuitive way of expression, such as software development, project management, and system analysis. The nodes in the flowchart represent specific steps or events, while the lines between the nodes represent the logical relationship between the steps or the order in which the events occur. The design of the lines between the nodes is crucial to the readability and aesthetics of the flowchart.

[0003] In flowchart drawing, orthogonal lines are a commonly used connection method, which means that the lines only contain horizontal and vertical segments, and these segments form right angles when connected. This connection method makes the flowchart neater and clearer, which is conducive to readers' understanding of the logical relationship of the process. However, in practical applications, it is not easy to determine the best path for orthogonal lines between nodes; on the one hand, it is necessary to ensure that the lines meet the orthogonal requirements; on the other hand, it is also necessary to consider factors such as the length of the lines and the number of inflection points to optimize the aesthetics and readability of the flowchart.

[0004] At present, the orthogonal connection methods in the prior art are mainly based on the shortest path algorithm in graph theory, such as the Dijkstra algorithm. These solutions convert the connection problem between the nodes of the flowchart into the shortest path problem in graph theory, so as to find the connection that meets the orthogonal requirements. However, these methods still have shortcomings in dealing with the selection of multiple shortest paths, the processing of inflection points, and the aesthetics of the path.

[0005] For example, Chinese patent CN112985408B discloses a path planning optimization method and system. The path planning optimization method divides the path search area into multiple grid nodes, determines the position coordinates of the starting point, the target point and the obstacle point, and uses the A-star algorithm to determine the feasible grid node with the minimum total cost among all grid nodes in the layer as the new current node. Although the path planning optimization method expands the search range through the shortest path algorithm, increases the angle of the optional grid node and reduces the number of running steps, it still has the following defects:

[0006] 1. Dividing the path search area into multiple grid nodes, expanding the search range and increasing the angles of the optional grid nodes will increase the complexity of the algorithm, making it more difficult to implement and debug;

[0007] 2. Expanding the search range and increasing the angles of optional grid nodes will lead to increased memory consumption, especially when dealing with large-scale path planning problems, which may lead to insufficient memory;

[0008] 3. Increasing the angle of the optional grid nodes may make the path smoother, but in some cases it will sacrifice the accuracy of the path. A trade-off needs to be made between path smoothness and accuracy.

[0009] Currently, no effective solution has been proposed for the problems in the related technologies. Summary of the invention

[0010] In view of the problems in the related art, the present invention proposes a method for implementing orthogonal connection of flow chart nodes to overcome the above technical problems existing in the existing related art.

[0011] To this end, the specific technical solution adopted by the present invention is as follows:

[0012] A method for realizing orthogonal connection of flow chart nodes, the method comprising the following steps:

[0013] S1. Process the bounding boxes of the start node and the end node in the flowchart respectively to obtain the processed node position and boundary information;

[0014] S2. Based on the processed node positions and boundary information, the scale layer, grid layer and reference points of the flowchart are constructed in sequence, and an optimized grid route map is established according to the adjacent relationship between the reference points;

[0015] S3. Calculate the shortest path from the start node to the end node in the optimized grid route map, and extract the best orthogonal connection path from the shortest path calculation result.

[0016] Preferably, based on the processed node positions and boundary information, the scale layer, grid layer and reference points of the flowchart are sequentially constructed, and the optimized grid route map is established according to the adjacent relationship between the reference points, including the following steps:

[0017] S21, establishing a number of horizontal straight lines and vertical straight lines around the processed node positions, and combining the horizontal straight lines and the vertical straight lines to form a scale layer;

[0018] S22, defining a rectangular area covering the start node and the end node, and intersecting the rectangular area with the ruler layer to form a grid layer;

[0019] S23, adding reference points in each grid layer, and connecting the reference points in horizontal and vertical directions to generate a grid route map;

[0020] S24. Obtain the node density of each grid in the grid roadmap, and use an adaptive grid refinement algorithm to perform dynamic grid adjustment to obtain an optimized grid roadmap.

[0021] Preferably, the scale layer includes a straight line passing through the edge where the node position is located and parallel to the edge and a straight line passing through the anchor point and the pseudo anchor point;

[0022] Reference points include corner points of the mesh, midpoints of edges of internal meshes, center points of internal meshes, and midpoints of outward-facing edges of edge meshes.

[0023] Preferably, obtaining the node density of each grid in the grid roadmap, performing dynamic grid adjustment using an adaptive grid refinement algorithm, and obtaining an optimized grid roadmap comprises the following steps:

[0024] S241, estimating the node density of each grid in the grid route map by using a kernel density estimation algorithm, and dividing the grid into a refined grid and a coarse grid based on the node density estimation result;

[0025] S242, for the refined grid, divide the refined grid into several sub-grids, re-add reference points in each sub-grid, and update the adjacent relationship between the reference points; for the coarse grid, merge several adjacent coarse grids into a parent grid, and update the adjacent relationship between the reference points to ensure the coherence of the grid structure;

[0026] S243. Repeat step S242 until the node density of all grids is within the set threshold range, and obtain the final optimized grid roadmap.

[0027] Preferably, estimating the node density of each grid in the grid route map by using a kernel density estimation algorithm, and dividing the grid into a refined grid and a coarse grid based on the node density estimation result comprises the following steps:

[0028] S2411, collecting node coordinate data of each grid in the grid route map to form a node data set, and estimating the node density of each grid based on the kernel function and bandwidth parameter;

[0029] S2412, calculating the kernel density estimation value of the center point of each grid based on the node density of each grid;

[0030] S2413, fusing the kernel density estimation value to form a density matrix, and predicting the node density distribution of each grid in the grid route map based on the density matrix;

[0031] S2414. Set a refinement threshold and a coarsening threshold according to the node density distribution, compare the node density of each grid with the refinement threshold and the coarsening threshold respectively, and divide each grid in the grid roadmap into a refinement grid and a coarsening grid based on the comparison result.

[0032] Preferably, calculating the shortest path from the start node to the end node in the optimized grid route map, and extracting the best orthogonal connection path from the shortest path calculation result comprises the following steps:

[0033] S31, define and initialize a set S and a set U; add the starting node to the set S, and add the unprocessed nodes to the set U;

[0034] Among them, set S represents the set of vertices whose shortest paths have been determined, and set U represents the set of vertices whose shortest paths have not been determined;

[0035] S32, calculating the path distance between each node in the optimized grid route map, and using the improved Dijkstra algorithm to gradually update the shortest path from the start node to the end node in combination with the number and direction of the turning points in the path;

[0036] S33: Taking the shortest path from the starting node to the ending node as the best orthogonal connection path.

[0037] Preferably, calculating the path distance between each node in the optimized grid route map, and combining the number and direction of the turning points in the path, using the improved Dijkstra algorithm to gradually update the shortest path from the start node to the end node includes the following steps:

[0038] S321, obtaining a preset vertex A and a vertex B, and calculating the shortest path distance between the vertex A and the vertex B;

[0039] S322, based on the shortest path distance between vertex A and vertex B, remove vertex B with the shortest distance to vertex A from set U and add it to set S;

[0040] S323, obtaining vertices C and D adjacent to vertex B, and repeating step S322 in combination with the number and direction of inflection points in the path until all vertices are processed, thereby obtaining the shortest path from the starting node to the ending node.

[0041] Preferably, obtaining vertices C and D adjacent to vertex B, and repeatedly executing step S322 in combination with the number and direction of inflection points in the path until all vertices are processed, and obtaining the shortest path from the starting node to the ending node includes the following steps:

[0042] S3231, obtaining vertex C and vertex D adjacent to vertex B, and calculating path distances from vertex B to vertex C and vertex D respectively;

[0043] S3232, determining whether the direction of the line between vertex B and vertex C and vertex D is consistent with the direction of the line between vertex A and vertex B;

[0044] S3233. If the connection directions are inconsistent, an additional weight is added and the path distance of vertex C in set U is updated at the same time; if the connection directions are consistent, the additional weight is 0 and the path distance of vertex D in set U is updated at the same time;

[0045] S3234, remove the vertex D with the shortest path distance to vertex A in the updated set U and add it to the set S;

[0046] S3235, remove the vertex C in the updated set U and add it to the set S, and update the path distance of the vertex E adjacent to the vertex C;

[0047] S3236. Remove vertex E from the updated set U and add it to the set S to obtain the shortest distance from vertex A to each vertex, and generate the shortest path from the starting node to the ending node.

[0048] Preferably, the calculation formula for the shortest path distance between vertex A and vertex B is:

[0049] ;

[0050] Where d represents the shortest path distance between vertex A and vertex B;

[0051] (x1, y1) represents the coordinates of vertex A;

[0052] (x2, y2) represents the coordinates of vertex B.

[0053] Preferably, the expression of the additional weight is:

[0054] ;

[0055] In the formula, extraWeight represents the additional weight;

[0056] edgeDistance represents the shortest path distance from the current vertex to the remaining vertices.

[0057] The beneficial effects of the present invention are:

[0058] 1. The present invention improves the Dijkstra algorithm and comprehensively considers factors such as path length, number of inflection points, overlap between lines and node boundaries, and lines crossing nodes, so as to generate more beautiful and standardized orthogonal lines of flowchart nodes. Compared with traditional methods, the readability and aesthetics of flowcharts are significantly improved, so that flowcharts can more intuitively display process logic and improve user experience.

[0059] 2. The present invention determines all possible orthogonal connection paths between nodes by introducing the scale layer and the grid layer, providing a solid foundation for subsequent path selection. This mechanism not only ensures the diversity of path selection, but also enables the algorithm to more accurately find the best path that meets the requirements, thereby achieving higher flexibility and accuracy in path selection.

[0060] 3. In the process of path selection, the present invention sets rules to avoid the overlap of connection lines with node boundaries and prevents connection lines from crossing nodes, thereby further improving the aesthetics and standardization of the flowchart, effectively avoiding problems such as connection confusion and node occlusion that may occur in traditional methods, making the flowchart clearer and easier to read. At the same time, by giving priority to paths with fewer inflection points, the complexity of the connection is reduced, and the overall aesthetics of the flowchart is improved, which not only makes the flowchart more concise and clear, but also helps users quickly understand and analyze the process logic and improve work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0062] Figure 1 is a flow chart of a method for implementing orthogonal connection of flow chart nodes according to an embodiment of the present invention;

[0063] Figure 2 It is a schematic diagram of node expansion in a method for realizing orthogonal connection of flow chart nodes according to an embodiment of the present invention;

[0064] Figure 3 is a schematic diagram of a ruler layer in a method for implementing orthogonal connection of flow chart nodes according to an embodiment of the present invention;

[0065] Figure 4 is a schematic diagram of a grid layer in a method for implementing orthogonal connection of flow chart nodes according to an embodiment of the present invention;

[0066] Figure 5 is a schematic diagram of reference points in a method for implementing orthogonal connection of flow chart nodes according to an embodiment of the present invention;

[0067] Figure 6 It is a schematic diagram of a grid route map in a method for implementing orthogonal connection of flow chart nodes according to an embodiment of the present invention;

[0068] Figure 7 It is a schematic diagram of an abstracted grid route map in a method for realizing orthogonal connection of flow chart nodes according to an embodiment of the present invention;

[0069] Figure 8 The present invention is a flowchart of an improved Dijkstra algorithm for finding the shortest path in a method for realizing orthogonal connection of flowchart nodes according to an embodiment of the present invention. DETAILED DESCRIPTION

[0070] To further illustrate each embodiment, the present invention provides drawings, which are part of the disclosure of the present invention and are mainly used to illustrate the embodiments. They can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementation methods and advantages of the present invention.

[0071] According to an embodiment of the present invention, a method for implementing orthogonal connection of flow chart nodes is provided.

[0072] The present invention aims to solve the problem of unreasonable path selection in the existing flowchart drawing technology when realizing orthogonal node connections. In flowchart drawing, the connection between nodes not only needs to realize functional connection, but also needs to consider aesthetics and standardization. However, the existing technology often only focuses on the functional realization of the connection, but does not give enough consideration to the aesthetics and standardization of the connection. Especially in the case of orthogonal connections, how to reasonably select the path, avoid the connection and the node boundary overlap, and prevent the connection from crossing the node, etc., has become a technical problem that needs to be solved urgently.

[0073] In addition, the present invention aims to solve the limitations of the existing Dijkstra algorithm in the application of orthogonal connections of flowchart nodes. Although the Dijkstra algorithm can find the shortest path between two nodes, when dealing with the problem of orthogonal connections of flowchart nodes, it does not take into account aesthetic factors such as the number of inflection points of the path, the overlap between the connection and the node boundary, and the connection crossing the node. Therefore, it is necessary to improve the Dijkstra algorithm so that it can comprehensively consider these factors to generate more beautiful and standardized orthogonal connections.

[0074] The present invention aims to solve the problem of unreasonable path selection in the existing flowchart drawing technology when realizing orthogonal connection of nodes, and the limitations of the existing Dijkstra algorithm in the application of orthogonal connection of flowchart nodes, and provide a method for realizing orthogonal connection of flowchart nodes to improve the aesthetics and standardization of flowcharts.

[0075] The present invention is further described with reference to the accompanying drawings and specific embodiments. Figure 1 As shown, according to a flowchart node orthogonal connection method of an embodiment of the present invention, the flowchart node orthogonal connection method comprises the following steps:

[0076] S1. Process (expand) the bounding boxes of the start node and the end node in the flowchart respectively to obtain the processed node position and boundary information.

[0077] It should be noted that if Figure 2As shown, the present invention first expands the bounding boxes of the starting node and the ending node, that is, the bounding boxes need to be expanded outward by a certain distance. This range can be set according to actual needs. For example, a fixed pixel value can be set as the expansion radius. The purpose of expanding the bounding boxes of the starting node and the ending node is to ensure that there is enough spacing between the connection line and the node to avoid the connection line and the node being too close or overlapping.

[0078] S2. Based on the processed node positions and boundary information, the scale layer, grid layer and reference points of the flowchart are constructed in sequence, and an optimized grid route map is established according to the adjacent relationship between the reference points.

[0079] Among them, the ruler layer includes straight lines passing through the edge where the node position is located and parallel to the edge, and straight lines passing through anchor points and pseudo anchor points; reference points include corner points of the grid, midpoints of the edges of the internal grid, center points of the internal grid, and midpoints of the edges of the edge grid facing outward.

[0080] Among them, based on the processed node positions and boundary information, the scale layer, grid layer and reference points of the flowchart are constructed in sequence, and the optimized grid route map is established according to the adjacent relationship between the reference points, including the following steps:

[0081] S21. Establish a number of horizontal straight lines and vertical straight lines around the processed node positions, and combine the horizontal straight lines and vertical straight lines to form a scale layer.

[0082] It should be noted that the ruler layer is composed of a series of horizontal and vertical straight lines, including straight lines passing through the edges where the nodes are located and parallel to the edges, as well as straight lines passing through anchor points and pseudo anchor points. The introduction of the ruler layer is crucial, as it provides a solid benchmark and precise reference for the subsequent grid layer construction; the ruler layer can be used to divide the space into Figure 3 The grid divided by dotted lines shown in the figure provides a clear structure and framework for subsequent path planning.

[0083] S22. Define a rectangular area covering the start node and the end node, and intersect the rectangular area with the ruler layer to form a grid layer.

[0084] It should be noted that the grid layer refers to a specific rectangular area that covers both the start node and the end node and intersects with the ruler layer to form many small grids. The construction of the grid layer can limit the search range to a limited area, thereby greatly improving the efficiency of finding the best path. The grid layer is presented as a series of grid areas obtained by the intersection and segmentation of the gray rectangular area and the ruler layer, such as Figure 4 As shown in the figure, its structure is clear and the levels are distinct, which provides strong support for subsequent path planning.

[0085] S23. Add reference points in each grid layer, and connect the reference points in horizontal and vertical directions to generate a grid route map.

[0086] It should be noted that reference points are added according to different types of grids. These reference points include the corner points of the grid, the edge midpoints and center points of the internal grid, and the midpoints of the edges of the edge grid facing outwards. At the same time, in order to avoid overlap with the edges of the nodes, the present invention cleverly excludes points that overlap with the edges of the nodes. The addition of these reference points not only enriches the amount of information in the grid, but also provides indispensable support for the subsequent grid route drawing, such as Figure 5 As shown in the figure, the layout of reference points is reasonable and accurate, which provides a strong basis for path planning.

[0087] It should be noted that the present invention skillfully draws grid routes based on the adjacent relationship between reference points. Specifically, the previously determined reference points are connected one by one in the horizontal and vertical directions to construct a complete grid route map. These routes are not only potential connection solutions, but also provide rich possibilities for subsequent path selection, such as Figure 6 As shown in the figure, the grid route map is not only accurate, but also clearly structured and easy to understand, laying a solid foundation for subsequent path planning.

[0088] S24. Obtain the node density of each grid in the grid roadmap, and use an adaptive grid refinement algorithm to perform dynamic grid adjustment to obtain an optimized grid roadmap.

[0089] The following steps are included in the process of obtaining the node density of each grid in the grid roadmap, performing dynamic grid adjustment using an adaptive grid refinement algorithm, and obtaining an optimized grid roadmap:

[0090] S241. Estimate the node density of each grid in the grid roadmap using a kernel density estimation algorithm, and divide the grid into a refined grid and a coarse grid based on the node density estimation result.

[0091] The node density of each grid in the grid roadmap is estimated by using a kernel density estimation algorithm, and the grid is divided into a fine grid and a coarse grid based on the node density estimation result, including the following steps:

[0092] S2411, collecting node coordinate data of each grid in the grid route map to form a node data set, and estimating the node density of each grid based on the kernel function and bandwidth parameter;

[0093] S2412, calculating the kernel density estimation value of the center point of each grid based on the node density of each grid;

[0094] S2413, fusing the kernel density estimation value to form a density matrix, and predicting the node density distribution of each grid in the grid route map based on the density matrix;

[0095] S2414. Set a refinement threshold and a coarsening threshold according to the node density distribution, compare the node density of each grid with the refinement threshold and the coarsening threshold respectively, and divide each grid in the grid roadmap into a refinement grid and a coarsening grid based on the comparison result.

[0096] S242, for the refined grid, divide the refined grid into several sub-grids, re-add reference points in each sub-grid, and update the adjacent relationship between the reference points; for the coarse grid, merge several adjacent coarse grids into a parent grid, and update the adjacent relationship between the reference points to ensure the coherence of the grid structure;

[0097] S243. Repeat step S242 until the node density of all grids is within the set threshold range, and obtain the final optimized grid roadmap.

[0098] It should be noted that the refinement process can ensure that the grid in the high-density area is more detailed and more accurately represents the complex node distribution, thereby improving the accuracy of path planning. After the grid is refined in the dense area, the number of nodes in each grid unit is reduced, so that the subsequent path planning algorithm can find the optimal path more accurately and avoid the path deviation caused by the coarse grid.

[0099] Grid coarsening in low-density areas can reduce the amount of calculation and improve the efficiency of the path planning algorithm. By merging grid cells in sparse areas, the number of grids and nodes is reduced, thereby reducing the scale of data that needs to be processed during the path planning process, saving computing resources and time.

[0100] The adaptive mesh refinement algorithm can dynamically adjust the degree of mesh refinement and coarsening to adapt to changes in node distribution in actual applications. Through continuous iterative refinement and coarsening operations, the mesh can reflect changes in node distribution in real time, ensuring efficient and accurate path planning when node density changes.

[0101] S3. Calculate the shortest path from the start node to the end node in the optimized grid route map, and extract the best orthogonal connection path from the shortest path calculation result.

[0102] It should be noted that orthogonal lines refer to an algorithm for connecting lines in geometric figures according to the direction of the coordinate axes in a rectangular coordinate system. The characteristic of this connection method is that the line segments must be orthogonal, that is, the angle between the line segments is 90 degrees. Orthogonal lines are widely used in many fields, such as computer graphics, CAD / CAM, etc., to generate geometric shapes such as straight lines, rectangles, polygons, etc.

[0103] It should be noted that in order to obtain the best orthogonal connection path from the starting point A to the end point E, the shortest path search process based on the grid roadmap needs to be highly abstracted. In this problem, the starting point A is set as the starting node, and the end point E is set as the ending node. Through this transformation, the orthogonal path problem from the starting point A to the end point E is essentially transformed into the problem of calculating the shortest path between two points. This process not only simplifies the complexity of the problem, but also makes it more efficient to find the optimal orthogonal connection path from the starting point to the end point. The abstracted grid roadmap is as follows: Figure 7 shown.

[0104] The steps of calculating the shortest path from the start node to the end node in the optimized grid route map and extracting the best orthogonal connection path from the shortest path calculation result include the following steps:

[0105] S31. Define and initialize set S and set U; add the starting node to set S, and add the unprocessed nodes to set U.

[0106] Define set S and set U, where set S represents the set of vertices for which the shortest path has been determined, set U represents the set of vertices for which the shortest path has not been determined, and A(4) means that the shortest distance from vertex A to the starting point is 4.

[0107] It should be noted that the set S and the set U are initialized, the shortest distance of the starting node is set to 0, the shortest distances of other nodes are set to infinity (∞), and the starting node is marked as the current node. The expressions of the set S and the set U are as follows:

[0108] ;

[0109] ;

[0110] S32. Calculate the path distance between each node in the optimized grid route map, and use the improved Dijkstra algorithm to gradually update the shortest path from the start node to the end node based on the number and direction of the turning points in the path.

[0111] It should be noted that the Dijkstra algorithm is also called the Dijkstra algorithm. It is a classic algorithm for solving the shortest path from a single source point to all other vertices in a weighted directed graph. It is based on the greedy idea and gradually expands the set of vertices for which the shortest path has been found until all vertices are traversed, thereby obtaining the shortest path from the source point to all vertices.

[0112] The Dijkstra algorithm is a greedy algorithm for solving the single-source shortest path problem in a weighted directed graph. The basic idea of ​​the algorithm includes: starting from the starting point, each time selecting the vertex with the shortest distance from the unvisited vertices, and then updating the distances of its adjacent vertices, and repeating this process until all vertices have been visited. The main improvement of the present invention is that when calculating the shortest distance, it is determined whether an additional weight extraWeight needs to be added according to whether there is an inflection point in the path. The calculation process of the improved Dijkstra includes:

[0113] Initialization phase: create a distance array dist, in which the distance from the starting node s to itself is 0, and the distances from other nodes to the starting node are infinite; use the minimum heap structure to initialize the priority queue Q, and add all nodes and their initial distances to it; initialize an empty set S to store the nodes whose shortest paths have been determined.

[0114] Main loop phase: When the priority queue Q is not empty, select the node u with the smallest distance from it; remove node u from Q and add it to the set S; traverse all adjacent nodes v of node u, if v is not in the set S, calculate the distance alt from the starting node s to node v through node u; if alt is less than the currently recorded dist[v], update dist[v] and update the priority of node v in the priority queue.

[0115] End of the loop: When the priority queue Q is empty, the algorithm ends and returns the distance array dist, which contains the shortest path distances from the starting node s to all other nodes.

[0116] Among them, the path distance between each node is calculated in the optimized grid route map, and the number and direction of the turning points in the path are combined to gradually update the shortest path from the starting node to the ending node using the improved Dijkstra algorithm, including the following steps:

[0117] S321. Obtain preset vertex A and vertex B, and calculate the shortest path distance between vertex A and vertex B.

[0118] It should be noted that, assuming there are two points, point A and point B, their coordinates are recorded as A (x1, y1) and B (x2, y2) respectively. In order to determine the distance between the two points, their coordinate values ​​can be used for calculation. The specific calculation formula can accurately reflect the straight-line distance between the two points and provide an effective means to quantify the spatial relationship between the two points. The calculation formula can quickly and accurately obtain the distance between points A and B. Among them, the calculation formula for the shortest path distance between vertex A and vertex B is:

[0119] ;

[0120] Where d represents the shortest path distance between vertex A and vertex B;

[0121] (x1, y1) represents the coordinates of vertex A;

[0122] (x2, y2) represents the coordinates of vertex B.

[0123] S322. Based on the shortest path distance between vertex A and vertex B, remove vertex B having the shortest distance to vertex A from set U and add it to set S.

[0124] It should be noted that at this time, the vertex with the shortest distance to vertex A in set U is B (1), and B is added to the combination S, and B is removed from set U, and the distances of the vertices adjacent to vertex B in set U are updated. The Dijkstra algorithm calculates the distance by adding the distance of vertex B to the distance from each vertex to vertex B. The present invention improves the Dijkstra algorithm in order to minimize the number of inflection points in the path. When the direction of the line pointing to vertex B is inconsistent with the direction of the line between the vertex to be calculated and vertex B, an extra weight is added when calculating the distance, which is recorded as extraWeight.

[0125] S323, obtaining vertices C and D adjacent to vertex B, and repeating step S322 in combination with the number and direction of inflection points in the path until all vertices are processed, thereby obtaining the shortest path from the starting node to the ending node.

[0126] Among them, obtaining vertices C and D adjacent to vertex B, and repeatedly executing step S322 in combination with the number and direction of inflection points in the path until all vertices are processed, and obtaining the shortest path from the starting node to the ending node includes the following steps:

[0127] S3231, obtaining vertex C and vertex D adjacent to vertex B, and calculating path distances from vertex B to vertex C and vertex D respectively;

[0128] S3232, determining whether the direction of the line between vertex B and vertex C and vertex D is consistent with the direction of the line between vertex A and vertex B;

[0129] S3233. If the connection directions are inconsistent, an additional weight is added and the path distance of vertex C in set U is updated at the same time; if the connection directions are consistent, the additional weight is 0 and the path distance of vertex D in set U is updated at the same time;

[0130] S3234, remove the vertex D with the shortest path distance to vertex A in the updated set U and add it to the set S;

[0131] S3235, remove the vertex C in the updated set U and add it to the set S, and update the path distance of the vertex E adjacent to the vertex C;

[0132] S3236. Remove vertex E from the updated set U and add it to the set S to obtain the shortest distance from vertex A to each vertex, and generate the shortest path from the starting node to the ending node.

[0133] S33: Taking the shortest path from the starting node to the ending node as the best orthogonal connection path.

[0134] It should be noted that if Figure 8 As shown in the figure, taking two vertices C and D adjacent to vertex B as an example, the direction of the line from vertex A to vertex B is horizontal, and the direction of the line from vertex B to vertex D is also horizontal, and the two directions are consistent, so extraWeight=0, while the direction of the line from vertex B to vertex C is vertical, and the directions of the two lines are inconsistent, so additional weights need to be added, where edgeDistance represents the shortest path distance from the current vertex to the remaining vertices, and its calculation method is as follows:

[0135] ;

[0136] In the formula, extraWeight represents the additional weight;

[0137] edgeDistance represents the shortest path distance from the current vertex to the remaining vertices.

[0138] At this time, the distance from vertex C to vertex A needs to consider additional weights, and the distance is (A, B) + (B, C) = 1 + (2 + 1) 2 =10, which is less than the previous distance from vertex C to vertex A∞, so the distance of vertex C in set U needs to be updated. The distance from vertex D to vertex A does not need to add additional weight. The distance is (A, B) + (B, D) = 1 + 3 = 4, which is less than the previous distance from vertex D to vertex A∞, so the distance of vertex D in set U needs to be updated. The expression is as follows:

[0139] ;

[0140] ;

[0141] After the update, the vertex D in set U has the shortest distance to vertex A. D is added to S and removed from set U. At this time, the only vertex adjacent to D is vertex E. Because the directions from B to D and from D to E are inconsistent, additional weights need to be added. Therefore, the distance from A to E is (A, D) + (D, E) = 4 + (4 + 1) 2 =29, less than infinity ( ), so the distance of E in the updated set U is E(29), and the updated results are as follows:

[0142] ;

[0143] ;

[0144] Remove the vertex C with the shortest distance in set U from set U and add it to set S. Update the distance of vertex E adjacent to vertex C. At this time, the direction from B to C is inconsistent with that from C to E, so the distance from A to E is (A, C) + (C + E) = 10 + (1 + 1) 2 =14, which is less than the original distance 29. The distance of E in the updated set U is E(14). The updated results are as follows:

[0145] ;

[0146] ;

[0147] Finally, there is only one vertex E left in the set U. Remove it from U and add it to the set S to get the shortest distance from vertex A to each vertex:

[0148] ;

[0149] Therefore, we can finally conclude that the shortest path from vertex A to vertex E is 14, and the path direction is A>B>C>E.

[0150] It should be noted that the present invention improves the Dijkstra algorithm so that it can comprehensively consider factors such as path length, number of inflection points, overlap between lines and node boundaries, and line crossing nodes when solving the shortest path. This improvement makes the algorithm more in line with actual needs when solving the orthogonal line problem of flowchart nodes, and improves the aesthetics and standardization of the lines. The present invention determines all possible orthogonal line paths between nodes by introducing a scale layer and a grid layer, and performs path selection based on the improved Dijkstra algorithm. This mechanism can ensure that the selected path functionally realizes the connection between nodes, and is more beautiful and standardized visually. In the process of path selection, the present invention sets rules to avoid the overlap of lines with node boundaries and prevents lines from crossing nodes, thereby improving the overall aesthetics of the flowchart. In addition, by giving priority to paths with fewer inflection points, the readability and ease of use of the flowchart are further improved.

[0151] In summary, with the help of the above technical solution of the present invention, the present invention improves the Dijkstra algorithm and comprehensively considers factors such as path length, number of inflection points, overlap between lines and node boundaries, and lines crossing nodes, so as to generate more beautiful and standardized orthogonal lines of flowchart nodes. Compared with the traditional method, the readability and aesthetics of the flowchart are significantly improved, so that the flowchart can more intuitively display the process logic and improve the user experience; the present invention determines all possible orthogonal connection paths between nodes by introducing a ruler layer and a grid layer, which provides a solid foundation for subsequent path selection. This mechanism not only ensures the diversity of path selection, but also makes The algorithm can more accurately find the best path that meets the requirements, thereby achieving higher flexibility and accuracy in path selection; in the process of path selection, the present invention sets rules to avoid the overlap of connections with node boundaries and prevents connections from crossing nodes, thereby further improving the aesthetics and standardization of the flowchart, and effectively avoiding problems such as connection confusion and node occlusion that may occur in traditional methods, making the flowchart clearer and easier to read. At the same time, by giving priority to paths with fewer inflection points, the complexity of the connections is reduced, and the overall aesthetics of the flowchart is improved, which not only makes the flowchart more concise and clear, but also helps users quickly understand and analyze the process logic and improve work efficiency.

[0152] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for realizing orthogonal connection of flow chart nodes, characterized in that: The method for realizing orthogonal connection of flow chart nodes comprises the following steps: S1. Process the bounding boxes of the start node and the end node in the flowchart respectively to obtain the processed node position and boundary information; S2. Based on the processed node positions and boundary information, the scale layer, grid layer and reference points of the flowchart are constructed in sequence, and an optimized grid route map is established according to the adjacent relationship between the reference points; S3, calculating the shortest path from the start node to the end node in the optimized grid route map, and extracting the best orthogonal connection path from the shortest path calculation result; The process of sequentially constructing the scale layer, grid layer and reference points of the flowchart based on the processed node positions and boundary information, and establishing an optimized grid route map according to the adjacent relationship between the reference points includes the following steps: S21, establishing a number of horizontal straight lines and vertical straight lines around the processed node positions, and combining the horizontal straight lines and the vertical straight lines to form a scale layer; S22, defining a rectangular area covering the start node and the end node, and intersecting the rectangular area with the ruler layer to form a grid layer; S23, adding reference points in each grid layer, and connecting the reference points in horizontal and vertical directions to generate a grid route map; S24, obtaining the node density of each grid in the grid route map, performing dynamic grid adjustment using an adaptive grid refinement algorithm, and obtaining an optimized grid route map; The scale layer includes a straight line passing through the edge where the node is located and parallel to the edge and a straight line passing through the anchor point and the pseudo anchor point; The reference points include corner points of the grid, midpoints of edges of the internal grid, center points of the internal grid, and midpoints of outward-facing sides of the edge grid.

2. A method for realizing orthogonal connection of flow chart nodes according to claim 1, characterized in that: The step of obtaining the node density of each grid in the grid roadmap and performing dynamic grid adjustment using an adaptive grid refinement algorithm to obtain an optimized grid roadmap comprises the following steps: S241, estimating the node density of each grid in the grid route map by using a kernel density estimation algorithm, and dividing the grid into a refined grid and a coarse grid based on the node density estimation result; S242, for the refined grid, divide the refined grid into several sub-grids, re-add reference points in each sub-grid, and update the adjacent relationship between the reference points; for the coarse grid, merge several adjacent coarse grids into a parent grid, and update the adjacent relationship between the reference points to ensure the coherence of the grid structure; S243, repeating step S242 until the node density of all grids is within the set threshold range, and obtaining the final optimized grid roadmap.

3. A method for realizing orthogonal connection of flow chart nodes according to claim 2, characterized in that: The method of estimating the node density of each grid in the grid roadmap by using a kernel density estimation algorithm and dividing the grid into a refined grid and a coarse grid based on the node density estimation result comprises the following steps: S2411, collecting node coordinate data of each grid in the grid route map to form a node data set, and estimating the node density of each grid based on the kernel function and bandwidth parameter; S2412, calculating the kernel density estimation value of the center point of each grid based on the node density of each grid; S2413, fusing the kernel density estimation value to form a density matrix, and predicting the node density distribution of each grid in the grid route map based on the density matrix; S2414. Set a refinement threshold and a coarsening threshold according to the node density distribution, compare the node density of each grid with the refinement threshold and the coarsening threshold respectively, and divide each grid in the grid roadmap into a refinement grid and a coarsening grid based on the comparison result.

4. A method for realizing orthogonal connection of flow chart nodes according to claim 3, characterized in that: The method of calculating the shortest path from the starting node to the ending node in the optimized grid route map and extracting the best orthogonal connection path from the shortest path calculation result comprises the following steps: S31, define and initialize a set S and a set U; add the starting node to the set S, and add the unprocessed nodes to the set U; The set S represents the set of vertices whose shortest paths have been determined, and the set U represents the set of vertices whose shortest paths have not been determined; S32, calculating the path distance between each node in the optimized grid route map, and using the improved Dijkstra algorithm to gradually update the shortest path from the start node to the end node in combination with the number and direction of the turning points in the path; S33: Taking the shortest path from the starting node to the ending node as the best orthogonal connection path.

5. A method for realizing orthogonal connection of flow chart nodes according to claim 4, characterized in that: The method of calculating the path distance between nodes in the optimized grid route map and gradually updating the shortest path from the start node to the end node using the improved Dijkstra algorithm in combination with the number and direction of the turning points in the path includes the following steps: S321, obtaining a preset vertex A and a vertex B, and calculating the shortest path distance between the vertex A and the vertex B; S322, based on the shortest path distance between vertex A and vertex B, remove vertex B with the shortest distance to vertex A from set U and add it to set S; S323, obtaining vertices C and D adjacent to vertex B, and repeating step S322 in combination with the number and direction of inflection points in the path until all vertices are processed, thereby obtaining the shortest path from the starting node to the ending node.

6. A method for realizing orthogonal connection of flow chart nodes according to claim 5, characterized in that: The process of obtaining vertices C and D adjacent to vertex B, and repeatedly executing step S322 in combination with the number and direction of inflection points in the path until all vertices are processed, and obtaining the shortest path from the starting node to the ending node includes the following steps: S3231, obtaining vertex C and vertex D adjacent to vertex B, and calculating path distances from vertex B to vertex C and vertex D respectively; S3232, determining whether the direction of the line between vertex B and vertex C and vertex D is consistent with the direction of the line between vertex A and vertex B; S3233. If the connection directions are inconsistent, an additional weight is added and the path distance of vertex C in set U is updated at the same time; if the connection directions are consistent, the additional weight is 0 and the path distance of vertex D in set U is updated at the same time; S3234, remove the vertex D with the shortest path distance to vertex A in the updated set U and add it to the set S; S3235, remove the vertex C in the updated set U and add it to the set S, and update the path distance of the vertex E adjacent to the vertex C; S3236. Remove vertex E from the updated set U and add it to the set S to obtain the shortest distance from vertex A to each vertex, and generate the shortest path from the starting node to the ending node.

7. A method for realizing orthogonal connection of flow chart nodes according to claim 6, characterized in that: The calculation formula of the shortest path distance between vertex A and vertex B is: ; In the formula, d Represents a vertex A and vertices B The shortest path distance between ( x 1, y 1) Representing vertices A The coordinates of ( x 2, y 2) Representing vertices B The coordinates of .

8. A method for realizing orthogonal connection of flow chart nodes according to claim 7, characterized in that: The expression of the additional weight is: ; In the formula, extraWeight represents additional weight; edgeDistance Indicates the shortest path distance from the current vertex to the remaining vertices.

Citation Information

Patent Citations

  • A path planning optimization method and system

    CN112985408B

  • Node connection line generation method and device, apparatus and storage medium

    CN110675471A

  • Path planning optimization method and system

    CN112985408A

Cited By

  • Adjacent point calculation-based CAD (Computer Aided Design) connection path selection method and system

    CN121682927A