Calculation device, calculation method, and calculation program
By calculating an approximate value of m f based on vertex degree order, the method addresses the time-consuming calculation of m f in Hybrid BFS for large-scale graphs, enhancing efficiency through reduced memory access.
Patent Information
- Application Number
- PCT/JP2024/001093
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-01-17
- Publication Date
- 2025-07-24
AI Technical Summary
The calculation of the parameter m f in Hybrid BFS for large-scale graphs is time-consuming due to irregular memory access in existing methods.
An approximate value of m f (m * f ) is calculated using the degree order of vertices in a scale-free graph, reducing irregular memory access by ordering vertex visits based on vertex degree and using an indptr array in Compressed Sparse Row format.
This approach significantly reduces the calculation time of m f in Hybrid BFS for large-scale graphs by minimizing memory accesses.
Smart Images

Figure JP2024001093_24072025_PF_FP_ABST
Abstract
Description
Calculation device, calculation method, and calculation program
[0001] The present invention uses a parameter m used to switch between Topdown BFS and Bottomup BFS in Hybrid BFS (Breadth-First Search). f The present invention relates to a calculation device, a calculation method, and a calculation program for calculating
[0002] Given a vertex S in a graph (see Figure 1), the problem of finding a BFS tree (see Figure 2) starting from vertex S is called a BFS query problem. Hybrid BFS is an efficient way to solve this BFS query problem. Hybrid BFS is a technique that switches between Topdown BFS and Bottomup BFS depending on the progress of the vertex search.
[0003] Topdown BFS searches all vertices by examining adjacent vertices in order from a starting point S. For example, the set of vertices whose distance from vertex S is i+1 is called the frontier set of level_i.
[0004] For example, in the graph shown in Figure 1, the frontier set of level_0 is {1,7,9}. The frontier set of level_1 is {2,8,10}. The frontier set of level_2 is {3,4,11}. Note that vertices that belong to a frontier set are called frontier vertices.
[0005] In Topdown BFS, all vertices adjacent to the frontier vertex are checked to see if there are any unvisited vertices. Therefore, Topdown BFS search is inefficient when the number of edges connected to the frontier vertex is large.
[0006] In addition, Bottomup BFS examines all edges connected to unvisited vertices. Unvisited vertices include vertices that are not adjacent to the frontier vertex, and examining the edges connected to those vertices is wasteful. Therefore, Bottomup BFS search is inefficient when there are few frontier vertices.
[0007] Therefore, Hybrid BFS efficiently searches the BFT tree (see Figure 2) by appropriately switching between Topdown BFS and Bottomup BFS depending on the progress of the search. In Hybrid BFS, the timing to switch between Topdown BFS and Bottomup BFS is determined by the total number of edges connected to the frontier vertices, m f , the number of frontier vertices n f , the number of edges connected to the unvisited vertices m u is used.
[0008] m f is calculated by counting the degree (number of edges) of each frontier vertex at each level during the search. u Since it is difficult to count directly, m is calculated by the following formula (1) using the average number of edges connected to the vertices of the graph and the number of unexplored vertices. u Find the approximate value of .
[0009]
[0010] In Topdown BFS, m f In Bottomup BFS, at most m edges are checked. u Check the edges. Therefore, m f >m u If so, switching from Topdown BFS to Bottomup BFS at that point is guaranteed to explore fewer edges. In fact, the number of edges checked in Bottomup BFS is m u Since it is smaller than α・m f >m u In this case, the BFS switches from Top-down to Bottom-up. Note that α is a tuning parameter.
[0011] On the other hand, the overhead of Bottomup BFS is scanning all vertices and visiting vertices that are not directly connected to the frontier vertex. Therefore, when the graph exploration is sufficiently advanced and m u >m fIn this case, the advantage of Bottomup BFS disappears, so we need to switch to Topdown BFS. In reality, the number of edges that can be used by Bottomup BFS is m u Since there are fewer than β・m u >m f In this case, we switch from Bottom-Up BFS to Top-Down BFS. Note that β is a tuning parameter.
[0012] Here, the above m f can be calculated as follows. The graph is represented using arrays (indptr array and indices array, see Figure 4) in which the adjacency matrix representing the graph (see Figure 3) is compressed in Compressed Sparse Row (CSR) format. The indices array is an array that stores the output vertex numbers. The indptr array is an offset array of the vertex numbers of the edges. In other words, the indptr array stores the cumulative sum of the number of edges each vertex has when the vertices of the graph are arranged in order of vertex number.
[0013] m f The calculation of is naively done by computing d(v)(=indptr[v+1]-indptr[v]) by m f This is done by adding to m f The calculation is done by reading indptr[v+1] and indptr[v] from the indptr array (see Figure 4) and calculating the difference between them as m f This is done by adding to
[0014] Therefore, in the whole BFS, m f To calculate this, memory access to the indptr array occurs 2|V(G)| times, where V(G) is the number of vertices in graph G.
[0015] Beamer, Scott, Krste Asanovic, and David Patterson. "Direction-Optimizing Breadth-First Search" SC'12: Proceedings of the International Conference on High Performance Computing, Networking, Storage and Analysis. IEEE, 2012
[0016] However, when applying Hybrid BFS to large-scale graphs, the above m f Therefore, when applying Hybrid BFS to a large-scale graph, the present invention aims to f The object of the present invention is to reduce the calculation time.
[0017] In order to solve the above-mentioned problems, the present invention is characterized by comprising an input accepting unit that accepts input of a scale-free graph in which the order of visiting each vertex is determined by the magnitude of the degree of each vertex; a search unit that visits each vertex of the graph in the order of visiting and searches for vertices adjacent to each vertex; a determination unit that determines up to which frontier vertex of the graph a search has been completed; and a calculation unit that reads, from an indptr array in which an adjacency matrix of the graph is compressed in a Compressed Sparse Row format, a first value indicating the sum of the degrees of each vertex that has been visited at the start of the search at the level where the search has ended and a second value indicating the sum of the degrees of each vertex that has been visited at the end of the search, and outputs the difference between the second value and the first value as an approximation of the sum of the degrees of each frontier vertex of the level.
[0018] According to the present invention, when applying Hybrid BFS to a large-scale graph, f The calculation time can be reduced.
[0019] FIG. 1 is a diagram showing an example of a graph. FIG. 2 is a diagram showing an example of a BFS tree searched from the graph shown in FIG. 1. FIG. 3 is a diagram showing an example of an adjacency matrix representing a graph. FIG. 4 is a diagram showing examples of arrays (indptr array and indices array) obtained by compressing the adjacency matrix shown in FIG. 3 in CSR format. FIG. 5 is a graph showing the relationship between a vertex v of a graph and a degree d(v). FIG. 6 is a graph showing the relationship between a vertex v of a graph and a degree d(v). FIG. 7 is a diagram showing an example of the configuration of a computing device. FIG. 8 is a diagram showing an example of a graph and an indptr array of the graph. FIG. 9 is a flowchart showing an example of a processing procedure executed by a computing device. FIG. 10 is a diagram showing a computer that executes a computing program.
[0020] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, a description will be given of an embodiment of the present invention with reference to the drawings, but the present invention is not limited to the embodiment.
[0021] [Overview] First, an overview of the computing device of this embodiment will be described. f When calculating m, irregular access occurs to the indptr array in memory, which is thought to take time. On the other hand, the calculation device of this embodiment calculates m based on the assumption that the graph to be processed is scale-free. f Approximate value of (m * f ) to reduce irregular memory accesses. For example, to reduce irregular memory accesses, the computing device may f Instead of the approximate value (m * f ) will be introduced.
[0022] In a scale-free graph, it is thought that in the early stages of a BFS tree search, vertices with a high degree (number of edges) are searched, and as the search nears its end, vertices with a low degree are more likely to be searched (see Figure 5).
[0023] The computing device of this embodiment utilizes the above property and assumes that the order in which each vertex of a graph is visited is determined by the magnitude of the degree of each vertex. For example, if the vertex numbers of each vertex of a graph are ordered in descending order of the degree of each vertex, the above assumption is equivalent to searching vertices in ascending order of vertex numbers. Also, as described above, the degree d(v) of a vertex v of a graph is indptr[v+1]-indptr[v] (see equation (2) below).
[0024]
[0025] Therefore, m at level_i of the graph f Approximate value of (m * f (i)) can be expressed by the following formula (3). Note that n in formula (3) start (i) is the number of vertices already visited at the start of the search at level_i. end (i) is the number of vertices visited at the end of the search at level_i.
[0026]
[0027] For example, consider the case where the numbers of each vertex constituting a graph are ordered by degree, and the number of vertices visited at the start of a search at level_1 in the graph is 1, and the number of vertices visited at the end of the search is 4.
[0028] In this case, m f = (indptr[2]-indptr[1]) + (indptr[3]-indptr[2]) + (indptr[4]-indptr[3]) = indptr[4]-indptr[1].
[0029] That is, the computing device can calculate m f When calculating m, it is not necessary to read all of indptr[1], indptr[2], indptr[3], and indptr[4] from the indptr array, but it is sufficient to read indptr[1] and indptr[4]. fThe number of accesses to the indptr array when calculating can be reduced.
[0030] Assume that the computing device visits vertices in the order of the degrees of the vertices of the graph, and calculates an approximation of m f (m * f ) (see Fig. 6).
[0031] Here, if the maximum value of level_ of BFS in the given graph is k, the accesses to the indptr array generated in the calculation of m * f are 2k times in the whole BFS. Also, since the diameter of the scale-free graph is generally much smaller than the number of vertices, k << V(G) holds. On the other hand, 2|V(G)| memory accesses occur in the naive calculation of m f .
[0032] Therefore, by calculating an approximation of m f (m * f ) as in the computing device of this embodiment, the number of memory accesses can be significantly reduced compared to calculating naive m f .
[0033] [Configuration Example] Next, a configuration example of the computing device 10 will be described using FIG. 7. The computing device 10 includes, for example, an input / output unit 11, a storage unit 12, and a control unit 13. Note that the graph to be searched for the BFS tree by the computing device 10 is a scale-free graph, and it is assumed that the access order of each vertex of the graph is determined by the magnitude of the degree of each vertex.
[0034] The input / output unit 11 is an interface that controls the input / output of various data. The input / output unit 11 receives, for example, the input of the graph to be searched for the BFS tree. For example, the input / output unit 11 receives the input of a graph (indptr array and indices array) compressed in the CSR format. Note that the process of compressing the graph in the CSR format may be performed by an external device or by the computing device 10.
[0035] The storage unit 12 stores data, programs, etc. that are referenced when the control unit 13 executes various processes. The storage unit 12 is realized by a semiconductor memory element such as a random access memory (RAM) or a flash memory, or a storage device such as a hard disk or an optical disk. For example, the storage unit 12 stores the indptr array and the indices array of the graph received by the input / output unit 11.
[0036] The control unit 13 controls the entire computing device 10. The functions of the control unit 13 are realized, for example, by a CPU (Central Processing Unit) executing a program stored in the storage unit 12.
[0037] The control unit 13 includes, for example, an input receiving unit 131, a searching unit 132, a determining unit 133, and a calculating unit 134.
[0038] The input receiving unit 131 receives input of the indptr array and the indices array of the graph. Note that this graph is a scale-free graph, in which the order in which each vertex of the graph is visited is determined by the magnitude of the degree of each vertex. For example, the vertex numbers assigned to each vertex of the graph are assumed to be the same as the order in which each vertex is visited.
[0039] The search unit 132 visits each vertex in the graph in the order of the vertex number and searches for vertices adjacent to each vertex. For the search, a Hybrid BFS is used. For example, the search unit 132 uses a Topdown BFS or a Bottomup BFS to visit each vertex in the graph and search for vertices adjacent to each vertex. At this time, the search unit 132 uses the m output by the calculation unit 134 f Approximate value of (m * f ) to switch between Topdown BFS and Bottomup BFS.
[0040] For example, when the search unit 132 completes the search up to a certain level, the calculation unit 134 outputs m * f Then, the search unit 132 obtains m * fThen, the search unit 132 searches the next level using the determined BFS (Topdown BFS or Bottomup BFS). After that, when the search unit 132 has finished searching the vertices of all levels of the input graph, it outputs the BFS tree obtained by the search.
[0041] The determination unit 133 determines the search status of the graph. For example, the determination unit 133 determines up to which level of the frontier vertex in the graph the search unit 132 has finished searching.
[0042] The calculation unit 134 calculates m based on the search status of the graph determined by the determination unit 133. f Approximate value of (m * f For example, the calculation unit 134 calculates m * f Calculate.
[0043] For example, the calculation unit 134 reads from the indptr array a value (first value) indicating the sum of the degrees of each vertex that has been visited at the start of the search at level_i where the determination unit 133 has determined that the search has ended, and a value (second value) indicating the sum of the degrees of each vertex that has been visited at level_i at the end of the search. Then, the calculation unit 134 outputs the difference between the second value and the first value as an approximation of the sum of the degrees of each frontier vertex at level_i used in Hybrid BFS.
[0044] For example, the number of vertices already visited at the start of the search at level_1 in the graph (n start (1)) is 1, and the number of vertices that have been visited at the end of the search (n end (1)) is 4. In this case, indptr[n start (1)]=indptr[4] and indptr[n end(1)]=indptr[1], the calculation unit 134 reads out indptr[4] and indptr[1] from the indptr array. Then, the calculation unit 134 substitutes the read-out values into the above formula (3) to obtain m * f Calculate (1)=indptr[4]-indptr[1].
[0045] Thereafter, the search unit 132 searches for the m calculated by the calculation unit 134. * f Using (1), it is determined whether Topdown BFS or Bottomup BFS should be applied at the next level (e.g., level_2), and switching between Topdown BFS and Bottomup BFS is performed depending on the result of the determination.
[0046] According to the computing device 10, when Hybrid BFS is applied to a large-scale graph, f The calculation time can be reduced.
[0047] [Calculation Example] Here, the graph shown in FIG. 1 is given as input to the calculation device 10, and m f Let us explain the approximation.
[0048] In the case of normal BFS, at level_0, the degree of vertex 0 is calculated with two memory accesses, and m f = 3. At level_1, the sum of the degrees of vertices 1, 7, and 9 is calculated in 6 memory accesses, and m f = 10. At level_2, the sum of the degrees of vertices 2, 8, and 10 is calculated with 6 memory accesses, and m f =6.
[0049] On the other hand, the calculation device 10 assumes that the vertices of the graph are searched in descending order of degree, and calculates m * f An example in which vertex numbers are assigned to the vertices of the graph in FIG. 1 in descending order of degree is shown as 801 in FIG. 8. Reference numeral 802 denotes the indptr array of the graph shown as 801.
[0050] First, since the number of visited vertices before searching level_0 is 0 and the number of visited vertices after searching is 1, the calculation device 10 calculates m * f This can be calculated by accessing the indptr array twice, as in (0) = indptr[1] - indptr[0] = 4.
[0051] Also, the number of visited vertices before searching level_1 is 1, and the number of visited vertices after searching is 4, so m * f This can be calculated by accessing the indptr array twice, as in (1) = indptr[4] - indptr[1] = 9.
[0052] Furthermore, the number of visited vertices before searching level_2 is 4, and the number of visited vertices after searching is 7, so m * f This can be calculated by accessing the indptr array twice, as in (2) = indptr[7] - indptr[4] = 8.
[0053] [Example of Processing Procedure] Next, an example of processing procedure executed by the computing device 10 will be described with reference to FIG. 9 . First, the input receiving unit 131 of the computing device 10 receives input of a graph (an indptr array and an indices array representing the graph) (S1). Thereafter, the search unit 132 searches for vertices of the graph for each level (S2). For example, the search unit 132 searches for vertices of the graph for each level using Top-down BFS. Then, if the search unit 132 has searched all vertices of the graph (Yes in S3), it outputs the BFS tree obtained by the search (S7).
[0054] On the other hand, if there is a vertex in the graph that has not yet been searched by the search unit 132 (No in S3), the search proceeds to the next level. At this time, the calculation unit 134 calculates m * f Then, the search unit 132 calculates m * fIt is determined whether to switch the BFS (Topdown BFS, Bottomup BFS) to be applied at the next level using the above (S5).
[0055] For example, when the BFS currently applied by the search unit 132 is a Topdown BFS, α·m * f >m u When β·m u >m * f When this happens, it is determined that the BFS should be switched from Bottom-up BFS to Top-down BFS.
[0056] In S5, if the search unit 132 switches the BFS to be applied at the next level (Yes in S5), the BFS is switched (S6) and the process returns to S2. On the other hand, if the search unit 132 does not switch the BFS to be applied at the next level (No in S5), the process returns to S2.
[0057] By performing the above process, the calculation device 10 calculates m * f Based on this, we can switch between Topdown BFS and Bottomup BFS to search the BFS tree.
[0058] [System Configuration, etc.] The components of each unit shown in the figure are conceptual functional units and do not necessarily have to be physically configured as shown. In other words, the specific form of distribution and integration of each device is not limited to that shown, and all or part of them can be functionally or physically distributed and integrated in any unit depending on various loads, usage conditions, etc. Furthermore, all or any part of the processing functions performed by each device can be realized by a CPU and a program executed by the CPU, or can be realized as hardware using wired logic.
[0059] Furthermore, among the processes described in the above embodiments, all or part of the processes described as being performed automatically can be performed manually, or all or part of the processes described as being performed manually can be performed automatically using a known method.In addition, the information including the processing procedures, control procedures, specific names, various data and parameters shown in the above documents and drawings can be changed as desired unless otherwise specified.
[0060] [Program] The above-described computing device 10 can be implemented by installing a program (computing program) as package software or online software on a desired computer. For example, by executing the above-described program on an information processing device, the information processing device can function as the computing device 10. The information processing device referred to here includes mobile communication terminals such as smartphones, mobile phones, and PHS (Personal Handyphone Systems), as well as terminals such as PDAs (Personal Digital Assistants).
[0061] 10 is a diagram showing an example of a computer that executes a calculation program. The computer 1000 includes, for example, a memory 1010 and a CPU 1020. The computer 1000 also includes a hard disk drive interface 1030, a disk drive interface 1040, a serial port interface 1050, a video adapter 1060, and a network interface 1070. These components are connected by a bus 1080.
[0062] The memory 1010 includes a read-only memory (ROM) 1011 and a random access memory (RAM) 1012. The ROM 1011 stores a boot program such as a basic input / output system (BIOS). The hard disk drive interface 1030 is connected to a hard disk drive 1090. The disk drive interface 1040 is connected to a disk drive 1100. A removable storage medium such as a magnetic disk or optical disk is inserted into the disk drive 1100. The serial port interface 1050 is connected to a mouse 1110 and a keyboard 1120, for example. The video adapter 1060 is connected to a display 1130, for example.
[0063] The hard disk drive 1090 stores, for example, an OS 1091, an application program 1092, a program module 1093, and program data 1094. That is, the programs that define the processes executed by the computing device 10 are implemented as program modules 1093 in which computer-executable code is written. The program modules 1093 are stored, for example, in the hard disk drive 1090. For example, the program modules 1093 for executing processes similar to those of the functional configuration of the computing device 10 are stored in the hard disk drive 1090. The hard disk drive 1090 may be replaced with an SSD (Solid State Drive).
[0064] Data used in the processing of the above-described embodiment is stored as program data 1094, for example, in the memory 1010 or the hard disk drive 1090. The CPU 1020 then reads the program module 1093 or the program data 1094 stored in the memory 1010 or the hard disk drive 1090 into the RAM 1012 as necessary and executes them.
[0065] The program module 1093 and program data 1094 may not necessarily be stored in the hard disk drive 1090, but may also be stored in a removable storage medium and read by the CPU 1020 via the disk drive 1100 or the like. Alternatively, the program module 1093 and program data 1094 may be stored in another computer connected via a network (such as a local area network (LAN) or a wide area network (WAN)). The program module 1093 and program data 1094 may then be read by the CPU 1020 from the other computer via the network interface 1070.
[0066] REFERENCE SIGNS LIST 10 Calculation device 11 Input / output unit 12 Storage unit 13 Control unit 131 Input reception unit 132 Search unit 133 Determination unit 134 Calculation unit
Claims
1. A computing device comprising: - an input receiving unit that receives an input of a scale-free graph in which the visit order of each vertex is determined by the degree of each vertex; - a search unit that visits each vertex of the graph according to the visit order and searches for vertices adjacent to the vertex; - a determination unit that determines up to which level of frontier vertices of the graph the search has ended; - a calculation unit that reads from an indptr array obtained by compressing the adjacency matrix of the graph in Compressed Sparse Row format a first value indicating the sum of the degrees of each vertex visited at the start of the search at the level where the search has ended, and a second value indicating the sum of the degrees of each vertex visited at the end of the search at the level, and outputs the difference between the second value and the first value as an approximation of the sum of the degrees of each frontier vertex at the level.
2. The computing device according to claim 1, wherein the search unit further switches the search method of the graph in Hybrid BFS using the approximation of the sum of the degrees of each frontier vertex at the output level.
3. A calculation method executed by a computing device, the method comprising: - a step of receiving an input of a scale-free graph in which the visit order of each vertex is determined by the degree of each vertex; - a step of visiting each vertex of the graph according to the visit order and searching for vertices adjacent to the vertex; - a step of determining up to which level of frontier vertices of the graph the search has ended; - a step of reading from an indptr array obtained by compressing the adjacency matrix of the graph in Compressed Sparse Row format a first value indicating the sum of the degrees of each vertex visited at the start of the search at the level where the search has ended, and a second value indicating the sum of the degrees of each vertex visited at the end of the search at the level, and outputting the difference between the second value and the first value as an approximation of the sum of the degrees of each frontier vertex at the level.
4. A step of receiving an input of a scale-free graph in which the visit order of each vertex is determined by the degree of each vertex; a step of visiting each vertex of the graph according to the visit order and searching for vertices adjacent to the vertex; a step of determining up to which level of frontier vertices of the graph the search has ended; from an indptr array obtained by compressing the adjacency matrix of the graph in Compressed Sparse Row format, a first value indicating the sum of the degrees of each vertex visited at the start of the search at the level where the search has ended, and a second value indicating the sum of the degrees of each vertex visited at the end of the search at the level, and outputting the difference between the second value and the first value as an approximation of the sum of the degrees of each frontier vertex at the level; and a calculation program for causing a computer to execute the steps.
Citation Information
Patent Citations
Method and apparatus for performing a search operation on heterogeneous computing systems
US20160378791A1
Computer Architecture for High-Speed, Graph-Traversal
US20190258401A1