A graph data force-directed layout acceleration method, computer and storage medium
Patent Information
- Application Number
- CN202611528694.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-30
- Publication Date
- 2026-11-03
AI Technical Summary
Existing force-directed layout algorithms have high computational complexity for repulsion calculations in large-scale graph data visualization, making it difficult to meet real-time interaction requirements. This is especially true when dynamic graph data is updated, leading to stuttering and response delays. Existing optimization methods are inefficient and have large errors when implemented on GPUs.
By employing uniform spatial grid partitioning and connected component identification, and through local repulsion pruning and spring force synthesis, the computational complexity of repulsion is reduced to O(N·k), and parallel execution is achieved using GPUs to adapt to dynamic interactive scenarios.
It significantly reduces the amount of repulsion calculations for graph data of tens of thousands, improves the frame rate and layout stability of dynamic interactions, and maintains layout quality and real-time response capabilities.
Smart Images

Figure CN123031291A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer graphics technology, and in particular to a graph data force-oriented layout acceleration method, a computer, and a storage medium. Background Technology
[0002] With the rapid development of fields such as social network analysis, bioinformatics, knowledge graphs, cybersecurity, and software engineering, the scale of graph data has exploded, with the number of nodes reaching tens of thousands or even hundreds of thousands. Graph data visualization, by mapping relational networks to node-link graphs, helps analysts understand complex community structures, critical paths, and anomalous connections, and has become an indispensable analytical tool in these fields. Force-directed placement algorithms, due to their intuitive physical metaphors (treating nodes as charged particles and edges as springs), good universality for general graphs, and ease of extension, have been one of the most mainstream placement methods for graph visualization since Eades proposed them in 1984.
[0003] The core of force-directed layout algorithms lies in minimizing system energy through iterative calculations, with repulsion calculations playing a dominant role. In classic Fruchterman-Reingold or ForceAtlas2 models, repulsion requires enumerating all node pairs, resulting in a time complexity of O(N²), where N is the number of nodes. When N reaches tens of thousands or more, the amount of repulsion calculation in a single iteration reaches hundreds of millions, making the computational load extremely heavy even in dynamic interactive scenarios where only a few iterations are performed per frame. Although modern GPUs offer powerful parallel computing capabilities, migrating repulsion calculations from the CPU to the GPU and utilizing large-scale thread parallel processing, the asymptotic complexity of O(N²) remains unchanged. As the number of nodes increases, the frame time will still quickly exceed the budget acceptable for real-time interaction, making it difficult to stably maintain a frame rate of over 30 frames per second.
[0004] To address the high complexity of repulsion calculation in force-directed layouts, existing optimization methods mainly include approximation algorithms based on spatial hierarchical structures, with the Barnes-Hut algorithm being a representative example. This method recursively divides the space into hierarchical units by constructing a quadtree (two-dimensional) or an octree (three-dimensional). For each node, when the distance between the entire tree unit and that node meets a threshold condition, the centroid and total mass of that unit are used to equivalently replace the repulsion contribution of all its internal nodes to that node, thereby reducing the computational complexity of repulsion from O(N²) to O(N log N). However, this type of method has significant shortcomings in practical applications: First, the construction of a quadtree or octree requires recursively traversing all nodes and determining the tree structure. When implemented on a GPU, this results in issues such as thread divergence and low stack operation efficiency, making it difficult to fully utilize the SIMT parallel architecture. Second, when the graph data is dynamically updated (e.g., node positions change every frame), the tree structure needs to be completely reconstructed. The reconstruction overhead is proportional to the node size, further weakening the real-time performance. Finally, this type of method alters the precise expression of repulsion, which may introduce unacceptable errors in scenarios sensitive to layout quality.
[0005] Furthermore, existing optimization methods are mostly designed for offline static layout scenarios, failing to fully consider the special needs of dynamic interactive scenarios. In real-time interactive graph visualization, users frequently perform operations such as dragging, filtering, and focusing, requiring the layout to be continuously updated with each user interaction. If the repulsion calculation cannot be completed within the frame budget, it will directly lead to screen stuttering and response delays, disrupting the user's continuous understanding of structural relationships. Summary of the Invention
[0006] To address the shortcomings of existing technologies, the present invention aims to provide a graph data force-directed layout acceleration method, computer, and storage medium, with the goal of significantly reducing the time complexity of repulsion calculation in force-directed layout while ensuring layout quality, and making it suitable for GPU parallel execution and dynamic interaction scenarios.
[0007] To achieve the above objectives, in a first aspect, the present invention provides: a graph data force-oriented layout acceleration method, comprising the following steps: Obtain the graph data to be laid out, the graph data includes a set of nodes and a set of edges, each node has a position vector in the layout space, and determine the connected component identifier corresponding to each node; A uniform spatial grid is constructed based on the current position vector of each node, each node is divided into corresponding grid cells, and a mapping relationship between the grid cells and the nodes is established. For each target node, a set of neighborhood units corresponding to the target node is determined according to a preset repulsive force action distance threshold, and only other nodes in the set of neighborhood units are enumerated as candidate interaction nodes. Based on the connected component identifiers corresponding to the target node and each candidate interaction node, as well as the spatial distance between them, local repulsive pruning is performed on the candidate interaction nodes, and the repulsive force contribution between the target node and the remaining candidate interaction nodes after pruning is calculated to obtain the repulsive force on the target node. The spring force on the target node is calculated based on the edge connected to the target node in the edge set. The repulsive force and the spring force are combined, and the position vector of the target node is updated based on the combination result. The uniform spatial grid is reconstructed based on the updated position vectors, and the layout iteration continues until the preset termination condition is met. The position vectors of each node are then output for graph data visualization rendering.
[0008] According to one aspect of the above technical solution, the steps for determining the connected component identifiers corresponding to each node specifically include: Configure a node index for each node in the node set to uniquely identify the corresponding node; Obtain the topological structure information of the graph data, which includes the total number of nodes, the total number of edges, and the node indices corresponding to the two endpoints of each edge; The graph data is parsed and structurally transformed to obtain a standardized data structure including a node array, an edge array, and adjacency relationship data. The adjacency relationship data is stored in an adjacency list or a compressed sparse row format. Perform at least one of the following preprocessing steps on the graph data: isolated node removal, self-loop edge filtering, duplicate edge merging, and multi-edge weight aggregation; The initial position vector of each node is determined by one of the following methods: random initialization, mesh initialization, or circular layout initialization. The node degree of each node and the resultant force of the previous round used for position update are also determined. Based on the topology of the graph data, the connected component identifiers corresponding to each node are determined by a breadth-first search algorithm or a disjoint-set data structure algorithm. When two nodes have the same connected component identifier, it means that the two nodes belong to the same connected component.
[0009] According to one aspect of the above technical solution, the step of constructing a uniform spatial grid based on the current position vector of each node specifically includes: The minimum and maximum coordinates of each node in each coordinate dimension are obtained to determine the bounding box of the layout space. Set the side length of the grid cell of the uniform spatial grid to the threshold value of the repulsive force action distance; The number of grid cells in the corresponding coordinate dimension is determined based on the ratio of the bounding box span to the side length of the grid cell in each coordinate dimension. Divide the difference between the node's position coordinates in the corresponding coordinate dimension and the minimum coordinate in that coordinate dimension by the side length of the grid cell to obtain the integer index of the node in the corresponding coordinate dimension. Boundary constraints are applied to the integer indices to ensure that they fall within the valid index range of the corresponding coordinate dimension, and the integer indices in each coordinate dimension are combined to form the grid cell index of the corresponding node's grid cell.
[0010] According to one aspect of the above technical solution, the step of determining the neighborhood unit set corresponding to the target node specifically includes: Obtain the grid cell index of the grid cell to which the target node belongs; The grid cells whose absolute difference between the integer index of each coordinate dimension and the corresponding integer index of the grid cell to which the target node belongs is not greater than 1 are determined as the neighborhood cells corresponding to the target node. The neighborhood cells located at the bounding box boundary of the layout space are truncated, and only the neighborhood cells located within the effective index range of the uniform spatial grid are retained, thereby obtaining the neighborhood cell set.
[0011] According to one aspect of the above technical solution, the step of establishing the mapping relationship between the mesh cells and nodes specifically includes: In the video memory of the graphics processor, a grid cell head buffer and a next node index buffer are set. The storage location corresponding to each grid cell index in the grid cell head buffer is used to store the head node index of the corresponding grid cell. The storage location corresponding to each node index in the next node index buffer is used to store the next node index of the corresponding node. At the beginning of each layout iteration, each storage location in the grid cell head buffer is initialized to an empty flag; Each node is assigned a computation thread by a computation shader, and each computation thread determines the grid cell index of the grid cell to which the node belongs based on the position vector of the corresponding node. For any node, the corresponding storage location in the grid cell header buffer is determined according to the grid cell index to which the node belongs. The node index of the node is written to the corresponding storage location through an atomic swap operation, and the original header node index saved in the corresponding storage location before the swap is read. The original head node index is written into the storage location corresponding to the node index of the next node index buffer to form a node index linked list for the corresponding grid cell. When enumerating the candidate interaction nodes, the computation thread corresponding to the target node reads the head node index of each neighborhood unit, and accesses the next node index buffer in sequence with the read node index until the empty tag is read.
[0012] According to one aspect of the above technical solution, the step of calculating the repulsive force contribution between the target node and the candidate interaction nodes retained after pruning includes: For the target node i and the candidate interaction node j, obtain the connected component identifiers of the connected components to which they belong, and determine the spatial distance based on their position vectors. ; When the connected component identifiers of the target node i and the candidate interactive node j are different and the spatial distance is... When the repulsive force distance threshold R is greater than the threshold value, skip the calculation of the repulsive force of candidate interaction node j to target node i and set the corresponding repulsive force contribution to zero vector. When the connected component identifiers of the target node i and the candidate interactive node j are the same, or the spatial distance is... If the distance of the repulsive force is not greater than the threshold R, the candidate interaction node j is retained, and the repulsive force contribution of the candidate interaction node j to the target node i is determined according to the following formula: ; ; In the formula, This represents the repulsive force contribution of candidate interaction node j to target node i. and Let i and j represent the position vectors of the target node i and the candidate interaction node j, respectively. Indicates the repulsion coefficient. and Let i and j represent the node degrees of the target node i and the candidate interaction node j, respectively. Indicates the effective layout distance. Indicates the current layout scale. This indicates the preset lower limit of the effective distance.
[0013] According to one aspect of the above technical solution, the step of updating the position vector of the target node specifically includes: Traverse the edges connected to the target node i according to the set of edges, and determine the spring force generated by the corresponding edge according to the following formula: ; In the formula, This represents the spring force exerted on target node i by the edge between target node i and its adjacent node j. This is the original length of the spring; Summarize the repulsive force contribution and spring force corresponding to target node i, and obtain the resultant force on target node i according to the following formula: ; The swing amount and preset step size factor are determined based on the node degree of the target node i, the current resultant force, and the resultant force of the previous round: ; ; Update the position vector of target node i according to the preset step size factor: ; In the formula, This represents the repulsive force experienced by the target node i. This represents the spring force acting on the target node i. This represents the net force acting on the target node i. Indicates the amount of swing. This indicates the combined efforts of the previous round. Indicates the preset speed parameter. Indicates the preset step size factor; After completing the position update, the current combined force is saved as the combined force of the previous round for use in the next round of layout iteration.
[0014] According to one aspect of the above technical solution, the step of reconstructing the uniform spatial grid based on the updated position vectors and continuing the layout iteration until a preset termination condition is met, and outputting the position vectors of each node for graph data visualization rendering, specifically includes: Set the maximum number of iteration rounds and the convergence threshold. In each round of layout iteration, the uniform spatial grid is reconstructed in sequence, the neighborhood cell set corresponding to each target node is determined, the repulsive force and spring force on each target node are calculated, and the position vector of each target node is updated. Whether the layout has converged is determined by the average change in the position vectors of each node during two consecutive layout iterations, and the average change is determined by the following formula: ; In the formula, Let N represent the average change corresponding to the t-th iteration of the layout, and let N represent the total number of nodes. and These represent the positions of node i in round t and round t, respectively. The position vector after one round of layout iteration; The layout iteration is terminated when the number of layout iteration rounds reaches the maximum number of iteration rounds or the average change is less than the convergence threshold. The arithmetic mean of the position vectors of each node is determined by parallel reduction. The arithmetic mean is used as the graph center. The position vectors of each node are subtracted from the graph center and multiplied by the display scaling factor to obtain the display position vectors used for graph data visualization rendering. The display position vector is written into the instance transformation buffer, and the nodes and edges of the graph data are rendered through indirect instantiation drawing.
[0015] Secondly, this solution also provides a computer, including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the graph data force-oriented layout acceleration method as described in the above technical solution.
[0016] Thirdly, this solution also provides a storage medium on which a computer program is stored, which, when executed by a processor, implements the graph data force-oriented layout acceleration method as described in the above technical solution.
[0017] Compared with existing technologies, the advantages of this invention are as follows: By dividing the layout space into a uniform grid and calculating the repulsion force only for node pairs within neighboring grids, the repulsion force calculation in a single iteration is reduced from O(N²) to O(N·k), where k is the average number of nodes in the local neighborhood and is much smaller than N. This reduces the repulsion force calculation by several orders of magnitude at scales of tens of thousands. Utilizing the connected component information of the graph data, node pairs belonging to different connected components and with a distance exceeding a threshold R are pre-pruned, further reducing invalid calculations. This also avoids the overall diffusion problem caused by cross-component repulsion forces in dynamic iterations of multi-connected component graphs, enhancing layout stability. The construction of the uniform grid and neighborhood enumeration both employ regular data structures and parallel access modes, making them suitable for efficient implementation in computational shaders and seamlessly integrated with existing GPU-accelerated rendering pipelines. This method only tightens the repulsion force calculation range without changing the inherent mathematical form of the force-directed model, improving efficiency without affecting layout readability and convergence stability. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the force-guided layout acceleration method in the first embodiment of the present invention. Figure 2 This is a two-dimensional schematic diagram of uniform grid division and neighborhood cell set in the first embodiment of the present invention; Figure 3 This is a schematic diagram of the hardware structure of the computer in the second embodiment of the present invention; The following detailed description, in conjunction with the accompanying drawings, will further illustrate the present invention. Detailed Implementation
[0019] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Several embodiments of the invention are illustrated in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0021] Example 1 The first embodiment of this invention provides a graph data force-oriented layout acceleration method. Please refer to [link / reference]. Figure 1 The figure shows a flowchart of the graph data force-oriented layout acceleration method in the first embodiment of the present invention. As shown in the figure, the method includes the following steps: Step S100: Obtain the graph data to be laid out. The graph data includes a set of nodes and a set of edges. Each node has a position vector in the layout space, and the connected component identifier corresponding to each node is determined. In this embodiment, the graph data can come from graph structure data such as social networks, knowledge graphs, biological networks, or software dependencies, including a set of nodes and a set of edges. A node index is configured for each node in the node set. The node index is used to uniquely identify the corresponding node and to locate the storage position of the node in the node array, node position buffer, and other storage structures arranged by nodes. Each edge is represented by the node indices corresponding to its two endpoints, thus the two nodes connected by the edge can be determined through the two node indices.
[0022] In this embodiment, the steps for obtaining the graph data to be laid out specifically include: obtaining the topological structure information of the graph data and preprocessing the graph data. The topological structure information includes the total number of nodes, the total number of edges, and the node indices corresponding to the two endpoints of each edge. Graph data from different sources or in different formats are parsed and structurally converted to obtain a standardized data structure. The standardized data structure includes a node array, an edge array, and adjacency relationship data. The adjacency relationship data can be stored using an adjacency list or a compressed sparse row format. When using the compressed sparse row format, an adjacency list offset array and an adjacency node index array are set. The element in the adjacency list offset array corresponding to any node index is used to represent the start and end positions of the adjacency node index of that node in the adjacency node index array, thereby enabling the continuous reading of edges connected to the target node or corresponding other nodes based on the node index of the target node.
[0023] Preprocessing may include one or more of the following: isolated node removal, self-loop edge filtering, duplicate edge merging, and multiple edge weight aggregation. Isolated node removal removes nodes that are not connected to other nodes and do not participate in the main topology display; self-loop edge filtering removes edges whose two endpoints are the same node; duplicate edge merging merges multiple duplicate edges connecting the same two nodes; and multiple edge weight aggregation merges the edge weights of multiple edges into a combined edge weight between the corresponding node pairs. In implementations that require displaying isolated nodes, isolated nodes may also be retained, and each isolated node may be treated as an independent connected component.
[0024] After performing preprocessing operations on the graph data, the position vectors in the layout space are initialized for each node. Position vectors can be initialized randomly, by a grid, or by a circular layout. The node degree is then determined for each node, and the resultant force from the previous iteration for each node is initialized to a zero vector. This resultant force is used to calculate the degree of oscillation of the node between adjacent layout iterations.
[0025] Finally, the connected component identifiers corresponding to each node are determined based on the topological structure of the graph data. Specifically, a breadth-first search algorithm or a disjoint-set data structure (union-find) algorithm can be used to traverse the node set and edge set, assigning the same connected component identifier to nodes belonging to the same connected component and different connected component identifiers to nodes belonging to different connected components. When using the disjoint-set data structure algorithm, the root node index of each connected component can be used as the corresponding connected component identifier.
[0026] Step S200: Construct a uniform spatial grid based on the current position vector of each node, divide each node into corresponding grid cells, and establish a mapping relationship between the grid cells and the nodes.
[0027] Specifically, the preprocessed graph data is loaded into the graphics processor's (GPU) video memory. The GPU's video memory contains buffers for node positions, node degrees, previous resultant force, connected component identifiers, adjacency list offsets, adjacent node indices, and edge endpoints. The node position buffer stores the position vector of each node corresponding to its index; the node degree buffer stores the degree of each node; the previous resultant force buffer stores the resultant force of the corresponding node in the previous round; and the connected component identifier buffer stores the connected component identifier of the corresponding node. These buffers are then linked to the computation shader for input / output data binding, enabling calls for uniform spatial mesh construction, repulsion calculation, spring force calculation, and position vector updates.
[0028] At the start of each layout iteration, a uniform spatial grid is constructed based on the node position vectors in the current node position buffer. First, the minimum and maximum coordinates of each node in each coordinate dimension are obtained to determine the bounding box of the layout space.
[0029] Let the set of nodes be Node The position coordinates are Then the minimum and maximum values of the bounding box in each dimension are respectively: ; ; Where V represents the set of nodes, , , , , and These represent the minimum and maximum coordinates in each coordinate dimension, respectively. The z-coordinate dimension is not calculated in the two-dimensional layout space. The side length h of the grid cells in the uniform spatial grid is set as the repulsive force distance threshold, i.e., h = R; The number of grid cells in each coordinate dimension is determined based on the bounding box span and grid cell side length. In 3D layout space, the number of grid cells in each coordinate dimension can be determined by the following formula: ; in, , and These represent the number of grid cells in the three coordinate dimensions, with symbols... This indicates rounding up, max(1, This is used to ensure that at least one grid cell is set in any coordinate dimension.
[0030] For any node i, calculate the grid cell index of the grid cell to which the node belongs based on its position vector. The grid cell index consists of integer indices in each coordinate dimension and can be determined according to the following formula: ; In the formula, , and These represent the integer indices of the grid cell to which node i belongs in each coordinate dimension, with symbols... This indicates rounding down to the nearest integer.
[0031] In the graphics processor's video memory, a grid cell header buffer and a next node index buffer are set up. The storage location in the grid cell header buffer corresponding to each grid cell index is used to store the header node index of that grid cell. The storage location in the next node index buffer corresponding to each node index is used to store the next node index in the linked list of node indices for the same grid cell. At the beginning of each layout iteration, each storage location in the grid cell header buffer is initialized to an empty flag. An empty flag can be represented by a negative value that is not within the range of valid node indices.
[0032] Each node is assigned a computation thread by a computation shader, and each thread processes one node. Each computation thread determines the mesh cell index of its corresponding mesh cell based on the node's position vector, and then determines the corresponding storage location in the mesh cell head buffer based on the mesh cell index. The computation thread writes the node index of the currently processed node to this storage location through an atomic swap operation, and then reads the original head node index stored in this storage location before the swap; subsequently, it writes the original head node index to the storage location corresponding to the node index of the currently processed node in the next node index buffer. After all nodes have completed the above operations, the nodes within the same mesh cell form a node index linked list through their node indices, and the mesh cell head buffer stores the head node index of this linked list.
[0033] Step S300: For each target node, determine the neighborhood unit set corresponding to the target node according to the preset repulsive force action distance threshold, and only enumerate other nodes in the neighborhood unit set as candidate interaction nodes.
[0034] Specifically, after establishing the mapping relationship between grid cells and nodes, a set of neighborhood cells is determined for each target node. (Reference) Figure 2 For each target node, a set of neighborhood units is determined. Figure 2 In this context, the target node is located within the central grid cell. The central grid cell and its surrounding adjacent grid cells constitute the neighborhood cell set corresponding to the target node. Other nodes located within the neighborhood cell set serve as candidate interaction nodes. Nodes located outside the neighborhood cell set do not participate in the repulsion calculation for the target node in this round of layout iteration. Let the grid cell index of the grid cell to which the target node i belongs be . Then its neighborhood unit set can be represented as: ; in This represents the set of neighborhood cells corresponding to the target node i. Indicates the grid cell index is The mesh elements are defined as follows: For target nodes located at the bounding box boundary, only mesh elements whose indices fall within the effective index range of the uniform spatial mesh are retained. Only mesh elements with indices within the effective index range of the uniform spatial mesh are considered in the 2D layout. and Two dimensions, at this time Includes up to Each grid cell; considered in 3D layout , , Three dimensions Includes up to Each grid cell.
[0035] The computation thread corresponding to the target node sequentially reads the head node index of each grid cell in the neighborhood cell set, and uses the read head node index to access the next node index buffer, reading the other node indices of the same grid cell one by one, until an empty marker is read. The other nodes read, excluding the target node itself, constitute the candidate interaction nodes corresponding to the target node.
[0036] Step S400: Based on the connected component identifiers corresponding to the target node and each candidate interaction node and the spatial distance between them, perform local repulsive pruning on the candidate interaction nodes, and calculate the repulsive force contribution between the target node and the remaining candidate interaction nodes after pruning, to obtain the repulsive force on the target node.
[0037] After obtaining candidate interaction nodes, local repulsive pruning is performed based on connected component identifiers and spatial distances. For the target node i and the candidate interaction node j, the corresponding connected component identifiers are read from the connected component identifier buffer, denoted as [i, j]. and And determine the spatial distance based on the position vectors of the two: ; In the formula, Represents the Euclidean distance between the target node i and the candidate interaction node j; if and If the repulsion calculation for that candidate interaction node is skipped, the repulsion contribution is set to zero. ;like or Then the contribution is calculated according to the repulsion formula.
[0038] When it is necessary to calculate the repulsive force contribution, a degree-dependent repulsive force model is adopted, with nodes... Received from node The magnitude of the repulsive force is: ; in, This represents the repulsive force contribution of candidate interaction node j to target node i. , Each node and The position vector, , For each node and The degree of the node. The repulsion coefficient is... The effective distance in the layout space is defined as: ; In the formula, The current layout scale (which can be the average distance between all nodes or the desired side length). This is a preset lower limit constant used to prevent the denominator from being too small.
[0039] Step S500: Calculate the spring force on the target node based on the edges connected to the target node in the edge set, combine the repulsive force with the spring force, and update the position vector of the target node based on the combination result.
[0040] By summing the repulsive force contributions generated by each candidate interaction node after pruning, the repulsive force experienced by the target node can be obtained: ; In the formula, This is the set of candidate interactive nodes retained after pruning.
[0041] Then, the spring force on the target node is calculated based on the edge set. For any edge in the edge set that connects to the target node i, the other node connected by that edge is denoted as node j. The position vector of node j is read from the current node position buffer, and the spring force exerted by that edge on the target node i is determined according to the following formula: ; In the formula, The spring force generated on the corresponding side. This indicates the original length of the spring.
[0042] Summarizing the spring forces generated by each edge connected to the target node in the edge set, we get: ; Here, E represents the edge set. The resultant force on the target node is obtained by combining the repulsive force and the spring force acting on it. : .
[0043] In one implementation, the position vector of the target node can be updated using a preset step size factor: ; Where η represents the preset step size factor.
[0044] In this embodiment, an adaptive step size is preferably used to update the position vector of the target node. First, the oscillation amount and preset step size factor are determined based on the target node's degree, the current resultant force, and the resultant force from the previous round. ; ; In the formula, Indicates the amount of swing. This indicates the combined efforts of the previous round. Indicates the preset speed parameter. Indicates the preset step size factor; Step S600: Reconstruct the uniform spatial grid based on the updated position vectors and continue the layout iteration until the preset termination condition is met, and output the position vectors of each node for graph data visualization rendering.
[0045] After the position vectors of all target nodes are updated, the current node position buffer and the next node position buffer are swapped. Based on the swapped current node position buffer, the bounding box of the layout space is redefined, the uniform spatial mesh and the mapping relationship between mesh cells and nodes are reconstructed, and the next round of layout iteration begins. Therefore, the uniform spatial mesh can be dynamically reconstructed as the node position vectors change, without the need to maintain a recursive hierarchical spatial structure.
[0046] Preset the maximum number of iterations and convergence threshold In each layout iteration, the uniform spatial grid is reconstructed sequentially, the neighborhood cell set corresponding to each target node is determined, the repulsive force and spring force on each target node are calculated, and the position vector of each target node is updated. Whether the layout has converged is determined by the average change in the position vectors of each node during two consecutive layout iterations, and the average change is determined by the following formula: ; In the formula, Let N represent the average change corresponding to the t-th iteration of the layout, and let N represent the total number of nodes. and These represent the positions of node i in round t and round t, respectively. The position vector after one round of layout iteration; The layout iteration is terminated when the number of layout iteration rounds reaches the maximum number of iteration rounds or the average change is less than the convergence threshold. The arithmetic mean of the position vectors of each node is determined by parallel reduction. The arithmetic mean is used as the graph center. The position vectors of each node are subtracted from the graph center and multiplied by the display scaling factor to obtain the display position vectors used for graph data visualization rendering. The display position vector is written into the instance transformation buffer, and the nodes and edges of the graph data are rendered through indirect instantiation drawing.
[0047] In a specific application scenario, the graph data to be laid out is a social network graph containing 10,000 nodes and 50,000 edges. The above method is implemented as a plugin in Unreal Engine 5, utilizing a rendering dependency graph to manage the GPU's computational channels. First, the graph data is read in the game thread, the degree of each node is calculated, and the connected component identifier corresponding to each node is determined using a disjoint-set data structure algorithm. The position coordinates of each node are initialized to random values, and the edge connections are converted to Compressed Sparse Linear Relationships (CSR) format. Then, a GPU structured buffer is allocated, including a node position buffer (storing the position of each node). The system includes coordinates, node degree and auxiliary state buffers (previous round displacement), connected component root buffer, CSR adjacency list offset and edge number buffer, edge endpoint pair buffer, and uploads all data to video memory.
[0048] At the start of each display frame, the bounding box of the layout space is determined based on the position vector in the current node position buffer, and the side length of the mesh cell is set to the repulsive force action distance threshold, which can be twice the preset desired side length. After clearing the mesh cell header buffer, the mesh construction computation shader is dispatched. Each computation thread inserts the node index of the corresponding node into the node index linked list of the corresponding mesh cell through atomic swap operations. Subsequently, the force calculation and position update computation shader is dispatched. Each computation thread processes one target node, traverses no more than 27 neighboring cells in the 3D layout space, and calculates the local repulsive force, spring force, resultant force, and adaptive step size in sequence, writing the updated position vector into the next node position buffer.
[0049] Each display frame executes 5 rounds of layout iterations. After completing 5 rounds of layout iterations, the graph center is determined through parallel reduction, and centering and display scaling are performed on the position vectors of each node. The display position vectors are written to the instance transformation buffer, and the indirect drawing parameters are updated to complete the instantiation rendering of nodes and edges. On a test platform equipped with an NVIDIA RTX 4070 graphics processor, the total time for executing 5 rounds of layout iterations per frame is approximately 7.2 milliseconds, corresponding to a rendering frame rate of approximately 138 frames per second. In a control method where uniform spatial mesh neighborhood enumeration is disabled and all other nodes are traversed for each target node, the time per frame exceeds 55 milliseconds under the same hardware and iteration conditions, corresponding to a rendering frame rate of less than 18 frames per second. This invention reduces the amount of repulsion calculation from Reduced to ,in With an average number of nodes in the neighborhood of approximately 80, the dynamic force-oriented layout of graph data at the tens of thousands scale has achieved real-time interactive standards for the first time. Furthermore, due to the adoption of connected component pruning, no overall diffusion phenomenon occurred between multiple connected components in the graph during long-term operation, resulting in good visual stability of the layout.
[0050] In summary, the graph data force-oriented layout acceleration method in the above embodiments of the present invention reduces the repulsion calculation in a single iteration from O(N²) to O(N·k) by dividing the layout space into a uniform grid and calculating the repulsion only for node pairs within neighboring grids. Here, k is the average number of nodes in the local neighborhood, which is much smaller than N. This can reduce the repulsion calculation by several orders of magnitude at a scale of tens of thousands. By utilizing the connected component information of the graph data, node pairs belonging to different connected components and whose distance exceeds a threshold R are pre-pruned, further reducing invalid calculations. At the same time, it avoids the overall diffusion problem caused by cross-component repulsion in dynamic iterations of multi-connected component graphs, thus enhancing layout stability. The construction of the uniform grid and the neighborhood enumeration both adopt regular data structures and parallel access modes, which are suitable for efficient implementation in computation shaders and can be seamlessly integrated with existing GPU-accelerated rendering pipelines. This method only tightens the repulsion calculation range without changing the inherent mathematical form of the force-oriented model, improving efficiency without affecting the readability and convergence stability of the layout.
[0051] Example 2 A second embodiment of this application provides a computer that may include a processor 81 and a memory 82 storing computer program commands.
[0052] Specifically, the processor 81 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0053] The memory 82 may include a large-capacity storage device for data or commands. For example, and not limitingly, the memory 82 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), flash memory, an optical disk drive, a magneto-optical disk drive, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 82 may include removable or non-removable (or fixed) media. Where appropriate, the memory 82 may be internal or external to a data processing device. In a particular embodiment, the memory 82 is non-volatile memory. In a particular embodiment, the memory 82 includes read-only memory (ROM) and random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), an electrically alterable read-only memory (EAROM), or flash memory, or a combination of two or more of these. Where appropriate, the RAM can be Static Random-Access Memory (SRAM) or Dynamic Random-Access Memory (DRAM). DRAM can be Fast Page Mode Dynamic Random-Access Memory (FPMDRAM), Extended Data Out Dynamic Random-Access Memory (EDODRAM), Synchronous Dynamic Random-Access Memory (SDRAM), etc.
[0054] The memory 82 can be used to store or cache various data files that need to be processed and / or communicated, as well as possible computer program commands executed by the processor 81.
[0055] The processor 81 implements any of the graph data force-oriented layout acceleration methods in the above embodiments by reading and executing computer program commands stored in the memory 82.
[0056] In some embodiments, the computer may further include a communication interface 83 and a bus 80. For example, Figure 3 As shown, the processor 81, memory 82, and communication interface 83 are connected through bus 80 and complete communication with each other.
[0057] The communication interface 83 is used to enable communication between the various modules, devices, units, and / or equipment in the embodiments of this application. The communication interface 83 can also enable data communication with other components such as external devices, image / data acquisition devices, databases, external storage, and image / data processing workstations.
[0058] Bus 80 includes hardware, software, or both, that couples computer components together. Bus 80 includes, but is not limited to, at least one of the following: data bus, address bus, control bus, expansion bus, and local bus. For example, and not as a limitation, bus 80 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, bus 80 may include one or more buses. Although specific buses are described and illustrated in the embodiments of this application, this application considers any suitable bus or interconnection.
[0059] Example 3 A third embodiment of this application provides a readable storage medium. This readable storage medium stores computer program commands; when executed by a processor, these computer program commands implement any of the graph data force-oriented layout acceleration methods described in the above embodiments.
[0060] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0061] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A graph data force-guided layout acceleration method, characterized in that, Includes the following steps: Obtain the graph data to be laid out, the graph data includes a set of nodes and a set of edges, each node has a position vector in the layout space, and determine the connected component identifier corresponding to each node; A uniform spatial grid is constructed based on the current position vector of each node, each node is divided into corresponding grid cells, and a mapping relationship between the grid cells and the nodes is established. For each target node, a set of neighborhood units corresponding to the target node is determined according to a preset repulsive force action distance threshold, and only other nodes in the set of neighborhood units are enumerated as candidate interaction nodes. Based on the connected component identifiers corresponding to the target node and each candidate interaction node, as well as the spatial distance between them, local repulsive pruning is performed on the candidate interaction nodes, and the repulsive force contribution between the target node and the remaining candidate interaction nodes after pruning is calculated to obtain the repulsive force on the target node. The spring force on the target node is calculated based on the edge connected to the target node in the edge set. The repulsive force and the spring force are combined, and the position vector of the target node is updated based on the combination result. The uniform spatial grid is reconstructed based on the updated position vectors, and the layout iteration continues until the preset termination condition is met. The position vectors of each node are then output for graph data visualization rendering.
2. The graph data force-guided layout acceleration method according to claim 1, characterized in that, The specific steps for determining the connected component identifiers corresponding to each node include: Configure a node index for each node in the node set to uniquely identify the corresponding node; Obtain the topological structure information of the graph data, which includes the total number of nodes, the total number of edges, and the node indices corresponding to the two endpoints of each edge; The graph data is parsed and structurally transformed to obtain a standardized data structure including a node array, an edge array, and adjacency relationship data. The adjacency relationship data is stored in an adjacency list or a compressed sparse row format. Perform at least one of the following preprocessing steps on the graph data: isolated node removal, self-loop edge filtering, duplicate edge merging, and multi-edge weight aggregation; The initial position vector of each node is determined by one of the following methods: random initialization, mesh initialization, or circular layout initialization. The node degree of each node and the resultant force of the previous round used for position update are also determined. Based on the topology of the graph data, the connected component identifiers corresponding to each node are determined by a breadth-first search algorithm or a disjoint-set data structure algorithm. When two nodes have the same connected component identifier, it means that the two nodes belong to the same connected component.
3. The graph data force-guided layout acceleration method according to claim 2, characterized in that, The specific steps for constructing a uniform spatial grid based on the current position vector of each node include: The minimum and maximum coordinates of each node in each coordinate dimension are obtained to determine the bounding box of the layout space. Set the side length of the grid cell of the uniform spatial grid to the threshold value of the repulsive force action distance; The number of grid cells in the corresponding coordinate dimension is determined based on the ratio of the bounding box span to the side length of the grid cell in each coordinate dimension. Divide the difference between the node's position coordinates in the corresponding coordinate dimension and the minimum coordinate in that coordinate dimension by the side length of the grid cell to obtain the integer index of the node in the corresponding coordinate dimension. Boundary constraints are applied to the integer indices to ensure that they fall within the valid index range of the corresponding coordinate dimension, and the integer indices in each coordinate dimension are combined to form the grid cell index of the corresponding node's grid cell.
4. The graph data force-guided layout acceleration method according to claim 3, characterized in that, The steps for determining the neighborhood set corresponding to the target node specifically include: Obtain the grid cell index of the grid cell to which the target node belongs; The grid cells whose absolute difference between the integer index of each coordinate dimension and the corresponding integer index of the grid cell to which the target node belongs is not greater than 1 are determined as the neighborhood cells corresponding to the target node. The neighborhood cells located at the bounding box boundary of the layout space are truncated, and only the neighborhood cells located within the effective index range of the uniform spatial grid are retained, thereby obtaining the neighborhood cell set.
5. The graph data force-guided layout acceleration method according to claim 3, characterized in that, The steps for establishing the mapping relationship between the mesh cells and nodes specifically include: In the video memory of the graphics processor, a grid cell head buffer and a next node index buffer are set. The storage location corresponding to each grid cell index in the grid cell head buffer is used to store the head node index of the corresponding grid cell. The storage location corresponding to each node index in the next node index buffer is used to store the next node index of the corresponding node. At the beginning of each layout iteration, each storage location in the grid cell head buffer is initialized to an empty flag; Each node is assigned a computation thread by a computation shader, and each computation thread determines the grid cell index of the grid cell to which the node belongs based on the position vector of the corresponding node. For any node, the corresponding storage location in the grid cell header buffer is determined according to the grid cell index to which the node belongs. The node index of the node is written to the corresponding storage location through an atomic swap operation, and the original header node index saved in the corresponding storage location before the swap is read. The original head node index is written into the storage location corresponding to the node index of the next node index buffer to form a node index linked list for the corresponding grid cell. When enumerating the candidate interaction nodes, the computation thread corresponding to the target node reads the head node index of each neighborhood unit, and accesses the next node index buffer in sequence with the read node index until the empty tag is read.
6. The graph data force-guided layout acceleration method according to claim 1, characterized in that, The steps for calculating the repulsive force contribution between the target node and the candidate interaction nodes retained after pruning include: For the target node i and the candidate interaction node j, obtain the connected component identifiers of the connected components to which they belong, and determine the spatial distance based on their position vectors. ; When the connected component identifiers of the target node i and the candidate interactive node j are different and the spatial distance is... When the repulsive force distance threshold R is greater than the threshold value, skip the calculation of the repulsive force of candidate interaction node j to target node i and set the corresponding repulsive force contribution to zero vector. When the connected component identifiers of the target node i and the candidate interactive node j are the same, or the spatial distance is... If the distance of the repulsive force is not greater than the threshold R, the candidate interaction node j is retained, and the repulsive force contribution of the candidate interaction node j to the target node i is determined according to the following formula: ; ; In the formula, This represents the repulsive force contribution of candidate interaction node j to target node i. and Let i and j represent the position vectors of the target node i and the candidate interaction node j, respectively. Indicates the repulsion coefficient. and Let i and j represent the node degrees of the target node i and the candidate interaction node j, respectively. Indicates the effective layout distance. Indicates the current layout scale. This indicates the preset lower limit of the effective distance.
7. The graph data force-guided layout acceleration method according to claim 6, characterized in that, The steps for updating the position vector of the target node specifically include: Traverse the edges connected to the target node i according to the set of edges, and determine the spring force generated by the corresponding edge according to the following formula: ; In the formula, This represents the spring force exerted on target node i by the edge between target node i and its adjacent node j. This is the original length of the spring; Summarize the repulsive force contribution and spring force corresponding to target node i, and obtain the resultant force on target node i according to the following formula: ; The swing amount and preset step size factor are determined based on the node degree of the target node i, the current resultant force, and the resultant force of the previous round: ; ; Update the position vector of target node i according to the preset step size factor: ; In the formula, This represents the repulsive force experienced by the target node i. This represents the spring force acting on the target node i. This represents the net force acting on the target node i. Indicates the amount of swing. This indicates the combined efforts of the previous round. Indicates the preset speed parameter. Indicates the preset step size factor; After completing the position update, the current combined force is saved as the combined force of the previous round for use in the next round of layout iteration.
8. The graph data force-guided layout acceleration method according to claim 1, characterized in that, The steps of reconstructing the uniform spatial grid based on the updated position vectors and continuing the layout iteration until a preset termination condition is met, and then outputting the position vectors of each node for graph data visualization rendering, specifically include: Set the maximum number of iteration rounds and the convergence threshold. In each round of layout iteration, the uniform spatial grid is reconstructed in sequence, the neighborhood cell set corresponding to each target node is determined, the repulsive force and spring force on each target node are calculated, and the position vector of each target node is updated. Whether the layout has converged is determined by the average change in the position vectors of each node during two consecutive layout iterations, and the average change is determined by the following formula: ; In the formula, Let N represent the average change corresponding to the t-th iteration of the layout, and let N represent the total number of nodes. and These represent the positions of node i in round t and round t, respectively. The position vector after one round of layout iteration; The layout iteration is terminated when the number of layout iteration rounds reaches the maximum number of iteration rounds or the average change is less than the convergence threshold. The arithmetic mean of the position vectors of each node is determined by parallel reduction. The arithmetic mean is used as the graph center. The position vectors of each node are subtracted from the graph center and multiplied by the display scaling factor to obtain the display position vectors used for graph data visualization rendering. The display position vector is written into the instance transformation buffer, and the nodes and edges of the graph data are rendered through indirect instantiation drawing.
9. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the graph data force-guided layout acceleration method as described in any one of claims 1-8.
10. A storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the graph data force-oriented layout acceleration method as described in any one of claims 1-8.
