Graph structure layout method, electronic equipment and storage medium
By extracting the graph structure and dividing node clusters, and determining the update coordinates based on dependencies and layer numbers, the problem of poor stability of the hierarchical layout algorithm is solved, and higher layout stability and readability are achieved.
Patent Information
- Application Number
- CN202510956396.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-11
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-07-11
AI Technical Summary
The existing hierarchical layout algorithms have poor stability when updating the graph structure, especially in complex layout scenarios.
By extracting the graph structure features, dividing node clusters, and determining the layer number and updating coordinates of nodes based on the dependencies and feature data between node clusters, reducing cross-layer or cross-cluster edge connections, improving the readability and layout stability of the graph structure.
In incremental layout scenarios, reduce the range of node coordinate variations and improve the layout stability and scalability of the graph structure.
Smart Images

Figure CN120470154A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data technology, and in particular to a graph structure layout method, electronic device, and storage medium. Background Art
[0002] In some scenarios (such as computer science and biology), users can use graph structures in data processing to clearly indicate the relationships between multiple data. For example, this graph structure can be a directed acyclic graph (DAG).
[0003] In the related art, users can manually drag and drop nodes on the canvas of a structure diagram layout tool and edit their content to obtain an initial graph structure. A hierarchical layout algorithm (e.g., the Sugiyama algorithm) is then used to update the layout of this initial graph structure to make it more aesthetically pleasing. However, this hierarchical layout algorithm suffers from poor stability during the update process of the initial graph structure. Summary of the Invention
[0004] The present application provides a graph structure layout method, electronic device and storage medium to at least solve the problem of poor stability of the hierarchical layout algorithm in the process of updating the initial graph structure in the related art.
[0005] This application provides a graph structure layout method, including:
[0006] Obtain a first graph structure, where the first graph structure includes a plurality of first nodes, and the plurality of first nodes are connected by directed edges;
[0007] Performing feature extraction processing on the first graph structure to obtain feature data of the plurality of first nodes, and dividing the plurality of first nodes into a plurality of node clusters having dependency relationships based on the feature data of the plurality of first nodes, each node cluster including at least one first node;
[0008] determining first layer numbers of the plurality of first nodes according to dependency relationships between the plurality of node clusters and characteristic data of the plurality of first nodes;
[0009] According to the dependency relationship between the multiple node clusters and the first layer numbers of the multiple first nodes, the updated coordinates of the multiple first nodes are determined, and the first graph structure is updated based on the updated coordinates of the multiple first nodes to obtain the second graph structure.
[0010] This application also provides a graph structure layout device, including:
[0011] An acquisition module is configured to acquire a first graph structure, where the first graph structure includes a plurality of first nodes, and the plurality of first nodes are connected by directed edges;
[0012] a processing module configured to perform feature extraction processing on the first graph structure to obtain feature data of the plurality of first nodes, and based on the feature data of the plurality of first nodes, divide the plurality of first nodes into a plurality of node clusters having dependency relationships, each node cluster including at least one first node;
[0013] The processing module is further configured to determine first layer numbers of the plurality of first nodes based on dependency relationships between the plurality of node clusters and characteristic data of the plurality of first nodes;
[0014] The processing module is also used to determine the updated coordinates of multiple first nodes based on the dependency relationship between multiple node clusters and the first layer numbers of multiple first nodes, and update the first graph structure based on the updated coordinates of the multiple first nodes to obtain a second graph structure.
[0015] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned graph structure layout methods when executing the computer program.
[0016] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned graph structure layout methods are implemented.
[0017] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned graph structure layout methods when executed by a processor.
[0018] Through the present application, after obtaining the first graph structure, feature data of multiple first nodes in the first graph structure are obtained by performing feature extraction processing on the first graph structure, and based on the feature data of the multiple first nodes, the multiple first nodes are divided into multiple node clusters with dependency relationships, and the first layer numbers of the multiple first nodes are determined according to the dependency relationships between the multiple node clusters and the feature data of the multiple first nodes to reduce cross-layer edges or cross-cluster edges in the graph structure and improve the readability and layout stability of the graph structure; the updated coordinates of the multiple first nodes are determined in combination with the dependency relationships between the multiple node clusters and the first layer numbers of the multiple first nodes, and the first graph structure is updated based on the updated coordinates of the multiple first nodes to obtain a second graph structure. In some incremental layout scenarios, the range of variation of the coordinates of each first node in the second graph structure can be reduced, so that the second graph structure has higher layout stability and scalability, and has higher stability during the graph structure update process. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1 A schematic diagram of the layout update process of the initial graph structure provided in an embodiment of the present application;
[0021] Figure 2 One of the flowcharts of the graph structure layout method provided in the embodiment of the present application;
[0022] Figure 3 An exemplary schematic diagram of updating a graph structure provided in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of the node cluster division process provided in an embodiment of the present application;
[0024] Figure 5 The second flowchart of the graph structure layout method provided in the embodiment of the present application;
[0025] Figure 6 A schematic diagram of the merging process of a node set provided in an embodiment of the present application;
[0026] Figure 7 The third flowchart of the graph structure layout method provided in the embodiment of the present application;
[0027] Figure 8 A schematic diagram of node layer division provided in an embodiment of the present application;
[0028] Figure 9 The fourth flowchart of the graph structure layout method provided in the embodiment of the present application;
[0029] Figure 10 The fifth flowchart of the graph structure layout method provided in the embodiment of the present application;
[0030] Figure 11 Flowchart 6 of the graph structure layout method provided in the embodiment of the present application;
[0031] Figure 12 A schematic diagram of the structure of a graph structure layout device provided in an embodiment of the present application;
[0032] Figure 13 This is a schematic diagram of the structure of the electronic device provided in this application. DETAILED DESCRIPTION
[0033] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0034] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0035] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and corresponding operation entrances must be provided for users to choose to authorize or refuse.
[0036] First, the terms involved in this application are explained.
[0037] Directed Acyclic Graph (DAG): A graph-based data structure. A DAG consists of multiple nodes connected to each other by directed edges, so that there are no cycles in the DAG.
[0038] Sugiyama algorithm: is a hierarchical graph layout algorithm that aims to layout a DAG into a row or column to meet both aesthetic and readability requirements.
[0039] Pre-training definition: Pre-training is a deep learning model training strategy. Its core is to use large-scale datasets to initially train the model, enabling it to learn common feature representations. This process is similar to the basic learning stage humans undergo before acquiring new knowledge, accumulating experience through extensive reading and observation.
[0040] A pre-trained language model generally involves designing a language model training task based on a large-scale corpus (including language training materials such as sentences and paragraphs), and then training a large-scale neural network algorithm structure to learn and implement it. The resulting large-scale neural network algorithm structure and parameters are the pre-trained language model. Subsequent tasks can use this model to extract features or fine-tune it to achieve specific task objectives. The idea behind pre-training is to first train a task to obtain a set of model parameters, then use this set of model parameters to initialize the network model parameters. The initialized network model is then used to train other tasks to obtain a model adapted for these tasks. By pre-training on a large-scale corpus, neural language representation models can acquire powerful language representation capabilities and extract rich syntactic and semantic information from text. Pre-trained language models can provide tokens and sentence-level features containing rich semantic information for use in downstream tasks. Fine-tuning can also be performed directly on the pre-trained model for downstream tasks, quickly and easily obtaining a dedicated downstream model.
[0041] The neural network algorithm structure for training the pre-trained language model can be a convolutional neural network (CNN), a recurrent neural network (RNN), a long short-term memory network (LSTM), etc., or a model built on an attention network, such as a transformer, a bidirectional encoder representation from transformers (BERT), a generative pre-trained transformer (GPT), a contrastive language-image pre-training (CLIP), etc., which is not limited in this application. An attention network refers to a network model that uses an attention mechanism for training. The model extracts more important feature information from the input sequence by assigning different weights to each part of the input sequence, so that the model ultimately obtains a more accurate output.
[0042] Fine-tuning involves further training a pre-trained model on a task-specific dataset to adjust model parameters and better adapt it to the target task. During fine-tuning, most layers of the pre-trained model are typically frozen, with only newly added layers trained or a small number of key layers adjusted. This preserves the useful features learned by the pre-trained model while enabling rapid adaptation to the specific requirements of the new task. Choosing the appropriate learning rate and number of training rounds is also crucial for successful fine-tuning.
[0043] In some scenarios (such as computer science and biology), users need to lay out a graph structure during data processing. For example, this graph structure can be a DAG.
[0044] A structure diagram editing tool can be run in an electronic device. Users can manually drag and drop nodes on the canvas of the structure diagram editing tool through the electronic device and edit the content of each node to obtain an initial graph structure, and then update the layout of the initial graph structure through a hierarchical layout algorithm.
[0045] Figure 1 For a schematic diagram of the layout update process of the initial graph structure provided in the embodiment of this application, please refer to Figure 1 The layout update process of the initial graph structure in the hierarchical layout algorithm includes the following four stages: node stratification, intra-layer sorting, coordinate allocation, and edge routing. Among them, node stratification refers to assigning multiple nodes in the DAG to different node layers, intra-layer sorting refers to sorting nodes within each node layer to reduce edge crossings, coordinate allocation refers to configuring the corresponding position for each node in the graph structure; edge routing refers to the method used to draw the edges between the nodes in the graph structure.
[0046] Exemplarily, the hierarchical layout algorithm can be the Sugiyama algorithm. During the layer assignment phase, the Sugiyama algorithm can use the longest path or network simplex method to perform page layering. During the intra-layer sorting phase, the Sugiyama algorithm can use a centroid or median heuristic algorithm for intra-layer sorting. During the coordinate assignment and edge routing phase, the Sugiyama algorithm can insert virtual nodes to handle long edges spanning multiple layers. However, edges are often straight or broken lines, which can easily lead to the generation of a large number of pseudo nodes.
[0047] However, in some complex layout scenarios (for example, adding nodes, deleting nodes, and nesting nodes), the graph structure updated by this hierarchical layout algorithm contains a large number of crossing and fragmented edges of varying lengths, which not only makes it difficult to read but also results in poor layout stability.
[0048] An embodiment of the present application provides a graph structure layout method. After obtaining a first graph structure, the method performs feature extraction processing on the first graph structure to obtain feature data of multiple first nodes in the first graph structure, and based on the feature data of the multiple first nodes, the multiple first nodes are divided into multiple node clusters with dependencies, and the first layer numbers of the multiple first nodes are determined according to the dependencies between the multiple node clusters and the feature data of the multiple first nodes, so as to reduce cross-layer edges or cross-cluster edges in the graph structure and improve the readability and layout stability of the graph structure; and, based on the dependencies between the multiple node clusters and the first layer numbers of the multiple first nodes, the updated coordinates of the multiple first nodes are determined, and the first graph structure is updated based on the updated coordinates of the multiple first nodes to obtain a second graph structure, so as to reduce the range of variation of the coordinates of each first node in the second graph structure in some incremental layout scenarios, so that the second graph structure has higher layout stability and scalability, and the graph structure update process has higher stability.
[0049] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0050] Figure 2 This is one of the flow charts of the graph structure layout method provided in the embodiment of the present application, such as Figure 2 As shown, the embodiment of the present application provides a graph structure layout method, which is described in detail as follows:
[0051] S201: Obtain a first graph structure.
[0052] In some embodiments, a structure diagram editing tool may be running on the electronic device, and the electronic device may use the graph structure on the canvas of the structure diagram editing tool as the first graph structure. A user may manually drag and drop nodes on the canvas of the structure diagram editing tool and edit the content of each node to generate the first graph structure on the canvas.
[0053] The first graph structure may include multiple first nodes, and the multiple first nodes are connected by directed edges.
[0054] Exemplarily, the first graph structure may be a DAG.
[0055] Figure 3 For an exemplary schematic diagram of graph structure update provided in the embodiment of this application, please refer to Figure 3The first graph structure includes seven first nodes, wherein first node A is connected to first node B1 and first node B2 via two directed edges, first node B1 is connected to first node C via a directed edge, first node C is connected to first node D and first node E2 via two directed edges, and first node D is connected to first node E1 via a directed edge. The layout of the first nodes in the first graph structure can be adjusted to obtain a second graph structure.
[0056] S202 : Perform feature extraction processing on the first graph structure to obtain feature data of the plurality of first nodes, and divide the plurality of first nodes into a plurality of node clusters having dependency relationships based on the feature data of the plurality of first nodes.
[0057] Each node cluster may include at least one first node.
[0058] In some embodiments, for any first node, the characteristic data of the first node includes attribute data and structure data of the first node, wherein:
[0059] (1) Attribute data
[0060] The attribute data may include an identity document (ID), type information, and weight of the first node. The type information includes a label and / or type of the first node. The weight includes a node weight of the first node and an edge weight corresponding to the first node.
[0061] The identifier of the first node may be used to identify the first node, and the identifier of the first node may be an index or a name of the first node.
[0062] The label of the first node can include a node label and / or an edge label. Optionally, the node label can indicate the name or characteristics of the first node (for example, the node of business 1); the edge label can be used to indicate the type of relationship corresponding to the first node (for example, a call relationship or a parent-child relationship). The edges corresponding to the first node can include edges issued by the first node and edges pointing to the first node.
[0063] Different first nodes may have the same type. Exemplarily, the type of the first node may be defined based on the function of the first node or the business of the first node.
[0064] The weight may be a scoring indicator manually assigned to the first node and the edge corresponding to the first node, and is used to adjust layout priority or visual prominence.
[0065] (2) Structural data
[0066] The structural data may include the out-degree and in-degree of the first node, and the path information between the first node and the starting first node in the first graph structure. The out-degree of the first node is the number of edges emitted by the first node, and the in-degree of the first node is the number of edges pointing to the first node.
[0067] If there are multiple paths between the first node and the starting first node in the first graph structure, the path information may include path information of each of the multiple paths.
[0068] The path information may include the number of paths, the path identifier of each path, and the path length, etc. The path length may be the longest path length between the first node and the starting first node, and / or the shortest path length between the first node and the starting first node.
[0069] For example, in Figure 3 In the graph, the out-degree of the first node A is 2 and the in-degree is 0. Since the starting first node in the first graph structure is the first node A, the path length of the first node A is 0; the out-degree of the first node B1 is 1 and the in-degree is 1. The path length between the first node B1 and the starting first node can be the length of the directed edge between the first node B1 and the first node A.
[0070] The graph structure layout method can be applied to an electronic device, which may include a semantic feature extraction and clustering module, which can be used to execute step S201. Exemplarily, the semantic feature extraction and clustering module can extract feature data (e.g., semantic attribute information) of a first node in an input first graph structure (e.g., DAG), and vectorize the extracted feature data to obtain a multidimensional feature vector of each first node, and based on the multidimensional feature vectors of the multiple first nodes, use a clustering algorithm to divide the multiple first nodes into multiple node clusters, so as to maintain semantically consistent area division during the layout process of the graph structure.
[0071] In some embodiments, a pre-trained language model may be used to perform feature extraction processing on the first graph structure to obtain feature data of multiple first nodes.
[0072] Optionally, for any first node, a multidimensional feature vector f(v) corresponding to the first node can be constructed based on the feature data of the first node. For example, f(v) = [identity, in-degree, out-degree, path length, label, weight, type].
[0073] The clustering algorithm can be used to divide the first node in the graph structure into multiple clusters, so that the connections within the cluster are dense and the connections between clusters are sparse. Exemplarily, the clustering algorithm can include but is not limited to a community discovery-based algorithm, such as the Louvain algorithm.
[0074] Optionally, the labels and / or types of the first nodes in the same node cluster are the same.
[0075] Figure 4 For a schematic diagram of the node cluster division process provided in the embodiment of this application, please refer to Figure 4 , based on the dependency relationships among the 12 first nodes in the first graph structure along the directed edges, the 12 first nodes can be divided into three node clusters, each of which can include at least one first node. Node cluster 2 depends on node cluster 1, and node cluster 3 depends on node cluster 2.
[0076] It should be noted that, based on the characteristic data of the plurality of first nodes, the process of dividing the plurality of first nodes into a plurality of node clusters with dependency relationships will be Figure 5 The details are described in the examples.
[0077] S203 : Determine first layer numbers of the plurality of first nodes according to dependency relationships among the plurality of node clusters and characteristic data of the plurality of first nodes.
[0078] In some embodiments, step S203 may further include the following steps S2031 to S2034:
[0079] S2031. Determine the second layer numbers of the plurality of first nodes according to the characteristic data of the plurality of first nodes.
[0080] In some embodiments, for any first node, the following steps can be used to determine the second layer number of the first node: determine the path of the first node based on the characteristic data of the first node; if the number of paths of the first node is one, determine the second layer number of the first node based on the path of the first node; if the number of paths of the first node is multiple, determine the path with the longest path length among the multiple paths, and determine the second layer number of the first node based on the path with the longest path length.
[0081] The characteristic data of the first node may include path information of the first node, and the path of the first node and the path length of the path may be determined based on the path information of the first node.
[0082] Optionally, for any first node, the second layer number of the first node can be determined based on the longest path hierarchical algorithm and the path of the first node. Exemplarily, the second layer number of the starting first node of the first graph structure can be configured as the minimum value, and for any first node other than the starting first node among the multiple first nodes, the second layer number can be configured for the first node according to the longest path hierarchical algorithm, wherein the longest path hierarchical algorithm can satisfy the following formula:
[0083]
[0084] in, Can represent the first node The second layer number, Can represent the first node The second layer number, where Indicates the first node Point to the first node .
[0085] For example, in Figure 4 In the example, the first starting node is the first node A, and the second layer number of the first node A can be .
[0086] For the first node B1-1, only the first node A points to the first node B1-1, and the second layer number of the first node B1-1 can be Similarly, 、 、 、 .
[0087] For the first node C1, only the first node B1-1 points to the first node C1, and the second layer number of the first node C1 can be .
[0088] For the first node C2, the first node B1-2 and the first node B1-3 both point to the first node C2. The second layer number of the first node C2 can be:
[0089] .
[0090] For the first node C3, only the first node B2-1 points to the first node C3, and the second layer number of the first node C3 can be .
[0091] For the first node D, only the first node C1 points to the first node D, and the second layer number of the first node D can be Similarly, the second layer number of the first node E2 can be obtained as .
[0092] For the first node E1, the first node D and the first node C3 both point to the first node E1. The second layer number of the first node E1 can be:
[0093] .
[0094] In this method, the second layer number of the first node can be determined based on the path with the longest path length between the first node and the starting first node in the first graph structure. This can avoid missing the second layer numbers of some first nodes in determining the first node, making the determined second layer number of the second node more accurate.
[0095] S2032: Determine at least one second node from the plurality of first nodes according to the dependency relationship between the plurality of node clusters.
[0096] The edge of the second node is used to connect two node clusters, and the edge of the second node is a directed edge pointing to the second node.
[0097] Assume that the plurality of first nodes include the first node and the first node , if the first node and the first node Belong to different node clusters, and the first node The outgoing directed edge points to the first node , the first node can be Determined as the second node, the first node can be Point to the first node The directed edge of is called a cross-cluster edge, which can be expressed as .
[0098] For example, Figure 4 The first graph structure shown may include eight second nodes, namely, first node B1-1, first node B1-2, first node B1-3, first node B2-1, first node B2-2, first node D, first node E1, and first node E2, corresponding to eight cross-cluster edges, which are represented as follows: 、 、 、 、 、 、 and .
[0099] S2033 . For any second node, determine a layer number correction value of the second node based on two node clusters connected by the edge of the second node.
[0100] In some embodiments, the layer number correction value of the second node can be determined by the following steps: determining the number of directed edges connecting the two node clusters; determining the number of directed edges within each node cluster in the two node clusters; and determining the layer number correction value of the second node based on the number of directed edges connecting the two node clusters and the number of directed edges within each node cluster.
[0101] Optionally, the layer number correction value of the second node may satisfy the following formula:
[0102]
[0103] in, Can be the second node The layer number correction value; Weights that can be pre-configured by the user can be used to adjust the importance of cross-cluster edges, for example, The value range is [0.5, 3]; and Can represent node clusters, node clusters The first node The node cluster where it is located, node cluster The first node The node cluster where it is located; Can represent node clusters With node cluster The number of directed edges connecting them; Can represent node clusters the number of internal directed edges; Can represent node clusters the number of internal directed edges; Constants that can be pre-configured for the user, This can be done to prevent the denominator of the formula from being a small positive number of 0.
[0104] In the above formula, the ratio Can be used to reflect node clusters With node cluster The density of inter-cluster edges relative to the density of directed edge couplings within the node clusters.
[0105] For example, Figure 4 As shown, the number of directed edges connecting node cluster 1 and node cluster 2 is 5, the number of directed edges within node cluster 2 is 4, and the number of directed edges within node cluster 1 is 0.
[0106] In this method, the layer number correction value of the second node can be determined in combination with the number of directed edges connecting the two node clusters connected by the second node and the number of directed edges within each node cluster, so that the layer number correction value can reflect the impact of the cross-cluster connection edges of the second node on the internal structure of the two node clusters connected by the second node, so that the second layer number of the second node can be corrected based on the layer number correction value of the second node, so that the first nodes in the node cluster are more compact and the cross-cluster connection edges are clearer.
[0107] S2034. Determine the first layer numbers of the plurality of first nodes according to the second layer numbers of the plurality of first nodes and the layer number correction value of at least one second node.
[0108] In some embodiments, the following steps can be used to determine the first layer numbers of multiple first nodes: determine the second layer numbers of the remaining first nodes in the multiple first nodes as the first layer numbers, and the remaining first nodes are the first nodes in the multiple first nodes except for at least one second node; determine the first layer number of at least one second node based on the second layer number of at least one second node in the multiple first nodes and the layer number correction value of at least one second node.
[0109] Optionally, for any second node, the first layer number of the second node may satisfy the following formula:
[0110]
[0111] in, Can represent the second node The first layer number, Can indicate pointing to the second node The first node connected by the directed edge The first layer number.
[0112] In the above formula, if the first node Node cluster With the second node Node cluster Belong to the same node cluster, , indicating that the layer number allocation tends to be compact; if the node cluster With node cluster Belong to different node clusters, and the node clusters With node cluster The density of inter-cluster edges between is high. Large, first node The first layer number increases accordingly.
[0113] In this method, by calculating the layer number correction value of the second node, the second layer number of the second node determined based on the longest path hierarchical algorithm can be corrected according to the layer number correction value, so that the first nodes in the node cluster are more compact and the cross-cluster connection edges are clearer.
[0114] S204 : Determine updated coordinates of the plurality of first nodes according to the dependency relationship between the plurality of node clusters and the first layer numbers of the plurality of first nodes, and update the first graph structure based on the updated coordinates of the plurality of first nodes to obtain a second graph structure.
[0115] For any first node, the updated coordinates of the first node may include a first coordinate and a second coordinate. For example, if the first graph structure is arranged horizontally by layer, the first coordinate may be the horizontal coordinate, and the second coordinate may be the vertical coordinate. If the first graph structure is arranged vertically by layer, the first coordinate may be the vertical coordinate, and the second coordinate may be the horizontal coordinate.
[0116] It should be noted that, according to the dependency relationship between multiple node clusters and the first layer numbers of multiple first nodes, the update coordinates of multiple first nodes are determined. Figure 7 is described in .
[0117] In some embodiments, the coordinates of the plurality of first nodes in the first graph structure may be updated to the updated coordinates of the plurality of first nodes to obtain a second graph structure.
[0118] Optionally, after updating the coordinates of the plurality of first nodes in the first graph structure, edges may be redrawn in the first graph structure to obtain a second graph structure. For example, after updating the coordinates, directed edges between the plurality of first nodes may be redrawn using Bezier curves to obtain the second graph structure, thereby reducing the probability of cross edges in the second graph structure.
[0119] For example, in Figure 3 In the first graph structure, the distances between the first node B2 and the first node B1, and between the first node E1 and the first node E2 are relatively far; after the layout of the first nodes in the first graph structure is adjusted using the method provided in an embodiment of the present application, a second graph structure is obtained, in which the distances between the first node B2 and the first node B1, and between the first node E1 and the first node E2 are more compact.
[0120] The graph structure layout method provided in the embodiment of the present application can extract feature data of multiple first nodes in a first graph structure, and based on the feature data of the multiple first nodes, divide the multiple first nodes into multiple node clusters with dependency relationships, and determine the first layer numbers of the multiple first nodes based on the dependency relationships between the multiple node clusters and the feature data of the multiple first nodes, so as to avoid cross-layer edges or cross-cluster edges in the graph structure layout process as much as possible, thereby improving the readability and layout stability of the graph structure; and, by combining the dependency relationships between the multiple node clusters and the first layer numbers of the multiple first nodes, determine the updated coordinates of the multiple first nodes, and update the first graph structure based on the updated coordinates of the multiple first nodes to obtain a second graph structure, so as to reduce the range of variation of the coordinates of each first node in the second graph structure in some incremental layout scenarios, so that the second graph structure has higher layout stability and scalability.
[0121] Next, combine Figure 5, a process of dividing a plurality of first nodes into a plurality of node clusters having dependency relationships based on feature data of the plurality of first nodes is described.
[0122] Figure 5 The second flow chart of the graph structure layout method provided in the embodiment of the present application is as follows: Figure 5 As shown, the embodiment of the present application provides a graph structure layout method, which is described in detail as follows:
[0123] S501: Divide the plurality of first nodes into a plurality of node sets having dependency relationships according to feature data of the plurality of first nodes.
[0124] Each node set may include at least one first node.
[0125] Optionally, the plurality of first nodes may be divided into a plurality of node sets having dependency relationships based on at least one of the following items in the characteristic data of the first nodes: path information, label, or type.
[0126] For example, the plurality of first nodes may be divided into a plurality of node sets with dependency relationships in the order of the maximum path length in the path information from short to long, and the maximum path length of the first nodes in each node set is the same. Figure 3 In the figure, the maximum path length between the first node D and the starting first node A of the first graph structure is the same as the maximum path length between the first node E2 and the starting first node A. The first node D and the first node E2 can be divided into a node set.
[0127] S502 : Determine the sum of the modularity of the multiple node sets based on the feature data of the first node in each node set in the multiple node sets.
[0128] Optionally, the sum of the modularity of multiple node sets can satisfy the following formula:
[0129]
[0130] in, It can represent the sum of modularity of multiple node sets; It can represent the total number of multiple node sets in the first graph structure; It can represent the sum of the weights of directed edges within a set of nodes; It can represent the total weight of all directed edges connected to each first node in a node set (including directed edges within the node set and directed edges connected to the first node outside the node set); It can represent the sum of the weights of all directed edges in the first graph structure; It can represent the proportion of directed edges within a certain node set in the actual network; It can represent the proportion of directed edges that are expected to fall inside a certain set of nodes in a random network. and The larger the difference between the two, the more obvious the structure of the node set is, that is, the actual internal connections are far more than random connections, indicating that the clustering is reasonable.
[0131] S503 : Merge multiple node sets according to the sum of a preset merging threshold and the modularity to obtain multiple node clusters with dependency relationships.
[0132] For example, it is assumed that the preset merging threshold is , for the first nodes in the first graph structure A collection of nodes, is an integer greater than 2, calculated based on step S502 The sum of the modularity of the node set is ;against If any two node sets in the node sets are merged, the merged node is calculated based on step S502. The sum of the modularity of the node set is ;like , then it is determined that the merger is feasible and the two node sets can be merged into one node set. , then it is determined that the merger is not feasible, and the two node sets will continue to be retained.
[0133] It is understandable that if these two node sets can be merged, the merged The node sets continue to be merged in the above manner until the merging of the node sets cannot make the sum of the modularity changes greater than the preset merging threshold. In this case, each node set can be determined as a node cluster.
[0134] For example, the user can flexibly configure the preset merging threshold according to business needs. .
[0135] In the process of merging multiple node sets, a multi-level structure can be generated. Figure 6 , the multi-level structure is described. Figure 6 For a schematic diagram of the node set merging process provided in the embodiment of this application, please refer to Figure 6 , a three-layer structure can be generated during the merging process of the node set, wherein the first-layer structure is the five first nodes in the first graph structure; the second-layer structure is the three node sets obtained by merging the five first nodes; and the third-layer structure is the two node clusters obtained by merging the three node sets.
[0136] The method may be executed by an electronic device; or, a semantic feature extraction and clustering module may be provided in the electronic device, and the method may be executed by the semantic feature extraction and clustering module.
[0137] The graph structure layout method provided in the embodiment of the present application can extract feature data of multiple first nodes in the first graph structure, and based on the feature data of the multiple first nodes, divide the multiple first nodes into multiple node clusters with dependencies, so that the graph structure layout can be quickly and conveniently performed based on these multiple node clusters in the future.
[0138] Next, combine Figure 7 , a process of determining updated coordinates of multiple first nodes based on dependency relationships between multiple node clusters and first layer numbers of multiple first nodes is described.
[0139] Figure 7 The third flow chart of the graph structure layout method provided in the embodiment of the present application is as follows: Figure 7 As shown, the embodiment of the present application provides a graph structure layout method, which is described in detail as follows:
[0140] S701: Determine an arrangement order of multiple node clusters according to dependency relationships among the multiple node clusters.
[0141] Optionally, for any two node clusters among the multiple node clusters: a first node cluster and a second node cluster, if the first node cluster depends on the second node cluster, the second node cluster is arranged before the first node cluster.
[0142] For example, Figure 4 The arrangement order of the three node clusters shown may be: node cluster 1 > node cluster 2 > node cluster 3.
[0143] This step may be performed by the electronic device; or, the electronic device may be provided with an intra-layer sorting and cluster constraint module, and this step may be performed by the intra-layer sorting and cluster constraint module.
[0144] S702: Divide the plurality of first nodes into a plurality of node layers having dependency relationships according to the first layer numbers of the plurality of first nodes.
[0145] The first node in each node layer has the same first layer number.
[0146] Figure 8 This is a schematic diagram of the node layer division provided in the embodiment of this application. Figure 8The first graph structure includes 12 first nodes. Based on the first layer numbers of the 12 first nodes, the 12 first nodes can be divided into 5 node layers, wherein node layer 1 includes 1 first node, node layer 2 includes 5 first nodes, node layer 3 includes 3 first nodes, node layer 4 includes 1 first node, and node layer 5 includes 2 first nodes.
[0147] This step may be performed by the electronic device; or, a hierarchical layout module may be provided in the electronic device, and this step may be performed by the hierarchical layout module.
[0148] S703: Determine updated coordinates of multiple first nodes according to the arrangement order of multiple node layers and multiple node clusters.
[0149] In some embodiments, the following steps can be used to determine the updated coordinates of multiple first nodes: for any node layer, determine at least one node cluster within the node layer, and the arrangement order of the first nodes of each node cluster within the node layer; determine the updated coordinates of multiple first nodes based on the first layer numbers corresponding to the multiple node layers, the arrangement order of at least one node cluster within each node layer in the multiple node layers, and the arrangement order of the first nodes of at least one node cluster within each node layer.
[0150] If the node layer includes multiple node clusters, these multiple node clusters can be segmented and sorted according to the order of the node clusters. Figure 8 In the example, there are two node clusters (node cluster 2 and node cluster 3) in node layer 2. The arrangement order of node cluster 2 is earlier than that of node cluster 3. Therefore, node cluster 2 can be arranged first, and then node cluster 3.
[0151] The first node of each node cluster within the node layer means that the first node is both within the node cluster and within the node layer. Figure 8 In the example, the node cluster 2 has three first nodes in the node layer 2, namely the first node B1-1, the first node B1-2 and the first node B1-3.
[0152] Assume that the node layer Li includes n first nodes , that is, Li={ First, perform paragraph sorting according to at least one node cluster within the node layer, Li=C i,1 ||C i,2 ||……||C i,m , It can represent the node set consisting of the first node belonging to the kth node cluster in the i-th node layer Li, where k=1, 2, ..., m.
[0153] A local optimization algorithm (e.g., centroid method or small-scale enumeration method) can be used to sort the nodes within the node set consisting of the first node belonging to the k-th node cluster in the node layer Li to ensure the stability of the sorting result, so that when the first node is added in some incremental layout scenarios, the stable position of the sorted node cluster will not be affected.
[0154] Optionally, a center of gravity method or a small-scale enumeration method may be used to determine the arrangement order of the first nodes within the node cluster.
[0155] For example, the centroid method may satisfy the following formula:
[0156]
[0157] in, Can represent the first node The center of gravity position; Can represent the first node The parent node set of Can represent the first node The first node in the previous node layer of the node layer The center of gravity position.
[0158] Exemplarily, the small-scale enumeration method may be applicable to the case where the number of first nodes in the node cluster is less than or equal to 6. The small-scale enumeration method may determine the minimum cross arrangement of the first nodes in the node cluster through permutations and combinations.
[0159] An embodiment of the present application also provides a method for optimizing inter-cluster crossings, which can abstract the node set consisting of the first node belonging to each node cluster in each node layer into a single block, construct a "cluster sequence", and use the "edge crossing number of the cluster center" as the optimization target. The median method or local exchange strategy is used to move each node cluster from its current position to the position closest to the center of gravity to reduce inter-cluster edge crossings.
[0160] The median method can be used to calculate the average position of the node set consisting of the first node belonging to each node cluster in each node layer in the adjacent nodes of the previous layer.
[0161]
[0162] in, Can represent a collection of nodes The average position of the adjacent nodes in the previous layer, Can represent a collection of nodes In the previous layer ( The set of adjacent nodes of the layer (that is, the first node connected to it by a directed edge).
[0163] The median method can be used to set a hierarchical graph and layout the node set composed of the first nodes of a certain node layer. The steps of the median method may include: 1. For the node set composed of the first nodes of each node cluster in the node layer, find the node set composed of the first nodes of each node cluster and the node set connected to the previous node layer, and determine the average position of the node set composed of the first nodes of each node cluster; 2. Sort the node set composed of the first nodes of all node clusters in the current node layer according to this average position; 3. Assign a new horizontal position to the node set composed of the first nodes of each node cluster for layout or further iteration. It can be understood that if the node set composed of the first nodes of each node cluster has multiple "horizontal positions" in the previous node layer, the average value or median of the multiple "horizontal positions" of the node set composed of the first nodes of each node cluster can be determined as the average position of the node set composed of the first nodes of each node cluster.
[0164] Alternatively, the calculated , sort the multiple node clusters of the node layer so that the directed edges connecting the node layer and the node layer of the previous layer are as neat as possible.
[0165] Local exchange means that you can try to exchange the positions of two adjacent node clusters in the node layer. If the number of crossovers decreases after the exchange, the exchange is retained; repeat the process until the local optimum is reached.
[0166] By performing inter-cluster cross-optimization processing, each node layer can be visually presented as a cluster block of multiple node clusters, with stable internal node positions, which facilitates semantic distinction; cross-layer edge connections are straighter and more concentrated, significantly reducing visual clutter; when the graph structure grows dynamically, only the clusters where the newly added nodes are located and the clusters they affect need to be locally sorted, without affecting the stability of the overall graph structure.
[0167] This step may be performed by the electronic device; or, the electronic device may be provided with a coordinate allocation and virtual node processing module, and this step may be performed by the coordinate allocation and virtual node processing module.
[0168] Next, combine Figure 9 , describes the process of determining the updated coordinates of multiple first nodes based on the first layer numbers corresponding to multiple node layers, the arrangement order of at least one node cluster within multiple node layers, and the arrangement order of the first nodes of at least one node cluster within each node layer.
[0169] Figure 9 The fourth flow chart of the graph structure layout method provided in the embodiment of the present application is as follows: Figure 9 As shown, the embodiment of the present application provides a graph structure layout method, which is described in detail as follows:
[0170] S901: Determine first coordinates of a first node in a plurality of node layers according to first layer numbers and inter-layer distances corresponding to the plurality of node layers.
[0171] Optionally, for the first node in any node layer, the first coordinate of the first node may satisfy the following formula:
[0172]
[0173] in, Can represent the first node The first coordinate of Can represent the first node The first layer number; Can represent the interlayer distance.
[0174] The layer spacing refers to the distance between two node layers, and the layer spacing can be used to visually separate the two node layers. For example, the user can pre-configure the layer spacing through the electronic device according to business needs.
[0175] The node layer may include at least one first node, and the first coordinates of the at least one first node may be the same. For example, the first coordinate may be a horizontal coordinate. Figure 8 In the example, node layer 2 includes 5 first nodes, and the horizontal coordinates of these 5 first nodes can be the same. The horizontal coordinate difference between node layer 1 and node layer 2, the horizontal coordinate difference between node layer 2 and node layer 3, and the horizontal coordinate difference between node layer 3 and node layer 4 can all be layer spacing. .
[0176] Optionally, if the number of directed edges connecting any two adjacent node layers is large, that is, the directed edge density between the two node layers is high, the layer spacing between the two node layers can be automatically adjusted based on the non-uniform layer spacing strategy to make room for edge routing.
[0177] Optionally, the method can also use an inter-layer foldable view mechanism to display multiple node layers, supporting interactive browsing of large graphs of multiple node layers. The inter-layer foldable view mechanism allows users to dynamically fold (hide) or expand (show) some of the node layers.
[0178] Users can view all node layers in multiple node layers in the large graph, or users can collapse (hide) some node layers that they are not interested in in the large graph. In this scenario, the layer spacing between different node layers can be adaptively adjusted dynamically. For example, there are 8 node layers, assuming that the layer spacing between each node layer is , the arrangement order of these 8 node layers is: node layer 1 > node layer 2 > node layer 3 > node layer 4 > node layer 5 > node layer 6 > node layer 7 > node layer 8. If the user collapses (hides) node layers 3 to 5, in this case, in the displayed second graph structure, the layer spacing between node layers 2 and 6 needs to be adjusted to .
[0179] S902. Determine the second coordinates of the first node in multiple node layers based on the arrangement order of at least one node cluster in each node layer, the arrangement order of the first node of at least one node cluster in each node layer, and the starting second coordinates of at least one node cluster in each node layer.
[0180] For any node layer, if the node layer includes a node cluster, the second coordinates of each first node in the node layer can be determined based on the arrangement order of the first nodes of the node cluster within the node layer, the starting second coordinates of the node cluster in the node layer and the preset node distance within the cluster.
[0181] For example, in Figure 8 In FIG, the starting second coordinate of the node cluster 2 in the node layer 2 may be the vertical coordinate of the first node B1 - 1 .
[0182] Optionally, the second coordinate of the first node of the node layer may be determined using the following formula:
[0183]
[0184] in, Can represent the first node The second coordinate of Can indicate the Node clusters In the Node layer The starting second coordinate of It can represent the preset distance between nodes in the cluster; Can represent the first node In the node cluster Internal sorting order.
[0185] For example, a node cluster There are three first nodes in the cluster, namely: first node 1, first node 2 and first node 3. The order of these three first nodes is: first node 1> first node 2> first node 3. Among them, first node 1, first node 2 and first node 3 are in the node cluster. The order of arrangement is 1, 2, and 3 respectively.
[0186] For any node layer, if the node layer includes S node clusters, where S is an integer greater than 1, the width W of the node layer can be divided into S cluster block segments according to the arrangement order of the S node clusters in the node layer and the preset inter-cluster distance Δx. Each cluster block segment is used to arrange the first node in a node cluster in the node layer, and the distance between any two cluster block segments is the inter-cluster distance Δx. Optionally, the width of each cluster block segment = (W - (S - 1) × Δx) / S.
[0187] The inter-cluster distance can be used to visually isolate node clusters at different node levels, and the intra-cluster node distance can be used to visually isolate different first nodes within each node cluster at a node level. For example, a user can pre-configure the inter-cluster distance and intra-cluster node distance through an electronic device based on business needs.
[0188] The method may be executed by an electronic device; or, a coordinate allocation and virtual node processing module may be provided in the electronic device, and the method may be executed by the coordinate allocation and virtual node processing module.
[0189] The graph structure layout method provided in an embodiment of the present application determines the updated coordinates of multiple first nodes by combining the dependency relationship between multiple node clusters and the first layer numbers of multiple first nodes, so as to reduce the range of variation of the coordinates of each first node in the second graph structure in some incremental layout scenarios, so that the second graph structure has higher layout stability and scalability.
[0190] In some embodiments, after determining the updated coordinates of the plurality of first nodes, a virtual node may be inserted into the plurality of first nodes based on a cluster-aware virtual node insertion mechanism. Figure 10 , describes the process of inserting a virtual node.
[0191] Figure 10 The fifth flow chart of the graph structure layout method provided in the embodiment of the present application is as follows: Figure 10 As shown, the embodiment of the present application provides a graph structure layout method, which is described in detail as follows:
[0192] S1001. Determine at least one group of node pairs according to first layer numbers of multiple first nodes.
[0193] Each node pair may include an initiating first node and a receiving first node, a directed edge sent by the initiating first node is connected to the receiving first node, the node cluster in which the initiating first node is located is different from the node cluster in which the receiving first node is located, and a layer number difference between a first layer number of the initiating first node and a first layer number of the receiving first node is greater than a preset threshold. For example, the preset threshold may be set to 1.
[0194] The initiating first node is a boundary node of the node cluster to which it belongs, and the receiving first node may also be a boundary node of the node cluster to which it belongs.
[0195] The node cluster where the initiating first node is located is different from the node cluster where the receiving first node is located, that is, the directed edge sent by the initiating first node is a cross-cluster edge; and, if the difference between the first layer number of the initiating first node and the first layer number of the receiving first node is greater than a preset threshold, it is determined that the directed edge between the initiating first node and the receiving first node is a cross-cluster and cross-multi-layer edge. In this case, a virtual node needs to be inserted for processing.
[0196] For example, in Figure 8 In the example, the initiating first node is the first node C1, the receiving first node is the first node E2, and the directed edge between the first node C1 and the first node E2 is a cross-cluster and cross-multi-layer edge. A virtual node needs to be inserted between the first node C1 and the first node E2.
[0197] S1002: For any group of node pairs, insert at least one virtual node between an initiating first node and a receiving first node of the node pair.
[0198] Optionally, the first layer number of at least one virtual node may be determined according to the first layer number of the initiating first node and the first layer number of the receiving first node.
[0199] For example, the first layer number of the virtual node may satisfy the following formula:
[0200]
[0201] in, It can represent the first node inserted between the initiating first node and the receiving first node. The first layer number of the virtual node, Take 1, 2, ..., , It can represent the first layer number of the initiating first node, It can represent the first layer number of the receiving first node.
[0202] If the inserted virtual node is inside the node cluster, the second coordinate of the virtual node is the same as the second coordinate of the initiating first node. If the inserted virtual node is located at the edge of the node cluster, the second coordinate of the virtual node can be offset by a preset distance from the second coordinate of the initiating first node toward the node cluster where the receiving second node is located. This preset distance is used to guide the direction of the directed edge of the virtual node to reduce the return of the edge outside the cluster.
[0203] After the coordinates of the virtual nodes are determined, Bezier curves can be used to implement edge curved path routing.
[0204] The method may be executed by an electronic device; or, a coordinate allocation and virtual node processing module may be provided in the electronic device, and the method may be executed by the coordinate allocation and virtual node processing module.
[0205] The graph structure layout method provided in an embodiment of the present application inserts virtual nodes between two first nodes connected by cross-cluster and cross-multi-layer edges to achieve segmented processing of cross-cluster and cross-multi-layer edges, which helps to reduce the number of fragmented nodes and reduce cross-complexity, thereby reducing the overall complexity of the graph structure; this method can avoid inserting redundant virtual nodes in continuous layers of the same cluster, which is beneficial to reducing the number of inserted virtual nodes and maintaining the visual coherence of the graph structure.
[0206] In some embodiments, after obtaining the second graph structure, some new nodes may be inserted into the second graph structure to implement incremental processing of the nodes of the second graph structure. Figure 11 , the process of incremental processing of nodes of the second graph structure is explained.
[0207] Figure 11 The sixth flow chart of the graph structure layout method provided in the embodiment of the present application is as follows: Figure 11 As shown, the embodiment of the present application provides a graph structure layout method, which is described in detail as follows:
[0208] S1101: Determine adjacent nodes corresponding to multiple candidate nodes in the second graph structure.
[0209] Optionally, user input information may be obtained, and the user input information may be used to indicate adjacent nodes corresponding to multiple candidate nodes in the second graph structure. The number of adjacent nodes corresponding to each candidate node may be one or more.
[0210] For example, the user input information may be to insert candidate node 1 between first node 1 and first node 2, and the adjacent nodes of candidate node 1 may be first node 1 and first node 2.
[0211] S1102: Determine an insertion order of the multiple candidate nodes according to the adjacent nodes corresponding to the multiple candidate nodes in the second graph structure.
[0212] Optionally, the following steps can be used to determine the insertion order of multiple candidate nodes: for any candidate node, determine the node cluster corresponding to the candidate node in the second graph structure, and the in-degree and out-degree of the candidate node in the second graph structure based on the adjacent nodes corresponding to the candidate node in the second graph structure; determine the insertion score of each candidate node based on the node cluster corresponding to each candidate node, and the in-degree and out-degree of each candidate node in the second graph structure; determine the insertion order of the multiple candidate nodes based on the insertion scores of the multiple candidate nodes.
[0213] In some embodiments, the insertion score of a candidate node may satisfy the following formula:
[0214]
[0215] in, Can represent candidate nodes The insertion score of and To adjust the parameters, users can set the adjustment parameters based on business needs; Can represent the candidate node in the second graph structure The number of directed edges, i.e., candidate nodes The in-degree of Can represent candidate nodes The number of directed edges issued to the first node arranged in the second graph structure, that is, the candidate node The out-degree of Can represent candidate nodes With candidate nodes Corresponding node cluster The semantic similarity between It can represent the inter-cluster correction parameter to avoid candidate nodes Insertion destroys node clusters clustering structure to reduce layout fragmentation.
[0216] Optionally, The following formula can be satisfied:
[0217]
[0218] in, Can represent candidate nodes The corresponding set of adjacent nodes in the second graph structure; Can represent candidate nodes The corresponding node cluster; Can represent candidate nodes The corresponding adjacent nodes in the second graph structure The corresponding node cluster; Can be expressed and This parameter is 1 when different; Can represent adjacent nodes With candidate nodes The semantic importance weight of the directed edge between them.
[0219] By Introduced into the calculation formula , can be based on In the process of determining the insertion score of the candidate node using the calculation formula, the candidate node that is closer to the current cluster structure of each node cluster in the second graph structure is preferentially inserted to maintain the semantic local consistency of each node cluster in the second graph structure.
[0220] S1103 : Insert multiple candidate nodes into the second graph structure according to the insertion order of the multiple candidate nodes and the adjacent nodes corresponding to each candidate node in the second graph structure.
[0221] In some embodiments, after inserting the candidate node, the coordinates of the candidate node can be determined. The coordinates of the candidate node may include a first coordinate and a second coordinate. The method for determining the first coordinate and the second coordinate can refer to the method for determining the first coordinate and the second coordinate of the first node shown in the above embodiment, and will not be repeated here.
[0222] According to the insertion order of multiple candidate nodes, after each k candidate nodes are inserted, local layout rearrangement optimization is performed on the second graph structure, and the rearrangement range is limited to 2 to 3 adjacent node layers. In the process of performing local layout rearrangement optimization, the position of the first node that has not been updated in the second graph structure is fixed to avoid global disturbance of the second graph structure.
[0223] The method may be executed by an electronic device; or, a progressive incremental layout processing module may be provided in the electronic device, and the method may be executed by the progressive incremental layout processing module.
[0224] The graph structure layout method provided in the embodiment of the present application adopts local fine-tuning instead of global rearrangement in the process of dynamically adjusting the generated second graph structure, which is beneficial to improving the readability, stability and scalability of the graph structure.
[0225] Figure 12 A schematic diagram of a structure layout device for a graph structure provided in an embodiment of the present application is shown in FIG. Figure 12 As shown, the graph structure layout device 120 includes an acquisition module 121 and a processing module 122 .
[0226] An acquisition module 121 is configured to acquire a first graph structure, where the first graph structure includes a plurality of first nodes connected by directed edges.
[0227] a processing module 122 configured to perform feature extraction processing on the first graph structure to obtain feature data of the plurality of first nodes, and based on the feature data of the plurality of first nodes, divide the plurality of first nodes into a plurality of node clusters having dependency relationships, each node cluster including at least one first node;
[0228] The processing module 122 is further configured to determine first layer numbers of the plurality of first nodes based on dependency relationships between the plurality of node clusters and characteristic data of the plurality of first nodes;
[0229] The processing module 122 is further configured to determine updated coordinates of multiple first nodes according to the dependencies between multiple node clusters and the first layer numbers of multiple first nodes, and update the first graph structure based on the updated coordinates of the multiple first nodes to obtain a second graph structure.
[0230] In one implementation, for any first node, the feature data of the first node includes attribute data and structure data of the first node, wherein:
[0231] The attribute data includes an identifier, type information, and weight of the first node, the type information includes a label and / or type of the first node, and the weight includes a node weight of the first node and an edge weight corresponding to the first node;
[0232] The structural data includes the out-degree and in-degree of the first node, as well as the path information between the first node and the starting first node in the first graph structure. The out-degree of the first node is the number of directed edges emitted by the first node, and the in-degree of the first node is the number of directed edges pointing to the first node.
[0233] In one implementation, the processing module 122 is specifically configured to:
[0234] Dividing the plurality of first nodes into a plurality of node sets having a dependency relationship according to feature data of the plurality of first nodes, each node set including at least one first node;
[0235] determining a sum of modularity of the plurality of node sets based on feature data of a first node in each of the plurality of node sets;
[0236] According to the sum of the preset merging threshold and the modularity, multiple node sets are merged to obtain multiple node clusters with dependencies.
[0237] In one implementation, the processing module 122 is specifically configured to:
[0238] determining second layer numbers of the plurality of first nodes according to the characteristic data of the plurality of first nodes;
[0239] Determining at least one second node from the plurality of first nodes according to the dependency relationship between the plurality of node clusters, wherein the edge of the second node is used to connect the two node clusters, and the edge of the second node is a directed edge pointing to the second node;
[0240] For any second node, determine the layer number correction value of the second node according to the two node clusters connected by the edge of the second node;
[0241] The first layer numbers of the plurality of first nodes are determined according to the second layer numbers of the plurality of first nodes and the layer number correction value of at least one second node.
[0242] In one implementation, for any first node, the processing module 122 is specifically configured to:
[0243] determining a path of the first node according to the characteristic data of the first node;
[0244] If the number of paths of the first node is one, determining the second layer number of the first node according to the path of the first node;
[0245] If there are multiple paths to the first node, a path with the longest path length is determined among the multiple paths, and the second layer number of the first node is determined based on the path with the longest path length.
[0246] In one implementation, the processing module 122 is specifically configured to:
[0247] Determining a layer number correction value of the second node according to two node clusters connected by an edge of the second node includes:
[0248] Determine the number of directed edges connecting two node clusters;
[0249] Determine the number of directed edges within each of the two node clusters;
[0250] The layer number correction value of the second node is determined according to the number of directed edges connecting the two node clusters and the number of directed edges within each node cluster.
[0251] In one implementation, the processing module 122 is specifically configured to:
[0252] Determine the second layer numbers of the remaining first nodes in the plurality of first nodes as the first layer numbers, the remaining first nodes being the first nodes in the plurality of first nodes except for the at least one second node;
[0253] The first layer number of at least one second node among the plurality of first nodes is determined according to the second layer number of at least one second node and the layer number correction value of at least one second node.
[0254] In one implementation, the processing module 122 is specifically configured to:
[0255] Determine the arrangement order of multiple node clusters according to the dependency relationship between the multiple node clusters;
[0256] Dividing the plurality of first nodes into a plurality of node layers having a dependency relationship according to the first layer numbers of the plurality of first nodes, wherein the first layer numbers of the first nodes in each node layer are the same;
[0257] According to the arrangement order of the plurality of node layers and the plurality of node clusters, the updated coordinates of the plurality of first nodes are determined.
[0258] In one implementation, the processing module 122 is specifically configured to:
[0259] For any node layer, determining at least one node cluster within the node layer and an arrangement order of the first node of each node cluster within the node layer;
[0260] The updated coordinates of multiple first nodes are determined based on the first layer numbers corresponding to multiple node layers, the arrangement order of at least one node cluster within each node layer in the multiple node layers, and the arrangement order of the first nodes of at least one node cluster within each node layer.
[0261] In one implementation, the processing module 122 is specifically configured to:
[0262] Determining first coordinates of first nodes in the plurality of node layers according to first layer numbers and layer spacings corresponding to the plurality of node layers;
[0263] The second coordinates of the first node in the multiple node layers are determined based on the arrangement order of at least one node cluster in each node layer, the arrangement order of the first node of at least one node cluster in each node layer, and the starting second coordinates of at least one node cluster in each node layer.
[0264] In one implementation, after determining the updated coordinates of the plurality of first nodes, the processing module 122 is specifically configured to:
[0265] Determine at least one group of node pairs based on the first layer numbers of the plurality of first nodes, each node pair including an initiating first node and a receiving first node, a directed edge sent by the initiating first node being connected to the receiving first node, a node cluster in which the initiating first node is located is different from a node cluster in which the receiving first node is located, and a layer number difference between the first layer number of the initiating first node and the first layer number of the receiving first node is greater than a preset threshold;
[0266] For any set of node pairs, at least one virtual node is inserted between an initiating first node and a receiving first node of the node pair.
[0267] In one implementation, after obtaining the second graph structure, the processing module 122 is specifically configured to:
[0268] Determine adjacent nodes corresponding to the plurality of candidate nodes in the second graph structure;
[0269] Determining an insertion order of the plurality of candidate nodes according to adjacent nodes corresponding to the plurality of candidate nodes in the second graph structure;
[0270] The plurality of candidate nodes are inserted into the second graph structure according to an insertion order of the plurality of candidate nodes and adjacent nodes corresponding to each candidate node in the second graph structure.
[0271] In one implementation, the processing module 122 is specifically configured to:
[0272] For any candidate node, determine the node cluster corresponding to the candidate node and the in-degree and out-degree of the candidate node in the second graph structure according to the adjacent nodes corresponding to the candidate node in the second graph structure;
[0273] Determine the insertion score of each candidate node according to the node cluster corresponding to each candidate node and the in-degree and out-degree of each candidate node in the second graph structure;
[0274] An insertion order of the multiple candidate nodes is determined according to the insertion scores of the multiple candidate nodes.
[0275] For the description of the features in the embodiment corresponding to the graph structure layout device, reference can be made to the relevant description of the embodiment corresponding to the graph structure layout method, which will not be repeated here.
[0276] Figure 13 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 13 As shown, the electronic device 130 provided in this embodiment includes: at least one processor 131 and a memory 132. Optionally, the electronic device 130 also includes a communication component 133. The processor 131, the memory 132 and the communication component 133 are connected via a bus.
[0277] During the specific implementation process, at least one processor 131 executes the computer-executable instructions stored in the memory 132 , so that at least one processor 131 executes the above-mentioned graph structure layout method embodiment.
[0278] The specific implementation process of the processor 131 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.
[0279] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the application may be directly executed by a hardware processor or by a combination of hardware and software modules within the processor.
[0280] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage.
[0281] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.
[0282] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned graph structure layout method embodiments when run.
[0283] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0284] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above-mentioned graph structure layout method embodiments are implemented.
[0285] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned graph structure layout method embodiments are implemented.
[0286] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0287] The above is a detailed introduction to a graph structure layout method, electronic device and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A graph structure layout method, characterized in that: include: Acquire a first graph structure, where the first graph structure includes a plurality of first nodes, and the plurality of first nodes are connected by directed edges; performing feature extraction processing on the first graph structure to obtain feature data of the plurality of first nodes, and dividing the plurality of first nodes into a plurality of node clusters having dependency relationships based on the feature data of the plurality of first nodes, each node cluster including at least one first node; determining first layer numbers of the plurality of first nodes according to dependency relationships between the plurality of node clusters and characteristic data of the plurality of first nodes; According to the dependency relationship between the multiple node clusters and the first layer numbers of the multiple first nodes, the updated coordinates of the multiple first nodes are determined, and the first graph structure is updated based on the updated coordinates of the multiple first nodes to obtain a second graph structure.
2. The method according to claim 1, characterized in that For any first node, the characteristic data of the first node includes the attribute data and structure data of the first node, wherein: The attribute data includes an identifier, type information, and weight of the first node, wherein the type information includes a label and / or type of the first node, and the weight includes a node weight of the first node and an edge weight corresponding to the first node; The structural data includes the out-degree and in-degree of the first node, and the path information between the first node and the starting first node in the first graph structure. The out-degree of the first node is the number of directed edges emitted by the first node, and the in-degree of the first node is the number of directed edges pointing to the first node.
3. The method according to claim 1 or 2, characterized in that Dividing the plurality of first nodes into a plurality of node clusters having dependency relationships based on the feature data of the plurality of first nodes includes: Dividing the plurality of first nodes into a plurality of node sets having a dependency relationship according to the feature data of the plurality of first nodes, each node set including at least one first node; determining a sum of modularity of the plurality of node sets based on feature data of a first node in each node set in the plurality of node sets; The plurality of node sets are merged according to the sum of a preset merging threshold and the modularity to obtain the plurality of node clusters having dependency relationships.
4. The method according to claim 1 or 2, characterized in that Determining first layer numbers of the plurality of first nodes according to dependency relationships between the plurality of node clusters and feature data of the plurality of first nodes includes: determining second layer numbers of the plurality of first nodes according to the characteristic data of the plurality of first nodes; Determining at least one second node from the plurality of first nodes according to the dependency relationship between the plurality of node clusters, wherein an edge of the second node is used to connect two node clusters, and the edge of the second node is a directed edge pointing to the second node; For any second node, determine a layer number correction value of the second node according to two node clusters connected by an edge of the second node; The first layer numbers of the plurality of first nodes are determined according to the second layer numbers of the plurality of first nodes and the layer number correction value of the at least one second node.
5. The method according to claim 4, characterized in that For any first node, determining the second layer number of the first node according to the characteristic data of the first node includes: determining a path to the first node based on the characteristic data of the first node; If the number of paths to the first node is one, determining a second layer number of the first node according to the path to the first node; If there are multiple paths to the first node, a path with the longest path length is determined among the multiple paths, and the second layer number of the first node is determined based on the path with the longest path length.
6. The method according to claim 4, characterized in that Determining a layer number correction value of the second node according to two node clusters connected by an edge of the second node includes: Determining the number of directed edges connecting the two node clusters; Determining the number of directed edges within each of the two node clusters; The layer number correction value of the second node is determined according to the number of directed edges connecting the two node clusters and the number of directed edges within each node cluster.
7. The method according to claim 4, characterized in that Determining the first layer numbers of the plurality of first nodes according to the second layer numbers of the plurality of first nodes and the layer number correction value of the at least one second node includes: Determine the second layer numbers of the remaining first nodes in the plurality of first nodes as the first layer numbers, the remaining first nodes being the first nodes in the plurality of first nodes excluding the at least one second node; The first layer number of the at least one second node among the plurality of first nodes is determined according to the second layer number of the at least one second node and the layer number correction value of the at least one second node.
8. The method according to claim 1, characterized in that Determining updated coordinates of the plurality of first nodes according to the dependency relationships between the plurality of node clusters and the first layer numbers of the plurality of first nodes includes: determining an arrangement order of the plurality of node clusters according to dependency relationships between the plurality of node clusters; Dividing the plurality of first nodes into a plurality of node layers having a dependency relationship according to the first layer numbers of the plurality of first nodes, wherein the first layer numbers of the first nodes in each node layer are the same; The updated coordinates of the plurality of first nodes are determined according to the arrangement order of the plurality of node layers and the plurality of node clusters.
9. The method according to claim 8, characterized in that Determining updated coordinates of the plurality of first nodes according to an arrangement order of the plurality of node layers and the plurality of node clusters includes: For any node layer, determining at least one node cluster within the node layer and an arrangement order of the first node of each node cluster within the node layer; The updated coordinates of the multiple first nodes are determined based on the first layer numbers corresponding to the multiple node layers, the arrangement order of at least one node cluster within each node layer in the multiple node layers, and the arrangement order of the first nodes of at least one node cluster within each node layer.
10. The method according to claim 9, characterized in that Determining updated coordinates of the plurality of first nodes according to first layer numbers corresponding to the plurality of node layers, an arrangement order of at least one node cluster within each of the plurality of node layers, and an arrangement order of first nodes within each of the at least one node cluster within each of the node layers, includes: Determining first coordinates of a first node in the plurality of node layers according to first layer numbers and layer spacings corresponding to the plurality of node layers; The second coordinates of the first node in the multiple node layers are determined based on the arrangement order of at least one node cluster in each node layer, the arrangement order of the first node within each node layer of at least one node cluster, and the starting second coordinates of at least one node cluster in each node layer.
11. The method according to any one of claims 8 to 10, characterized in that After determining the updated coordinates of the plurality of first nodes, the method further includes: Determine at least one group of node pairs based on the first layer numbers of the multiple first nodes, each node pair including an initiating first node and a receiving first node, a directed edge sent by the initiating first node is connected to the receiving first node, a node cluster where the initiating first node is located is different from a node cluster where the receiving first node is located, and a layer number difference between the first layer number of the initiating first node and the first layer number of the receiving first node is greater than a preset threshold; For any set of node pairs, at least one virtual node is inserted between an initiating first node and a receiving first node of the node pair.
12. The method according to any one of claims 8 to 10, characterized in that After obtaining the second graph structure, the method further includes: Determining adjacent nodes corresponding to the plurality of candidate nodes in the second graph structure; Determining an insertion order of the multiple candidate nodes according to adjacent nodes corresponding to the multiple candidate nodes in the second graph structure; The multiple candidate nodes are inserted into the second graph structure according to an insertion order of the multiple candidate nodes and adjacent nodes corresponding to each candidate node in the second graph structure.
13. The method according to claim 12, characterized in that Determining an insertion order of the plurality of candidate nodes according to adjacent nodes corresponding to the plurality of candidate nodes in the second graph structure includes: For any candidate node, determine, in the second graph structure, the node cluster corresponding to the candidate node and the in-degree and out-degree of the candidate node in the second graph structure based on the adjacent nodes corresponding to the candidate node in the second graph structure; Determining an insertion score of each candidate node according to the node cluster corresponding to each candidate node and the in-degree and out-degree of each candidate node in the second graph structure; An insertion order of the multiple candidate nodes is determined according to the insertion scores of the multiple candidate nodes.
14. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the graph structure layout method according to any one of claims 1 to 13 when executing the computer program.
15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the graph structure layout method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Conversion method and device of geological static map
CN105631915A
Layout method and device for directed acyclic graph of batch job and electronic equipment
CN118364140A
Network topology layout method and related equipment
CN118694666A
Force-directed graph layout method and apparatus, electronic device, and storage medium
US20250182353A1