Graph data processing method, graph data processing device and electronic device
By dividing graph data into subgraphs and calculating path distances based on incoming edge weights, the problem of low efficiency in the existing technology is solved and efficient path distance calculation of peer-to-peer incremental graph data is achieved.
Patent Information
- Application Number
- CN202210492698.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-07
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-05-07
AI Technical Summary
The existing technology is inefficient when calculating graph data and needs to update the path distance of nodes multiple times, resulting in high computational complexity.
By dividing the graph data into subgraphs, selecting the nodes to be calculated in the encoding order, determining the path distance based on the incoming edge weight and the target path distance, and repeating the calculation until the target path distance and previous nodes of all nodes are determined, avoiding multiple path updates distance.
It improves the efficiency of graph data processing, reduces computational complexity, and realizes efficient path distance calculation of equivalent incremental graph data.
Smart Images

Figure CN114840523B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a graph data processing method, a graph data processing device and an electronic device. Background Art
[0002] A graph is an abstract data structure used to represent the relationship between objects. It is described using nodes (Vertex) and edges (Edge). Nodes represent objects, and edges represent the relationship between objects. Data that can be abstracted into a graph is called graph data. Graph data usually includes multiple nodes and edges connecting multiple nodes.
[0003] In some cases, multiple nodes in the graph data are encoded sequentially, and the multiple nodes have a start node and an end node, the start node is the first node among all the nodes, and the end node is the last node. There are one or more paths between the start node and the end node, and it is necessary to determine the shortest path or the longest path from the start node to the end node from the multiple paths based on the path distances of the multiple paths. When the path distance between the start node and the end node is determined by the existing technology, starting from the start node, the nodes are traversed, and the end point of each current node is traversed as the neighboring node. The path distance of the neighboring node is determined according to the path distance and the outgoing edge weight of the current node, and the maximum or minimum value is compared with the existing path distance of the neighboring node to determine the path distance of the neighboring node, and the update value is iterated until all nodes are traversed, and the path distance and the previous node of all nodes are returned. Since each node can be a neighboring node of multiple nodes, it may be necessary to update the path distance of the node multiple times for each node, which is inefficient. Summary of the invention
[0004] In view of the above problems, an embodiment of the present invention is proposed to provide a graph data processing method that overcomes the above problems or at least partially solves the above problems, so as to solve the problem of low efficiency in the graph calculation process.
[0005] In order to solve the above problem, the first aspect of the embodiment of the present invention discloses a graph data processing method, which is used to process graph data. According to the coding order of multiple nodes in the graph data, the graph data is divided into multiple subgraphs and non-fixed edges connecting nodes in different subgraphs; each of the subgraphs includes multiple nodes and fixed edges connecting the nodes in the subgraphs; the source node of the non-fixed edge is located before the destination node in the coding order; the method includes:
[0006] Selecting nodes in at least one subgraph from the plurality of subgraphs in sequence as nodes to be calculated according to the encoding order;
[0007] In the case where the node to be calculated has at least one incoming edge, determining the path distance to be selected according to the weight of the incoming edge and the target path distance of the source node connected to the incoming edge; the target path distance of the source node is the longest path distance and / or the shortest path distance among all path distances between the starting node among the multiple nodes and the source node;
[0008] Determine the target path distance of the node to be calculated from all the path distances to be selected, and use the source node corresponding to the target path distance of the node to be calculated as the previous node of the node to be calculated; the target path distance of the node to be calculated is the maximum path distance to be selected corresponding to the longest path distance and / or the minimum path distance to be selected corresponding to the shortest path distance;
[0009] The steps of selecting the node to be calculated, determining the distance of the selected path, and determining the target path distance are repeatedly performed until the target path distances and previous nodes of all the nodes are determined.
[0010] Optionally, determining the distance of the to-be-selected path according to the weight of the incoming edge and the target path distance of a source node connected to the incoming edge includes:
[0011] If the source node connected to the incoming edge is the starting node, the weight of the incoming edge is used as the distance of the path to be selected;
[0012] If the target path distance of the source node connected to the incoming edge is predetermined, the weight of the incoming edge and the target path distance of the connected source node are summed to obtain the path distance to be selected;
[0013] If the target path distance of the source node connected to the incoming edge is not determined in advance, the summing step is performed after the target path distance of the source node connected to the incoming edge is determined to obtain the candidate path distance.
[0014] Optionally, the method further comprises:
[0015] When the node to be calculated is a node other than the starting node and has no incoming edge, the target path distance between the node to be calculated and the starting node is set to a first preset value, and the previous node of the node to be calculated is set to a second preset value; the first preset value is an infinitesimal value corresponding to the longest path distance value and / or an infinite value corresponding to the shortest path distance value; the second preset value indicates that the previous node of the node to be calculated is empty.
[0016] Optionally, determining the distance of the to-be-selected path according to the weight of the incoming edge and the target path distance of a source node connected to the incoming edge includes:
[0017] The step of determining the distance of the path to be selected is performed on the nodes to be calculated in the at least one selected subgraph in sequence according to the coding order.
[0018] Optionally, the step of sequentially performing the step of determining the distance of the to-be-selected path on the to-be-calculated nodes in the at least one selected subgraph includes:
[0019] For each of the subgraphs, the step of determining the distance of the to-be-selected path is performed on the nodes to be calculated in the subgraph in sequence according to the coding order of the nodes to be calculated in the subgraph.
[0020] A second aspect of an embodiment of the present invention discloses a graph data processing device, the device comprising a processing module having at least one processing unit, wherein the processing unit comprises a plurality of processing sub-units; the processing module is connected to a storage module;
[0021] The storage module is used to store graph data, wherein the graph data is divided into multiple subgraphs and non-fixed edges connecting nodes in different subgraphs according to the coding order of multiple nodes in the graph data; each of the subgraphs includes multiple nodes and fixed edges connecting nodes in the subgraphs; the source node of the non-fixed edge is located before the destination node in the coding order;
[0022] The processing module is used for, when there is an idle processing unit in the at least one processing unit, sequentially obtaining a node in the subgraph as a node to be calculated for the idle processing unit from the storage module according to the coding order of the multiple nodes, and obtaining the incoming edge information of the node to be calculated for the idle processing unit;
[0023] The processing module is further used to assign the node to be calculated and the incoming edge information of the node to be calculated to a processing sub-unit in the idle processing unit, so that the processing sub-unit determines the path distance to be selected according to the weight of the incoming edge included in the incoming edge information and the target path distance of the target source node connected to the incoming edge when the node to be calculated has at least one incoming edge; the target path distance of the target source node is the longest path distance and / or the shortest path distance among all path distances between the starting node and the target source node among the multiple nodes;
[0024] The processing module is further used to determine and output the target path distance of the node to be calculated from all the path distances to be selected, and to determine and output the target path distance of the node to be calculated as the previous node of the node to be calculated and output the target path distance of the node to be calculated; the target path distance of the node to be calculated is the maximum path distance to be selected corresponding to the longest path distance and / or the minimum path distance to be selected corresponding to the shortest path distance;
[0025] The processing module repeatedly executes the steps of obtaining the nodes to be calculated and the incoming edge information for the idle processing unit, allocating the nodes to be calculated and the incoming edge information, and determining and outputting the target path distance and the previous node until the target path distance and the previous node of all the nodes are output.
[0026] Optionally, it further includes a cache module; the processing module is connected to the cache module, and the processing module is further used to apply for a storage area for each node to be calculated in the cache module, and output the target path distance and the previous node of the node to be calculated to the cache module;
[0027] The cache module is used to receive and store the target path distance and the previous node of the node to be calculated in the storage area of the node to be calculated;
[0028] The processing module is further configured to obtain the target path distance of the target source node from the cache module.
[0029] Optionally, a memory module is further included; the cache module is connected to the memory module, and the cache module is further used to send the target path distances and previous nodes of all the nodes to be calculated in the subgraph to the memory module when the target path distances and previous nodes of all the nodes to be calculated in the subgraph are stored in the cache module, so that the memory module stores the target path distances and previous nodes of all the nodes to be calculated in the subgraph;
[0030] The cache module is further configured to obtain the target path distance of the target source node from the memory module to provide the target path distance of the target source node to the processing module.
[0031] Optionally, the processing sub-unit is used to use the weight of the incoming edge as the path distance to be selected if the target source node is the starting node; if the processing module obtains the target path distance of the target source node from the cache module, the weight of the incoming edge and the target path distance of the target source node are summed to obtain the path distance to be selected; if the processing module does not obtain the target path distance of the target source node from the cache module, wait until the processing module obtains the target path distance of the target source node from the cache module, and then execute the summing step to obtain the path distance to be selected.
[0032] Optionally, the processing sub-unit is also used to set the target path distance between the node to be calculated and the starting node to a first preset value, and set the previous node of the node to be calculated to a second preset value when the node to be calculated is a node other than the starting node and has no incoming edge; the first preset value is an infinitesimal value corresponding to the longest path distance value and / or an infinite value corresponding to the shortest path distance value; the second preset value indicates that the previous node of the node to be calculated is empty.
[0033] A third aspect of an embodiment of the present invention discloses an electronic device, including the graph data processing device as described above.
[0034] In an embodiment of the present invention, according to the coding order of the nodes, at least one node in a subgraph is selected from multiple subgraphs in turn as a node to be calculated. When the node to be calculated has at least one incoming edge, the distance of the path to be calculated is determined according to the weight of the incoming edge and the target path distance of the connected source node, the target path distance of the node to be calculated is determined from all the distances of the paths to be calculated, and the source node corresponding to the target path distance of the node to be calculated is used as the previous node of the node to be calculated, and the steps of selecting the node to be calculated, determining the distance of the path to be calculated, and determining the target path distance are repeated until the target path distance and the previous node of all nodes are determined. For equal-increment graph data, the shortest or longest path distance between the node and the starting node is determined by the weight of the incoming edge, and the path distance of the node does not need to be updated multiple times, which is highly efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram showing the composition of a graph data in an embodiment of the present invention is shown;
[0036] Figure 2 A schematic diagram of a graph data header in an embodiment of the present invention is shown;
[0037] Figure 3 A schematic diagram of storing graph data in an embodiment of the present invention is shown;
[0038] Figure 4 A flowchart showing a method for processing graph data according to an embodiment of the present invention is shown;
[0039] Figure 5 A schematic diagram of the structure of a graph data processing device in an embodiment of the present invention is shown;
[0040] Figure 6 A schematic diagram showing the structure of another graph data processing device in an embodiment of the present invention is shown;
[0041] Figure 7 A structural block diagram of an electronic device in an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0042] In order to facilitate understanding of the embodiments of the present invention, the graph data involved in the embodiments of the present invention is first briefly introduced.
[0043] In some usage scenarios, graph data is divided into multiple subgraphs with the same graph structure and edges connecting nodes in different subgraphs. Multiple subgraphs have the same graph structure, and each subgraph includes multiple nodes and edges connecting nodes in the subgraph. Since the structures of multiple subgraphs are the same, each subgraph has the same edges. The edges between subgraphs may be the same or different. To facilitate distinction, this embodiment names the edges connecting nodes in different subgraphs as non-fixed edges, and the edges connecting nodes in the same subgraph as fixed edges. Figure 1 As shown, Figure 1 A schematic diagram showing the composition of a graph data in an embodiment of the present invention is shown. Taking program operation as an example, the program includes Figure 1 Instructions i0, i1, i2, i3 and i4 are shown, and the processor (Central Processing Unit, CPU) uses pipeline technology to run the program. During the program running process, the execution process of each instruction can be divided into 5 pipeline stages, namely, the dispatch stage, the ready stage, the execute stage, the complete stage and the commit stage. The dispatch stage is represented by symbol D, the preparation stage is represented by symbol R, the execution stage is represented by symbol E, the completion stage is represented by symbol P, and the commit stage is represented by symbol C. When the pipeline technology is used to execute multiple instructions, the CPU processes the multiple instructions in parallel. For example, in the preparation stage of instruction i0, the dispatch stage of instruction i1 can be performed, and in the execution stage of instruction i0, the preparation stage of instruction i1 can be performed, and the dispatch stage of instruction i2 can be performed. By analogy, multiple instructions can be processed in parallel. The division method of the pipeline stage may include but is not limited to the above examples, and this embodiment does not limit this. During the execution of each instruction, the CPU can generate a node for each pipeline stage in the instruction, and the subsequent pipeline stage depends on the execution result of the previous pipeline stage. There is an association between the two stages, and a fixed edge connecting the two nodes can be generated. The source node of the fixed edge is the node of the previous pipeline stage, and the destination node is the node of the next pipeline stage.
[0044] Figure 1Each circle shown can represent a pipeline stage, or a node corresponding to a pipeline stage, and the symbol in the circle is the node number of the node. The line between two nodes represents an edge, and the arrow of the edge indicates the direction of the edge, and the arrow starts from the source node of the edge and points to the destination node. For example, during the execution of instruction i0, for the 5 pipeline stages of instruction i0, 5 sequential nodes D0, R0, E0, P0 and C0 can be generated according to the execution order of each stage, and the 5 nodes have a coding order from D0 to C0. In some cases, in order to reflect the coding order between each node in the subgraph, the nodes can be encoded with Arabic numerals. While generating the 5 nodes corresponding to instruction i0, 4 fixed edges can be generated, and there is a fixed edge between two adjacent nodes. The source node connected by each fixed edge is the node of the previous pipeline stage, and the destination node is the node of the next pipeline stage. For example, the source node connected by fixed edge 101 is D0, and the destination node is R0. At this time, nodes D0, R0, E0, P0 and C0, as well as fixed edges 101, 102, 103 and 104 form a subgraph 100 belonging to instruction i0. Similarly, a subgraph 200 belonging to instruction i1 and subgraphs belonging to other instructions can be generated. Among them, since instructions i0, i1, i2, i3 and i4 are executed in sequence, the subgraphs of instructions i0, i1, i2, i3 and i4 are sequentially from the subgraph of instruction i0 to the subgraph of instruction i4. All nodes in the entire graph data are encoded sequentially from the first node D0 in the first subgraph corresponding to the first instruction i0 to the last node C4 in the last subgraph corresponding to the last instruction i4. Node D0 is the starting node in the graph data, and node C4 is the ending node. For the encoding order of all nodes, in two adjacent subgraphs, the last node of the previous subgraph is before the first node of the next subgraph, and the inflow node C0 is before the node D1.
[0045] Between two pipeline stages of different instructions, the execution of a pipeline stage in the latter instruction depends on the execution result of a pipeline stage in the former instruction. The two pipeline stages have an association relationship, and a corresponding non-fixed edge can be generated. For example, between instruction i0 and instruction i1, the preparation stage of instruction i1 needs to obtain the execution result of the completion stage of instruction i0, and a non-fixed edge 1021 can be generated. The source node connected by non-fixed edge 1021 is node P0 in subgraph 100, and the destination node is node R1 in subgraph 200. In the encoding order of all nodes, node P0 is before node R1. Similarly, other non-fixed edges in graph data can be generated. Figure 1The graph structures of different subgraphs are the same, different subgraphs have the same number of nodes, and nodes at the same position have the same fixed edges. The position of a node refers to the coding order of the node in all nodes included in the subgraph. For example, subgraph 100 and subgraph 200 have the same number of nodes, node D0 is the first node in subgraph 100, node D1 is the first node in subgraph 200, and node D0 and node D1 are two nodes at the same position. In addition, node D0 and node D1 have the same fixed edges, namely fixed edge 101 and fixed edge 201. Fixed edge 101 points from the first node D0 in subgraph 100 to the second node R0, and fixed edge 201 points from the first node D1 in subgraph 200 to the second node R1. Fixed edge 101 in subgraph 100 corresponds to fixed edge 201 in subgraph 200.
[0046] The electronic device may also obtain the weights of the fixed edges and the non-fixed edges, and store the weights of the fixed edges and the non-fixed edges. Figure 1 In the usage scenario shown, the weight can be the delay time between the pipeline stages corresponding to the two nodes connected by the fixed edge. For example, during the execution of instruction i0, if the delay time between the first time when the dispatch stage is executed and the second time when the preparation stage is executed is 1 clock cycle, the weight of the fixed edge 101 can be set to 1, and if the delay time between the second time when the preparation stage is executed and the third time when the execution stage is executed is 0 clock cycles, the weight of the fixed edge 102 can be set to 0. Similarly, the weight of the fixed edge 103 can be set to 20, and the weight of the fixed edge 104 can be set to 1. Similarly, if the delay time between the fourth time when the completion stage is executed in instruction i0 and the fifth time when the preparation stage is executed in instruction i1 is 10 clock cycles, the weight of the non-fixed edge 1021 can be set to 10. And so on, we can get Figure 1 The weight of each fixed edge and non-fixed edge in .
[0047] exist Figure 1 In the process of obtaining the graph data shown in the figure, the nodes in the graph data are in subgraph units, and the nodes and fixed edges of a subgraph are added each time. Figure 1 The graph data shown can be referred to as equal-increment graph data. It should be noted that the equal-increment graph data is not limited to the usage scenarios in the above examples, and other usage scenarios in actual applications can also be expressed by using the equal-increment graph data. Figure 1 The graph data shown may be automatically generated and stored by the electronic device during operation, or may be acquired and stored from other connected electronic devices.
[0048] In one embodiment, the equal-increment graph data may be stored in a unit compression structure format, and the unit compression structure includes a graph data header and an information set. The graph data header includes structural information of multiple subgraphs, and the structural information is used to describe the nodes and fixed edges in the graph structure. The structural information may include a set of nodes and a set of fixed edges in the graph structure.
[0049] In an optional manner, the graph data header may be composed of a number array and a connection information list, wherein the number array is used to sequentially store multiple reference node numbers, and the connection information list is used to store the first connection information of the fixed edge and the second connection information of the non-fixed edge. The first connection information is used to describe the reference node numbers of the source node and the destination node of the fixed edge connection, and the second connection information is used to describe the reference node numbers of the source node and the destination node of the non-fixed edge connection. The same reference node number is used in the graph data header to represent nodes at the same position in different subgraphs. For example, Figure 1 Node D0, node D1, node D2, node D3 and node D4 in can be represented by reference node number D, and node R0, node R1, node R2, node R3 and node R4 can be represented by reference node number R. Multiple reference node numbers can be used to correspond to nodes at the same position in multiple subgraphs to describe the node sets in multiple subgraphs. The number array is, for example, a one-dimensional array N[5]={D, R, E, P, C}, the first element in the number array stores the reference node number D of the first node in the subgraph, the second element stores the reference node number R of the second node in the subgraph, and so on. The reference node numbers corresponding to each node in the subgraph can be stored to describe the node sets of multiple subgraphs. Multiple reference node numbers are set sequentially in the number array, so the position of the node corresponding to the reference node number in the subgraph can be determined according to the position of the reference node number in the number array. For example, if the reference node number E is in the third position in the number array, then the reference node number E can be determined as the reference node number of the third node in the subgraph; if the reference node number P is in the fourth position in the number array, then the reference node number P can be determined as the reference node number of the fourth node in the subgraph.
[0050] At the same time, the connection relationship between multiple reference node numbers can be used to describe the set of fixed edges in multiple subgraphs in the graph data header. As shown in Table 1, Table 1 is an exemplary connection information list.
[0051] Index 123456
[0052] Connection informationD-RR-EE-PP-CD-DP-R
[0053] Table 1
[0054] In Table 1, the first connection information and the second connection information are connection information of the same format. Each connection information is used to describe the source node and the destination node of an edge. The first bit of the connection information is the reference node number of the source node connected to the edge, and the second bit is the reference node number of the destination node connected to the edge. For example, the connection information (DR) is the first connection information, the first bit D indicates that the reference node number of the source node connected to the edge is D, and the second bit R indicates that the reference node number of the destination node connected to the edge is R. The index of the connection information is used to obtain the connection information from the connection information list. For example, when the index of a fixed edge is 1, the connection information (DR) can be determined from Table 1 according to the index 1, so that the source node connected to the fixed edge can be determined to be the first node in the subgraph, and the destination node is the second node in the subgraph. Further, according to the subgraph number of the subgraph where the fixed edge is located, the source node and the destination node of the fixed edge can be determined. For example, if the subgraph number of the subgraph where the fixed edge is located is 1, it can be determined that the source node connected to the fixed edge is the node D1 in the subgraph 200, and the destination node is the node R1 in the subgraph 200. When the connection information is the second connection information, it is necessary to determine the subgraph number of the source subgraph where the source node of the non-fixed edge connection is located, and the subgraph number of the destination subgraph where the destination node is located. For example, when the index of a non-fixed edge is 5, the second connection information (DD) can be determined from Table 1. Further, if it is determined that the subgraph number of the source subgraph where the source node of the non-fixed edge connection is located is 1, and the subgraph number of the destination subgraph where the destination node is located is 2, then it can be determined that the source node of the non-fixed edge connection is D1, and the destination node is D2.
[0055] In another optional manner, the graph data header may be established in the form of a coding matrix. Figure 2 As shown, Figure 2A schematic diagram of a graph data header in an embodiment of the present invention is shown, where the coding matrix is a coding matrix of 5 rows and 5 columns, the row numbers from the 1st row to the 5th row are reference node numbers D, R, E, P and C, respectively, and the column numbers from the 1st column to the 5th column are reference node numbers D, R, E, P and C, respectively. The row numbers and column numbers with the same values are encoded by the same reference node number, for example, the row number of the 3rd row and the column number of the 3rd column are both reference node number E. The row numbers of the coding matrix correspond to the source nodes connected by fixed edges and non-fixed edges, and the column numbers correspond to the destination nodes connected by fixed edges and non-fixed edges. For example, the Pth row represents the reference node number P of the source node connected by the fixed edge or non-fixed edge, and the Rth column represents the reference node number R of the destination node connected by the fixed edge or non-fixed edge. The indexes of the fixed edges and non-fixed edges are set at the corresponding positions in the coding matrix, and the target matrix position in the coding matrix can be determined according to the index, and the connection information can be further determined according to the row number and column number of the target matrix position. For example, the source node connected by fixed edge 102 is R0, the destination node is E0, the reference node number of the source node is R, the reference node number of the destination node is E, the matrix position of fixed edge 102 is in the Rth row and the Eth column, and the index "3" is set in the Rth row and the Eth column. The index "3" corresponds to the fixed edge between node R0 and node E0, and also corresponds to the fixed edge between node R1 and node E1 at the same position, as well as the fixed edge between node R2 and node E2, the fixed edge between node R3 and node E3, and the fixed edge between node R4 and node E4. The format of the graph data header may include but is not limited to the above examples, and the graph data header may be set according to the specific graph structure of the subgraph, which is not limited in this embodiment.
[0056] like Figure 3 As shown, Figure 3 A schematic diagram of the storage of graph data in an embodiment of the present invention is shown, where subgraph number 401 is subgraph number 0 of subgraph 100, and subgraph number 402 is subgraph number 1 of subgraph 200. The subgraph numbers of the multiple subgraphs are encoded in sequence according to the encoding order. The information set includes a first information set of fixed edges and a second information set of non-fixed edges. Figure 1As shown, the subgraph 100 includes fixed edge 101, fixed edge 102, fixed edge 103 and fixed edge 104. In the first storage area 403 corresponding to the subgraph number 401, the first information set 4031 of the fixed edge 101, the first information set 4032 of the fixed edge 102, the first information set 4033 of the fixed edge 103, and the first information set 4034 of the fixed edge 104 are stored in sequence. The information "1" included in the first information set 4031 represents the weight 1 of the fixed edge 101, and the information "0" included in the first information set 4032 represents the weight 0 of the fixed edge 102. When reading the subgraph 100 from the graph data, the reference node number can be first obtained from the header of the graph data, and then each node in the subgraph 100 can be determined according to the reference node number and the subgraph number 0, and the four first information sets in the first storage area corresponding to the subgraph number 0 can be obtained in sequence according to the subgraph number 0, and the fixed edge corresponding to the first information set can be determined according to the position of each first information set. For example, the weight in the first information set 4032 stored in the second position in the first storage area 403 is the weight of the second fixed edge 102 in the subgraph 100, and the weight in the first information set 4033 stored in the third position in the first storage area 403 is the weight of the third fixed edge 103 in the subgraph 100. The first information set may also include other information of the fixed edge, which is not limited in this embodiment.
[0057] In one embodiment, the first information set may also include the index of the fixed edge in the graph data header. In combination with the above example, an information may be added to the first information set 4031, which is the index 2 of the fixed edge 101. After setting the index in the first information set, the first connection information of the fixed edge can be obtained from the graph data header according to the index in the first information set, and the reference node numbers of the source node and the destination node connected by the fixed edge can be determined. Further, the destination node and the source node connected by the fixed edge can be determined according to the subgraph number corresponding to the first information set. For example, if the first information set of a fixed edge includes index 2, the first connection information (DR) can be determined from the graph data header according to index 2, and further, according to the subgraph number 0 corresponding to the first information set, it can be determined that the source node of the fixed edge connection is the first node D0 in the subgraph 100, and the destination node is the second node R0 in the subgraph 100.
[0058] Similarly, in the first storage area corresponding to the subgraph number 402, the weight of each fixed edge in the subgraph 200 is stored in sequence. In the second storage area 404 corresponding to the subgraph number 402, the second information set 4041 of the non-fixed edge 1021, the second information set 4042 of the non-fixed edge 1022, and the second information set 4043 of the non-fixed edge 1023 in the subgraph 200 are stored in sequence. The first information in the second information set of each non-fixed edge is the subgraph number of the source subgraph connected to the non-fixed edge, the second information indicates the index of the non-fixed edge in the graph data header, and the third information is the weight of the non-fixed edge. For example, the first information 0 in the second information set 4041 of the non-fixed edge 1021 indicates that the source node connected to the non-fixed edge 1021 is in the subgraph 100 with the subgraph number 0, and the index 6 corresponds to Figure 2 In the Pth row and Rth column of the coding matrix shown in FIG. 40, in the process of reading the graph data, firstly, according to the second information (i.e., index 6) in the second information set 4041, Figure 2 The second connection information PR is determined in the encoding matrix shown in FIG. 1 or the connection information list shown in Table 1. Further, according to the first information (i.e., subgraph number 0), the source node of the non-fixed edge can be determined to be P0, and according to subgraph number 1, the destination node of the non-fixed edge can be determined to be P1, and the weight of the non-fixed edge 1021 can be determined to be 10. Other information of the non-fixed edge can also be stored in the second information set, and this embodiment does not limit this.
[0059] When storing equal-incremental graph data in the manner described above, the structural information of multiple subgraphs can be stored through the graph data header, and the same structural information can be stored for multiple subgraphs of the same structure. At the same time, an information set can be stored based on the subgraph number, and the information set includes the weight information of the fixed edges in each subgraph, as well as the weight information of the non-fixed edges and other difference information between the subgraphs. Storing a copy of the structural information for each subgraph can be avoided, and the amount of graph data can be reduced, thereby reducing storage space. It should be noted that other methods can also be used to store the equal-incremental graph data as described above, and this embodiment does not limit this.
[0060] When using graph data, it is often necessary to determine the shortest path and / or longest path between the start node and the end node based on the edge weights. The path starts from the start node in the graph data and gradually reaches the end node along the outgoing edges of each node. The shortest path is the path with the smallest sum of edge weights among all paths, and the longest path is the path with the largest sum of edge weights among all paths.
[0061] One of the core concepts of an embodiment of the present invention is that, for equal-increment graph data, one or more nodes in the subgraph are selected at one time in units of subgraphs, and the longest path distance and / or the shortest path distance between the node and the starting node is calculated by the weight of the incoming edge of the node, and the selection and calculation are repeated until the longest path distance and / or the shortest path distance between all nodes and the starting node are calculated to determine the shortest path and / or the longest path.
[0062] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0063] Reference Figure 4 , shows a flowchart of a method for processing graph data in an embodiment of the present invention, the method is used to process graph data, according to the coding order of multiple nodes in the graph data, the graph data is divided into multiple subgraphs and non-fixed edges connecting nodes in different subgraphs; each subgraph includes multiple nodes and fixed edges connecting nodes in the subgraph; the source node of the non-fixed edge is located before the destination node in the coding order. The method may include the following steps:
[0064] Step 401 : Select nodes in at least one subgraph from multiple subgraphs in sequence according to the coding order as nodes to be calculated.
[0065] In this embodiment, the graph data processing method can be implemented by electronic devices such as computers and servers. The graph data can be pre-stored in a storage location in the electronic device. During the graph data processing, the electronic device can obtain at least one node in the subgraph from the storage location as a node to be calculated. Alternatively, the electronic device can communicate with other electronic devices and obtain at least one node in the subgraph from the other electronic devices as a node to be calculated.
[0066] like Figure 1As shown, the source node of the non-fixed edge 1021 is node P0, and the destination node is node R1. In the coding order, node P0 is before node R1. Optionally, in each subgraph, there is a fixed edge between two adjacent nodes, and the source node of the fixed edge is located before the target node in the coding order. For example, in subgraph 100, there is a fixed edge between two adjacent nodes, and the source node of the fixed edge 102 is node R0, and the target node is E0. The electronic device can start from the starting node, and select one or more nodes in the subgraph from all subgraphs as nodes to be calculated each time according to the coding order of the nodes, and the number of subgraphs selected is a positive integer. When selecting according to the coding order of the nodes, the coding order of multiple subgraphs can be selected, that is, starting from the first subgraph, at least one node in the subgraph is selected as the node to be calculated each time. Alternatively, directly according to the coding order of all nodes, starting from the starting node, at least one node in the subgraph is selected as the node to be calculated each time.
[0067] Exemplarily, each time a node in a subgraph can be selected as a node to be calculated, the first time the node in the subgraph corresponding to instruction i0 is selected as the node to be calculated, the second time the node in the subgraph corresponding to instruction i1 is selected as the node to be calculated, and so on, the nodes in the subgraph corresponding to all instructions can be selected as nodes to be calculated. Alternatively, each time two nodes in subgraphs can be selected as nodes to be calculated, the first time the nodes in the two subgraphs corresponding to instruction i0 and instruction i1 are selected as nodes to be calculated, the second time the nodes in the two subgraphs corresponding to instruction i2 and instruction i3 are selected as nodes to be calculated, and so on, the nodes in the subgraphs corresponding to all instructions can be selected as nodes to be calculated. The number of subgraphs selected each time can be the same or different, and this embodiment does not limit this.
[0068] Step 402: When the node to be calculated has at least one incoming edge, determine the distance of the path to be selected according to the weight of the incoming edge and the target path distance of the source node connected to the incoming edge.
[0069] Step 403: determine the target path distance of the node to be calculated from all the path distances to be selected, and use the source node corresponding to the target path distance of the node to be calculated as the previous node of the node to be calculated.
[0070] The target path distance of the source node is the longest path distance and / or the shortest path distance among all path distances between the starting node and the source node among the multiple nodes. The target path distance of the node to be calculated is the maximum candidate path distance corresponding to the longest path distance and / or the minimum candidate path distance corresponding to the shortest path distance. When it is necessary to determine the shortest path between the end node and the start node, the target path distance is the minimum candidate path distance; when it is necessary to determine the longest path between the end node and the start node, the target path distance is the maximum candidate path distance.
[0071] In this embodiment, after selecting the node to be calculated, the incoming edge of the node to be calculated can be determined from the graph data, and the incoming edge is the edge connected when the node is used as the destination node. Figure 1 As shown, if the node to be calculated is node R1, the incoming edges of the node to be calculated R1 include fixed edges 201 and non-fixed edges 1021. If the node to be calculated is node E0, the incoming edges of the node to be calculated E0 only include fixed edges 102.
[0072] Among them, when the equal-increment graph data is stored in a unit compression structure format, the nodes to be calculated and the incoming edges of the nodes to be calculated can be determined from the graph data based on the subgraph number. For example, when selecting a node in subgraph 200 as a node to be calculated, first, multiple reference node numbers D, R, E, P and C can be obtained from the graph data header, and then combined with the subgraph number 1 of subgraph 200, a subscript is added to each reference node number to obtain each node number D1, R1, E1, P1 and C1 in subgraph 200, and the nodes to be calculated in subgraph 200 are determined. At the same time, since multiple nodes in subgraph 200 are connected sequentially, multiple fixed edges within subgraph 200 can be determined, that is, Figure 1 The first fixed edge D1-R1, the second fixed edge R1-E1, the third fixed edge E1-P1 and the fourth fixed edge P1-C1 are shown. In addition, the first information set 405, the first information set 406, the first information set 407 and the first information set 408 can be obtained from the first storage area corresponding to the subgraph number 1. The multiple first information sets are sequentially stored in the first storage area, and the weight of the first fixed edge D1-R1 can be determined to be the weight 1 in the first information set 405. Similarly, each fixed edge and weight in the subgraph 200 can be determined.
[0073] Furthermore, multiple second information sets can be obtained from the second storage area corresponding to the subgraph number 1. Taking the second information set 4041 as an example, the second information 6 (the information is an index) can be extracted from the second information set 4041, and the connection information (PR) can be obtained from the graph data header according to the index. Then, according to the first information 0 in the second information set 4041 (the information is the subgraph number of the source subgraph), the source node of the non-fixed edge can be determined to be node P0, and according to the subgraph number 1, the destination node of the non-fixed edge can be determined to be node R1. At this time, the non-fixed edge can be determined to be P0-R1, that is, Figure 1. In addition, the third information 10 can be obtained from the second information set 4041, and the third information 10 is the weight of the non-fixed edge 1021. Similarly, the weights of the non-fixed edge 1022 and the non-fixed edge 1023 corresponding to the subgraph 200 can be obtained. At this point, all nodes and fixed edges in the subgraph 200 have been determined, and all non-fixed edges corresponding to the subgraph 200 have been determined, and the incoming edges of each node in the subgraph 200 can be further determined. For example, the incoming edges of the node D1 include the non-fixed edge 1022, and the incoming edges of the node R1 include the fixed edge 201 and the non-fixed edge 1021, and the weight of each incoming edge can also be determined.
[0074] It should be noted that when equal-increment graph data is stored in other formats, one or more nodes in the subgraph can be selected from the graph data by a method that matches the storage format, and the incoming edges of the nodes and the weights of the incoming edges can be determined.
[0075] In this embodiment, after determining the node to be calculated, it can be determined whether the node to be calculated has an incoming edge, so as to determine the candidate path distance of the node to be calculated according to the weight of the incoming edge and the target path distance of the source node connected to the incoming edge, and then select and determine the target path distance from all the candidate path distances. After determining the target path distance of a certain node, the obtained target path distance can be stored in a preset position, so that when determining the candidate path distances of other nodes, if the node is determined to be the source node of the incoming edge, the target path distance of the node can be obtained from the preset position.
[0076] Optionally, step 402 may include:
[0077] If the source node connected to the incoming edge is the starting node, the weight of the incoming edge is used as the distance of the candidate path;
[0078] If the target path distance of the source node connected by the incoming edge is predetermined, the weight of the incoming edge and the target path distance of the connected source node are summed to obtain the distance of the selected path;
[0079] If the target path distance of the source node connected to the incoming edge is not determined in advance, after the target path distance of the source node connected to the incoming edge is determined, the summation step is performed to obtain the candidate path distance.
[0080] Exemplarily, according to the coding order of multiple nodes, the node in the first subgraph of the multiple subgraphs can be selected as the node to be calculated. Since the starting node of the multiple nodes has no incoming edge and no previous node, the target path distance of the starting node can be set to 0, and the previous node is empty. When the source node connected by the incoming edge is determined to be the starting node, the weight of the incoming edge can be used as the path distance to be selected. In combination with the above example, all nodes in the subgraph 100 can be determined as nodes to be calculated. At this time, the incoming edge of each node in the subgraph 100 and the weight of the incoming edge can be determined. When calculating the target path distance of node R0, since the incoming edge of node R0 has only fixed edge 101, the path distance to be selected of node R0 is the weight of fixed edge 101, and since node R0 has only one incoming edge, it has only one path distance to be selected. The target path distance of node R0 can be determined as the weight of fixed edge 101, and the target path distance of node R0 can be stored in a preset position.
[0081] Furthermore, when determining the candidate path distance of node E0, the incoming edge can be determined as fixed edge 102, and the source node of incoming edge 102 is node R0. At this time, the target path distance of node R0 can be read from the preset position, and the target path distance of node R0 and the weight of the incoming edge 102 are summed to obtain a candidate path distance of node E0. Similarly, since node E0 has only one incoming edge, the calculated candidate path distance can be directly used as the target path distance of node E0, and the target path distance of node E0 is stored in the preset position. By analogy, the target path distance of each node in subgraph 100 can be determined. Among them, the target path distance of each node can be stored in different positions to store the target path distances of all nodes that have been determined.
[0082] Among them, since nodes in multiple subgraphs can be selected as nodes to be calculated each time, when determining the path distance to be calculated of a certain node, there may be a situation where the target path distance of the source node connected by the incoming edge has not been determined. Combined with the above example, when the nodes in subgraph 100 and subgraph 200 are determined as nodes to be calculated at the same time, multiple nodes can be carried out in parallel, and the path distance to be calculated can be determined at the same time. When determining the path distance to be calculated of node R1, the incoming edge of node R1 includes a non-fixed edge 1021, and the source node of the non-fixed edge 1021 is node P0, and the target path distance of node P0 needs to be obtained. At this time, the target path distance of node P0 may not be determined. In this case, for node R1, after waiting for the target path distance of node P0 to be determined, the weight of the non-fixed edge 1021 and the target path distance of node P0 can be summed to obtain a path distance to be calculated for node R1. On the contrary, when the target path distance of node P0 has been determined, the target path distance of node P0 and the weight of the non-fixed edge 1021 can be directly summed to obtain a path distance to be calculated for node R1. When determining the candidate path distance of node R1, the target path distance of node P0 can be continuously read from the preset position. If the target path distance of node P0 is not read, wait for a preset time until the target path distance of node P0 is read, and then sum the weight of the incoming non-fixed edge 1021 and the target path distance of node P0 to obtain a candidate path distance of node R1. The specific value of the preset time can be set according to demand, and this embodiment does not limit this.
[0083] In this embodiment, for a node to be calculated having multiple incoming edges, each incoming edge of the node to be calculated can be determined, and the source node of each incoming edge and the target path distance of the source node can be determined. Taking node R1 as an example, when node R1 is used as a node to be calculated, it can be determined that node R1 has two incoming edges, namely, a fixed edge 201 and a non-fixed edge 1021. At this time, it can be determined that the source node of the fixed edge 201 is node D1, and the source node of the non-fixed edge 1021 is node P0. The predetermined target path distance of node D1 and the target path distance of node P0 can be read from a preset position, and the target path distance of node D1 and the weight of the fixed edge 201 can be summed to obtain a path distance to be selected for node R1, and the target path distance of node P0 and the weight of the non-fixed edge 1021 can be summed to obtain another path distance to be selected for node R1.
[0084] When it is determined that the node to be calculated has one path distance to be selected, the path distance to be selected can be directly used as the target path distance of the node to be calculated. When it is determined that the node to be calculated has multiple path distances to be selected, the maximum and / or minimum path distance to be selected can be selected as the target path distance. In combination with the above example, if it is necessary to determine the longest path between the end node and the start node, the maximum path distance to be selected can be selected from the two path distances to be selected of node R1 as the target path distance of node R1, and the source node corresponding to the maximum path distance to be selected can be used as the previous node of node R1. For example, if the path distance to be selected calculated based on the target path distance of node D1 and the weight of fixed edge 201 is the largest, node D1 can be used as the previous node of node R1. On the contrary, if it is necessary to determine the shortest path between the end node and the start node, the minimum path distance to be selected can be selected from the two path distances to be selected as the target path distance of node R1, and the source node corresponding to the minimum path distance to be selected can be used as the previous node of node R1.
[0085] In one embodiment, it may be necessary to simultaneously determine the longest path and the shortest path between the end node and the start node. In this case, the largest candidate path distance can be used as a target path distance of node R1, and the smallest candidate path distance can be used as another target path distance of node R1. In addition, the node corresponding to the largest candidate path distance can be used as the previous node corresponding to the longest path, and the node corresponding to the smallest candidate path distance can be used as the previous node corresponding to the shortest path. In this case, when determining the candidate path distance of node E1, the incoming edge of node E1 only has a fixed edge between node E1 and node R1, and the source node of the incoming edge is node R1. Two target path distances can be selected, and the two candidate path distances corresponding to node E1 can be calculated respectively, one of which is used as the target path distance corresponding to the longest path, and the other is used as the target path distance corresponding to the shortest path.
[0086] If a node has multiple candidate path distances, and the multiple candidate path distances are equal, the multiple candidate path distances can be used as the target path distances at the same time, and the source nodes corresponding to the multiple candidate path distances can be saved as the previous nodes at the same time. For example, if the two candidate path distances of node R1 are the same, node D1 and node P0 can be saved as the previous nodes of node R1 at the same time.
[0087] Optionally, the method may further include:
[0088] When the node to be calculated is a node other than the starting node and has no incoming edge, the target path distance between the node to be calculated and the starting node is set to a first preset value, and the previous node of the node to be calculated is set to a second preset value; the first preset value is an infinitesimal value corresponding to the longest path distance value and / or an infinite value corresponding to the shortest path distance value; the second preset value indicates that the previous node of the node to be calculated is empty.
[0089] In one embodiment, among all nodes except the starting node, there may be nodes without incoming edges, for example, there may be no non-fixed edge 1022 between node D0 and node D1. In this case, when node D1 is determined as the node to be calculated, since node D1 has no incoming edges, the target path distance between node D1 and the starting node D0 cannot be determined. At this time, the target path distance between node D1 and the starting node D0 can be set to a first preset value, and the previous node of node D1 can be set to a second preset value. When it is necessary to determine the longest path between the starting node and the ending node, the first preset value can be an infinitesimal value; when it is necessary to determine the shortest path between the starting node and the ending node, the first preset value can be an infinite value; when it is necessary to simultaneously determine the shortest path and the longest path between the starting node and the ending node, the first preset value can include both an infinite value and an infinitesimal value. The infinitesimal value and the infinite value are used to assist in determining the target path distance of other nodes. For example, when determining the distance of the candidate path of node R1, when it is necessary to determine the longest path between the starting node and the ending node, the infinitesimal value of node D1 and the weight of the fixed edge 201 can be summed to obtain the distance of the candidate path of node D1, which is also an infinitesimal value; when it is necessary to determine the shortest path between the starting node and the ending node, the infinite value of node D1 and the weight of the fixed edge 201 can be summed to obtain the distance of the candidate path of node D1, which is also an infinitesimal value. When the target path distance of a certain node is an infinite value and an infinitesimal value, it means that there is no path between the node and the starting node. When the target path distance of a certain node is an infinite value or an infinitesimal value, the previous node of the node can be set to a second preset value, indicating that the node has no previous node, that is, it means that there is no path between the node and the starting node.
[0090] Step 404: Repeat the steps of selecting a node to be calculated, determining the distance of a selected path, and determining the target path distance until the target path distances and previous nodes of all nodes are determined.
[0091] In this embodiment, step 401, step 402 and step 403 can be repeatedly performed until the target path distance and the previous node of all nodes are determined. At this time, the longest path and / or the shortest path between the starting node and the ending node can be determined based on all the previous nodes. In combination with the above example, if the longest path needs to be determined, the target path distance of each node is the maximum path distance to be selected, and the previous node of each node is the source node corresponding to the maximum path distance to be selected. At this time, the path composed of all the previous nodes is the longest path from the starting node to the ending node, and the target path distance of the ending node is the longest path distance between the starting node and the ending node. If the shortest path needs to be determined, the target path distance of each node is the minimum path distance to be selected, and the previous node of each node is the source node corresponding to the minimum path distance to be selected. At this time, the path composed of all the previous nodes is the shortest path from the starting node to the ending node, and the target path distance of the ending node is the shortest path distance between the starting node and the ending node. If it is necessary to determine the longest path and the shortest path at the same time, then for the longest path, the path composed of the previous nodes corresponding to the maximum candidate path distance of each node is the longest path, and the maximum target path distance of the end node is the longest path distance between the start node and the end node; for the shortest path, the path composed of the previous nodes corresponding to the minimum candidate path distance of each node is the shortest path, and the minimum target path distance of the end node is the shortest path distance between the start node and the end node.
[0092] In summary, in the embodiment of the present invention, according to the coding order of the nodes, at least one node in a subgraph is selected from multiple subgraphs in turn as a node to be calculated. When the node to be calculated has at least one incoming edge, the distance of the path to be calculated is determined according to the weight of the incoming edge and the target path distance of the connected source node, the target path distance of the node to be calculated is determined from all the distances of the path to be calculated, and the source node corresponding to the target path distance of the node to be calculated is used as the previous node of the node to be calculated, and the steps of selecting the node to be calculated, determining the distance of the path to be calculated, and determining the target path distance are repeated until the target path distance and the previous node of all nodes are determined. For equal increment graph data, the shortest or longest path distance between the node and the starting node is determined by the weight of the incoming edge, and the path distance of the node does not need to be updated multiple times, which is more efficient. In addition, since the path distance between the node and the starting node is calculated by the incoming edge of the node, the nodes in multiple subgraphs can be processed in parallel, which can further improve the processing efficiency.
[0093] Optionally, the step of determining the distance of the to-be-selected path according to the weight of the incoming edge and the target path distance of the source node connected to the incoming edge may include:
[0094] The step of determining the distance of the to-be-selected path is performed on the nodes to be calculated in the at least one selected subgraph in sequence according to the coding order.
[0095] In one embodiment, when selecting nodes in multiple subgraphs as nodes to be calculated, the distance of the path to be calculated of each subgraph can be determined in sequence according to the coding order. In combination with the above example, when determining the distance of the path to be calculated of a certain node, since the target path distance of the source node connected to the incoming edge of the node is not determined, it is necessary to wait for a certain time, and further when the target path distance of the node is needed to determine the distance of the path to be calculated of other nodes, further waiting is required. Therefore, the distance of the path to be calculated of each subgraph can be determined in sequence according to the coding order. For example, when simultaneously determining the nodes in subgraph 100 and subgraph 200 as nodes to be calculated, the distance of the path to be calculated of the node to be calculated in subgraph 100 can be determined in the coding order first, and then the distance of the path to be calculated of the node to be calculated in subgraph 200 can be determined. At this time, when determining the distance of the path to be calculated of node R1, it is not necessary to wait for the determination of the target path distance of node P0.
[0096] Optionally, the step of sequentially performing the step of determining the distance of the to-be-selected path on the to-be-calculated nodes in the selected at least one subgraph may include:
[0097] For each subgraph, the step of determining the distance of the to-be-selected path is performed on the nodes to be calculated in the subgraph in sequence according to the coding order of the nodes to be calculated in the subgraph.
[0098] In one embodiment, when determining the distance of the candidate path of the node to be calculated in each subgraph, the distance of the candidate path of each node in the subgraph can be determined in sequence according to the coding order. In combination with the above example, for the nodes to be calculated in subgraph 100, the distance of the candidate path of node D0 can be determined first, then the distance of the candidate path of node R0 can be determined, and then the distance of the candidate path of node E0 can be determined. By sequentially determining the distance of the candidate path of each node according to the coding order of multiple nodes to be calculated in subgraph 100, it is possible to avoid reducing waiting time and improve efficiency.
[0099] In the embodiment of the present invention, when nodes in multiple subgraphs are determined to be nodes to be calculated, the distance of the candidate path of the node to be calculated in each subgraph can be determined in sequence according to the coding order, which can reduce waiting time and improve efficiency.
[0100] Reference Figure 5 , showing a schematic structural diagram of a graph data processing device in an embodiment of the present invention, the graph data processing device includes a processing module having at least one processing unit (Process Unit, PU), and the processing unit includes multiple processing sub-units (Process Element, PE).
[0101] The graph data includes multiple nodes. According to the coding order of the multiple nodes in the graph data, the graph data is divided into multiple subgraphs and non-fixed edges connecting nodes in different subgraphs; each subgraph includes multiple nodes and fixed edges connecting nodes in the subgraph; the source node of the non-fixed edge is located before the destination node in the coding order. The understanding of the graph data can refer to the above example, and this embodiment will not be repeated.
[0102] The processing module can be a storage module in a graph data processing device, or a storage module set in other devices. The processing module is connected to the storage module, and the processing module can obtain graph data from the storage module. The storage module can use the storage format in the above example to store the graph data in the storage module, or use other formats to store the graph data in the storage module.
[0103] In this embodiment, the processing module is used to obtain nodes in a subgraph as nodes to be calculated for the idle processing unit in the encoding order of multiple nodes from the storage module in sequence, and obtain the incoming edge information of the nodes to be calculated for the idle processing unit when there is an idle processing unit in at least one processing unit. Further, the processing module is also used to assign the nodes to be calculated and the incoming edge information of the nodes to be calculated to a processing subunit in the idle processing unit, so that the processing subunit determines the path distance to be selected according to the weight of the incoming edge included in the incoming edge information and the target path distance of the target source node connected to the incoming edge when the node to be calculated has at least one incoming edge; the target path distance of the target source node is the longest path distance and / or the shortest path distance among all path distances between the starting node and the target source node among the multiple nodes.
[0104] Exemplarily, the processing module 500 may include: Figure 5 The processing unit 501, the processing unit 502 and the processing unit 503 shown, Figure 5 The symbol PU stands for a processing unit, and the symbol PE stands for a processing sub-unit. After the processing module starts processing the graph data, it can monitor the three processing units. When it is determined that a processing unit is idle, it can use the processing unit as an idle processing unit. At this time, the processing module can obtain a node in a subgraph in the graph data from the storage module according to the encoding order of multiple nodes, and obtain the input edge information of the node to be calculated, and assign the obtained node as the node to be calculated to the idle processing unit. Combined with Figure 1As shown, when the processing of graph data is started, the three processing units in the processing module are all in an idle state. The processing module can extract the nodes in the first three subgraphs corresponding to instruction i0, instruction i1 and instruction i2 in sequence as nodes to be calculated in the coding order, allocate the nodes to be calculated in the subgraph corresponding to instruction i0 to processing unit 501, allocate the nodes to be calculated in the subgraph corresponding to instruction i1 to processing unit 502, and allocate the nodes to be calculated in the subgraph corresponding to instruction i2 to processing unit 503. At the same time, the processing module can also obtain the incoming edge information of the node to be calculated from the storage module. The incoming edge information may include the source node connected to the incoming edge of the node to be calculated, and the weight of the incoming edge. The process of the processing module obtaining the node and the incoming edge information of the node can refer to the above example, and this embodiment will not be repeated here.
[0105] In this embodiment, after receiving the assigned node to be calculated and the incoming edge information, the processing subunit can first determine whether the node to be calculated has an incoming edge. If there is an incoming edge, determine the target path distance of the target source node connected by the incoming edge, and sum the target path distance and the weight of the incoming edge to obtain the selected path distance of the node to be calculated. The process of the processing subunit determining the target path distance of the node to be calculated and the previous node can refer to the above example, and this embodiment will not be repeated here.
[0106] In one embodiment, the storage module may be a memory module in a graph data processing device. After the processing subunit determines the target path distance and the previous node of a node to be calculated, the processing module may output the target path distance and the previous node of the node to be calculated to the memory module, so that the memory module stores the target path distance and the previous node of the node to be calculated to the target position in the memory module. When other processing subunits are determining the selected path distances of other nodes to be calculated, if the node to be calculated is determined to be a source node, the processing module may read the target path distance of the node to be calculated from the target position and provide the target path distance of the node to be calculated to other processing subunits.
[0107] Optionally, after the processing unit determines the target path distance and previous node of all nodes to be calculated in a subgraph, the processing module may send the target path distance and previous node of all nodes in the subgraph to the memory module. The memory module may sequentially store the target path distance and previous node of all nodes in a subgraph through a continuous storage area, taking the subgraph as a unit. Accordingly, when a certain processing sub-unit needs to obtain the target path distance of the source node, the processing module may send a data request to the memory module, and the memory module may send the target path distance of the source node to the processing module in response to the data request, and the processing module provides the target path distance of the source node to the processing sub-unit. The specific method of storing the target path distance and the previous node in the memory module, and the specific process of the processing module obtaining the target path distance of the source node from the memory module can be set according to demand, and this embodiment does not limit this.
[0108] In this embodiment, the processing module is further used to determine and output the target path distance of the node to be calculated from all the path distances to be selected, and to use the source node corresponding to the target path distance of the node to be calculated as the previous node of the node to be calculated and output it; the target path distance of the node to be calculated is the maximum path distance to be selected corresponding to the longest path distance and / or the minimum path distance to be selected corresponding to the shortest path distance. The processing module repeatedly executes the steps of obtaining the node to be calculated and the incoming edge information for the idle processing unit, the step of allocating the node to be calculated and the incoming edge information, and the step of determining and outputting the target path distance and the previous node until the target path distance and the previous node of all nodes are output.
[0109] In combination with the above example, after the processing module obtains the nodes in the first three subgraphs as nodes to be calculated, if multiple processing sub-units in the processing unit 501 determine the target path distance and the previous node of all nodes in the subgraph 100, the processing unit 501 enters an idle state. Correspondingly, after determining that the monitoring processing unit 501 is an idle processing unit, the processing module can continue to obtain the nodes in the subgraph corresponding to the instruction i3 as nodes to be calculated in the coding order, and obtain the incoming edge information of each node to be calculated, and assign each node to be calculated and the incoming edge information of the node to be calculated corresponding to the instruction i3 to a processing sub-unit in the processing unit 501. By analogy, the processing module repeatedly detects the idle processing unit until all nodes in the subgraph are assigned to the processing unit as nodes to be calculated, and the processing sub-unit determines the target path distance and the previous node of each node, and the processing module can output the target path distance and the previous node of each node to the memory module until the target path distance and the previous node of all nodes are output. Among them, the processing sub-unit can set the target path distance of the starting node to 0 and the previous node to be empty. It should be noted that the number of processing units can be set to one or more according to the needs, and a large number of processing sub-units can be set in each processing unit to adapt to subgraphs including different numbers of nodes. Among them, the process of determining the target path distance of the node to be calculated from all the path distances to be selected and outputting it, and the process of using the source node corresponding to the target path distance of the node to be calculated as the previous node of the node to be calculated and outputting it can also be implemented by the processing unit or processing sub-unit in the processing module, and this embodiment does not make specific restrictions.
[0110] Optionally, the processing subunit is also used to set the target path distance between the node to be calculated and the starting node to a first preset value and set the previous node of the node to be calculated to a second preset value when the node to be calculated is a node other than the starting node and has no incoming edge; the first preset value is an infinitesimal value corresponding to the longest path distance value and / or an infinite value corresponding to the shortest path distance value; the second preset value indicates that the previous node of the node to be calculated is empty.
[0111] like Figure 6 As shown, Figure 6 A structural schematic diagram of another graph data processing device in an embodiment of the present invention is shown. The graph data processing device includes a processing module 500, a cache module 600 and a memory module 700. The processing module 500 is connected to the cache module 600, and the cache module 600 is connected to the memory module 700.
[0112] Among them, the processing module is also used to apply for a storage area for each node to be calculated in the cache module, and output the target path distance and previous node of the node to be calculated to the cache module; the cache module is used to receive and store the target path distance and previous node of the node to be calculated in the storage area of the node to be calculated; the processing module is also used to obtain the target path distance of the target source node from the cache module.
[0113] The processing subunit is specifically used to, if the target source node is the starting node, use the weight of the incoming edge as the distance of the path to be selected; if the processing module obtains the target path distance of the target source node from the cache module, then sum the weight of the incoming edge and the target path distance of the target source node to obtain the distance of the path to be selected; if the processing module does not obtain the target path distance of the target source node from the cache module, then wait for the processing module to obtain the target path distance of the target source node from the cache module, and then execute the summation step to obtain the distance of the path to be selected.
[0114] In one embodiment, a cache module may be provided in a graph data processing device to cache the target path distance and the previous node of the determined node. After acquiring a node in a subgraph as a node to be calculated, the processing module may send an allocation request to the cache module to apply for a plurality of continuous storage areas from the cache module to store the target path distance and the previous node of each node to be calculated in the subgraph. After receiving the allocation request, the cache module may allocate a storage area in the cache module for each node to be calculated in the subgraph. The multiple storage areas of the multiple nodes to be calculated in the same subgraph are located in the same area of the cache module in sequence according to the coding order of the nodes. Each storage area stores the target path distance and the previous node of a node to be calculated.
[0115] like Figure 6As shown, the cache module 600 includes multiple cache lines, the history length is the number of cache lines, and the number of storage areas in each cache line corresponds to the number of all nodes to be calculated included in a subgraph. An exclusive bit can be set at the head of each cache line, and each storage area included in the cache line can store valid bits, distances, and previous node data in sequence. The exclusive bit is used to mark whether the cache line is free. For example, when the exclusive bit is 1, it means that the cache line has been assigned to one of the subgraphs, and when it is 0, it means that the cache line is free. The valid bit is used to mark whether the data in the storage area is valid. For example, when the valid bit is 1, it means that the data in the storage area is valid, and when it is 0, it means that the data in the storage area is invalid. The distance is the target path distance of the node to be calculated, and the previous node array is one or more previous nodes of the node to be calculated. The head pointer in the cache module points to the free cache line in the cache module, and the head pointer number of the head pointer is initialized to 0. After receiving the allocation request sent by the processing module, the cache module can set the exclusive bit in the free cache line pointed to by the head pointer to 1, allocate the cache line to the subgraph, and send the current head pointer number to the processing module, then the head pointer number is increased by 1, and the head pointer points to the next free cache line. Each cache line is used to store the target path distance and previous node of a node in a subgraph, so each head pointer number corresponds to the target path distance and previous node of a node in a subgraph.
[0116] In one embodiment, the spatial size of each storage area is consistent and arranged in sequence. The processing module can determine the storage address of the storage area of each node to be calculated in the cache line based on the head pointer number and the offset. The offset corresponds to the position of the node to be calculated in the subgraph. For example, if the node to be calculated is the first node in the subgraph, the offset corresponds to the first storage area in the cache line. If the node to be calculated is the third node in the subgraph, the offset corresponds to the third storage area in the cache line. The processing module assigns the node to be calculated in a subgraph to a processing unit, and after receiving the head pointer number sent by the cache module after assigning the cache line to the subgraph, the corresponding relationship between the processing unit and the head pointer number can be recorded. When a processing subunit in the processing unit determines the target path distance and the previous node of a node to be calculated, the processing module can first determine the position of the node to be calculated processed by the processing subunit in the subgraph, determine the offset according to the position, and then send a data packet including the corresponding head pointer number, offset, target path distance and previous node to the cache module. After receiving the data packet, the cache module first determines the corresponding cache line according to the head pointer number, and determines the target storage area in the cache line according to the offset, and stores the received target path distance and previous node in the target storage area. After storing the target path distance and previous node in a certain storage area, the cache module can set the valid position of the storage area to 1, indicating that the storage area has stored the target path distance and previous node of the node to be calculated, and the data in the storage area is valid data.
[0117] In this embodiment, when determining the selected path distance of a node to be calculated, the processing subunit needs to obtain the target path distance of the target source node connected by the incoming edge. At this time, the processing module can generate a first data request, which includes the head pointer number corresponding to the subgraph where the target source node is located, and the offset of the target source node. Correspondingly, after receiving the first data request, the cache module first determines the target cache line from all cache lines according to the head pointer number, and then determines the storage area of the target source node from the target cache line according to the offset. When the valid bit of the storage area is 1, the target path distance of the target source node is read from the storage area, and the target path distance of the target source node is sent to the processing module, and the processing module forwards the target path distance to the corresponding processing subunit. On the contrary, when the cache module determines that the valid bit of the storage area is 0, it determines that the target path distance of the target source node has not been stored, and can send a response message to the processing module, so that the processing module controls the processing subunit to wait, and resends the first data request to the cache module after a preset time length until the target path distance of the target source node is obtained, and the target path distance is provided to the processing subunit.
[0118] In an embodiment of the present invention, a cache module is provided in the graph data processing device. The cache module can cache the target path distances and previous nodes of the nodes that have been calculated during the graph data processing process, and when the target path distance of a certain node is needed to calculate the target path distances of other nodes, the target path distance of the node can be quickly provided to the processing module, thereby avoiding direct acquisition from the memory module, thereby improving efficiency. The data interaction process between the cache module and the processing module may include but is not limited to the above examples.
[0119] In this embodiment, the cache module is connected to the memory module. The cache module is also used to send the target path distances and previous nodes of all nodes to be calculated in the subgraph to the memory module when the target path distances and previous nodes of all nodes to be calculated in the subgraph are stored in the cache module, so that the memory module stores the target path distances and previous nodes of all nodes to be calculated in the subgraph; the cache module is also used to obtain the target path distance of the target source node from the memory module to provide the target path distance of the target source node to the processing module.
[0120] In this embodiment, the cache module is also used to determine that the target distance paths and previous nodes of all nodes in the corresponding subgraph have been determined when all valid bits in a cache line are 1, and the target path distances and previous nodes of all nodes in the cache line can be output to the memory module for storage. Figure 6 As shown, a memory module can be set in the graph data processing device, and the memory module is composed of a memory controller and a memory. The tail pointer in the cache module can point to a cache line in the cache line to be written into the memory. When all valid bits in the cache line are 1, it means that the target path distance and the previous node of all nodes in the subgraph corresponding to the cache line have been determined. The cache module can send the target path distance and the previous node of all nodes stored in the cache line to the memory module, and the memory controller stores the received data in the memory. After the data in the cache line is written into the memory, the exclusive bit of the cache line can be cleared to make the cache line idle, and each valid bit in the cache line can be cleared to allocate the cache line to other subgraphs.
[0121] Optionally, when the cache module sends the target path distance and previous node in a cache line to the memory module, it can also send the head pointer number of the cache line to the memory module, so that the memory module stores the target path distance and previous node of the node in each subgraph received in sequence according to the head pointer number.
[0122] Among them, after receiving the first data request, the cache module can send a second data request to the memory module, and the second data request can also include a head pointer number and an offset. The memory control can obtain the target path distance and the previous node of the target source node from the memory according to the head pointer number and the offset, and return the target path distance and the previous node of the target source node to the cache module, and the cache module sends the target path distance and the previous node of the target source node to the processing module. Alternatively, the memory module can store the target path distance and the previous node of all nodes in each subgraph in the form of an array or a matrix, and the cache module can determine the position of the target path distance of the target source node in the array or the matrix according to the encoding position of the target source node in the graph data, so as to obtain the target path distance of the target source node from the memory module according to the determined position. The specific way in which the memory module stores the target path distance, and the data interaction process between the memory module and the cache module can be set according to the needs, and this embodiment does not limit this.
[0123] In one embodiment, a graph data processing device is located in an electronic device, and the graph data processing device includes a processing module and a cache module, and the memory module is a memory module in the electronic device, and the processing module, the memory module and the cache module can be connected through a system bus. The graph data is stored in the memory module. During the graph data processing process, the processing module can send a DMA request to a direct memory access (DMA) controller in the electronic device, so that the DMA controller sends a bus request to the CPU in the electronic device to obtain control of the system bus. After obtaining the control, the processing module can send a DMA request to obtain a node from the memory module as a node to be calculated, and obtain the input edge information of the node to be calculated. After the processing module obtains the target path distance and the previous node of the node to be calculated, the cache module writes the target path distance and the previous node of the node into the memory module. Alternatively, the graph data processing device includes a processing module, a memory module and a cache module, and the memory module is connected to other electronic devices. After determining the target path distance and the previous node of the node and storing them in the memory module, the electronic device can read the target path distance and the previous node of the node from the memory module.
[0124] In summary, the graph data processing device in this embodiment includes a processing module, and the processing unit in the processing module includes multiple processing sub-units. For equal-increment graph data, combined with the specificity of equal-increment graph data, the path distance between the node and the starting node is determined by the node's incoming edge, so that the multiple processing sub-units in each processing unit can process all nodes in a sub-graph in parallel, thereby improving the processing efficiency of the graph data.
[0125] An embodiment of the present invention further provides an electronic device, comprising the graph data processing apparatus as described above.
[0126] Figure 7 The electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0127] Reference Figure 7 , the electronic device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .
[0128] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0129] The memory 704 is configured to store various types of data to support operations on the device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0130] The power supply component 706 provides power to the various components of the electronic device 700. The power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 700.
[0131] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0132] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.
[0133] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0134] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 can detect the open / closed state of the device 700, the relative positioning of components, such as the display and keypad of the electronic device 700, and the sensor assembly 714 can also detect the position change of the electronic device 700 or a component of the electronic device 700, the presence or absence of contact between the user and the electronic device 700, the orientation or acceleration / deceleration of the electronic device 700, and the temperature change of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0135] The communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices. The electronic device 700 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0136] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0137] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by a processor 720 of an electronic device 700 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0138] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform a graph data processing method.
[0139] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0140] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0141] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0142] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0143] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0144] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0145] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0146] The above is a detailed introduction to a graph data processing method and device, an electronic device and a storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A graph data processing method, characterized in that: The method is used to process graph data. According to the coding order of multiple nodes in the graph data, the graph data is divided into multiple subgraphs and non-fixed edges connecting nodes in different subgraphs; each of the subgraphs includes multiple nodes and fixed edges connecting nodes in the subgraphs; the source node of the non-fixed edge is located before the destination node in the coding order; the method includes: Selecting nodes in at least one subgraph from the plurality of subgraphs in sequence as nodes to be calculated according to the encoding order; In the case where the node to be calculated has at least one incoming edge, determining the path distance to be selected according to the weight of the incoming edge and the target path distance of the source node connected to the incoming edge; the target path distance of the source node is the longest path distance and / or the shortest path distance among all path distances between the starting node among the multiple nodes and the source node; Determine the target path distance of the node to be calculated from all the path distances to be selected, and use the source node corresponding to the target path distance of the node to be calculated as the previous node of the node to be calculated; the target path distance of the node to be calculated is the maximum path distance to be selected corresponding to the longest path distance and / or the minimum path distance to be selected corresponding to the shortest path distance; The steps of selecting the node to be calculated, determining the distance of the selected path, and determining the target path distance are repeatedly performed until the target path distances and previous nodes of all the nodes are determined.
2. The method according to claim 1, characterized in that: The determining the distance of the to-be-selected path according to the weight of the incoming edge and the target path distance of the source node connected to the incoming edge includes: If the source node connected to the incoming edge is the starting node, the weight of the incoming edge is used as the distance of the path to be selected; If the target path distance of the source node connected to the incoming edge is predetermined, the weight of the incoming edge and the target path distance of the connected source node are summed to obtain the path distance to be selected; If the target path distance of the source node connected to the incoming edge is not determined in advance, the summing step is performed after the target path distance of the source node connected to the incoming edge is determined to obtain the candidate path distance.
3. The method according to claim 1, characterized in that Also includes: When the node to be calculated is a node other than the starting node and has no incoming edge, the target path distance between the node to be calculated and the starting node is set to a first preset value, and the previous node of the node to be calculated is set to a second preset value; the first preset value is an infinitesimal value corresponding to the longest path distance value and / or an infinite value corresponding to the shortest path distance value; the second preset value indicates that the previous node of the node to be calculated is empty.
4. The method according to any one of claims 1 to 3, characterized in that: The determining the distance of the to-be-selected path according to the weight of the incoming edge and the target path distance of the source node connected to the incoming edge includes: The step of determining the distance of the path to be selected is performed on the nodes to be calculated in the at least one selected subgraph in sequence according to the coding order.
5. The method according to claim 4, characterized in that The step of sequentially performing the step of determining the distance of the to-be-selected path on the to-be-calculated nodes in the at least one selected subgraph comprises: For each of the subgraphs, the step of determining the distance of the to-be-selected path is performed on the nodes to be calculated in the subgraph in sequence according to the coding order of the nodes to be calculated in the subgraph.
6. A graph data processing device, characterized in that: A processing module including at least one processing unit, wherein the processing unit includes a plurality of processing sub-units; the processing module is connected to the storage module; The storage module is used to store graph data, wherein the graph data is divided into multiple subgraphs and non-fixed edges connecting nodes in different subgraphs according to the coding order of multiple nodes in the graph data; each of the subgraphs includes multiple nodes and fixed edges connecting nodes in the subgraphs; the source node of the non-fixed edge is located before the destination node in the coding order; The processing module is used for, when there is an idle processing unit in the at least one processing unit, sequentially obtaining a node in the subgraph as a node to be calculated for the idle processing unit from the storage module according to the coding order of the multiple nodes, and obtaining the incoming edge information of the node to be calculated for the idle processing unit; The processing module is further used to assign the node to be calculated and the incoming edge information of the node to be calculated to a processing sub-unit in the idle processing unit, so that the processing sub-unit determines the path distance to be selected according to the weight of the incoming edge included in the incoming edge information and the target path distance of the target source node connected to the incoming edge when the node to be calculated has at least one incoming edge; the target path distance of the target source node is the longest path distance and / or the shortest path distance among all path distances between the starting node and the target source node among the multiple nodes; The processing module is further used to determine the target path distance of the node to be calculated from all the path distances to be selected and output it, and to use the source node corresponding to the target path distance of the node to be calculated as the previous node of the node to be calculated and output it; The target path distance of the node to be calculated is the maximum candidate path distance corresponding to the longest path distance and / or the minimum candidate path distance corresponding to the shortest path distance; The processing module repeatedly executes the steps of obtaining the nodes to be calculated and the incoming edge information for the idle processing unit, allocating the nodes to be calculated and the incoming edge information, and determining and outputting the target path distance and the previous node until the target path distance and the previous node of all the nodes are output.
7. The graph data processing device according to claim 6, characterized in that: Also includes a cache module; The processing module is connected to the cache module, and the processing module is further used to apply for a storage area in the cache module for each node to be calculated, and output the target path distance and the previous node of the node to be calculated to the cache module; The cache module is used to receive and store the target path distance and the previous node of the node to be calculated in the storage area of the node to be calculated; The processing module is further configured to obtain the target path distance of the target source node from the cache module.
8. The graph data processing device according to claim 7, characterized in that: Also included are memory modules; The cache module is connected to the memory module, and the cache module is further used for sending the target path distances and the previous nodes of all the nodes to be calculated in the subgraph to the memory module when the target path distances and the previous nodes of all the nodes to be calculated in the subgraph are stored in the cache module, so that the memory module stores the target path distances and the previous nodes of all the nodes to be calculated in the subgraph; The cache module is further configured to obtain the target path distance of the target source node from the memory module to provide the target path distance of the target source node to the processing module.
9. The graph data processing device according to claim 7, characterized in that: The processing subunit is used for, if the target source node is the starting node, using the weight of the incoming edge as the path distance to be selected; if the processing module obtains the target path distance of the target source node from the cache module, summing the weight of the incoming edge and the target path distance of the target source node to obtain the path distance to be selected; if the processing module does not obtain the target path distance of the target source node from the cache module, waiting for the processing module to obtain the target path distance of the target source node from the cache module, executing the summing step to obtain the path distance to be selected.
10. The graph data processing device according to any one of claims 6 to 9, characterized in that: The processing sub-unit is also used to set the target path distance between the node to be calculated and the starting node to a first preset value, and set the previous node of the node to be calculated to a second preset value when the node to be calculated is a node other than the starting node and has no incoming edge; the first preset value is an infinitesimal value corresponding to the longest path distance value and / or an infinite value corresponding to the shortest path distance value; the second preset value indicates that the previous node of the node to be calculated is empty.
11. An electronic device, characterized in that: It comprises a graph data processing device as described in any one of claims 6-10.
Citation Information
Patent Citations
Processor performance analysis method and device and electronic equipment
CN114840371A
