Search device and search method
Patent Information
- Application Number
- PCT/JP2025/005474
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2026-08-27
Smart Images

Figure JP2025005474_27082026_PF_FP_ABST
Abstract
Description
Search Device and Search Method
[0001] The present invention relates to a search device and a search method.
[0002] As a data operation of a graph structure, breadth-first search (BFS: breadth-first search) is known. BFS is used in fields such as data mining, route search (car navigation, transfer guidance), network design, and circuit design.
[0003] There is a method of constructing a BFS tree by performing BFS on the entire graph from the given starting point each time. Also, as an efficient BFS method, hybrid BFS is known (for example, see Non-Patent Document 1). Hybrid BFS is an efficient BFS approach that combines two search directions: top-down search and bottom-up search.
[0004] Scott Beamer, Krste Asanovic, and David Patterson, "Direction-optimizing breadth-first search," In Proceedings of the International Conference on High Performance Computing, Networking, Storage and Analysis, pp. 12:1-12:10. IEEE Computer Society Press, 2012.
[0005] However, the conventional technology has a problem of long processing time. For example, in hybrid BFS, reading and updating of the access vector are performed in both top-down search and bottom-up search. At that time, in a graph representing a complex connection, it is necessary to access the data of adjacent vertices irregularly scattered throughout the access vector. Similarly, irregular memory access occurs when storing the source vertex in the parent array. Such low-locality access is unlikely to hit the cache of the CPU (Central Processing Unit). As a result, the time required for BFS processing increases due to the latency of memory access.
[0006] To solve the above-mentioned problems and achieve the objective, the search device is characterized by comprising: a default tree construction unit that constructs a BFS tree starting from the vertex with the highest degree in the graph; an ordering unit that assigns numbers to the vertices of the BFS tree according to their proximity to the starting point and the magnitude of their degree; and a search unit that performs a BFS starting from a specified vertex in the graph using bitwise operations on the bit values corresponding to each of the numbers.
[0007] According to the present invention, the processing time of BFS can be shortened.
[0008] Figure 1 is a diagram illustrating an example graph. Figure 2 is a diagram illustrating an example BFS tree. Figure 3 is a diagram illustrating a hybrid BFS. Figure 4 is a diagram illustrating a hybrid BFS. Figure 5 is a diagram illustrating a hybrid BFS. Figure 6 is a diagram illustrating an example configuration of a search device according to the first embodiment. Figure 7 is a diagram illustrating the algorithm for constructing a default tree. Figure 8 is a diagram illustrating the algorithm for reordering. Figure 9 is a diagram illustrating an example of a reordered graph. Figure 10 is a diagram illustrating an example of a reordered default tree. Figure 11 is a diagram illustrating an example of a reordered default tree. Figure 12 is a diagram illustrating the algorithm for BFS query processing. Figure 13 is a diagram illustrating bit parallel processing. Figure 14 is a diagram illustrating the search process. Figure 15 is a diagram illustrating the search process. Figure 16 is a diagram illustrating the search process. Figure 17 is a diagram illustrating the reduction of the number of bit operations. Figure 18 is a flowchart illustrating the processing flow for constructing a default tree. Figure 19 is a flowchart illustrating the processing flow for reordering. Figure 20 is a flowchart illustrating the BFS query processing flow. Figure 21 is a diagram illustrating an example of a computer executing a search program.
[0009] Embodiments of the search device and search method according to the present invention will be described in detail below with reference to the drawings. However, the present invention is not limited to the embodiments described below.
[0010] [Definition of BFS Tree] Here, we will explain BFS trees. A BFS tree starting at vertex s of a graph is a rooted tree that includes all vertices reachable from vertex s, with vertices at a distance of j from vertex s as parents, and vertices adjacent to the parent at a distance of j+1 as children.
[0011] Figure 1 shows an example of a graph. Figure 1 is a diagram illustrating an example of a graph. Each vertex of the graph in Figure 1 is distinguished by a number (in the example in Figure 1, the numbers are from 0 to 9).
[0012] Figure 2 shows an example of a BFS tree. Figure 2 shows a BFS tree constructed starting from vertex 1 of the graph.
[0013] [Definition of Parent Array] A BFS tree is represented by a parent array, which is an array that stores the parent of each vertex. The parent array p of the BFS tree starting from vertex s. s The sequence is as follows: 1. p s [s] = s 2. For a vertex u that is reachable from vertex s but is not vertex s, p s [u] is the parent of u. 3. For a vertex u that is inaccessible from vertex s, p s [u] = -1.
[0014] For example, the parent array corresponding to the BFS tree in Figure 2 is p 0 If we set it as p, 0 [0] = 0, p 0 [1] = 0, p 0 [2] = 1. From now on, we will treat the BFS tree and the parent array as identical. In other words, finding the BFS tree is equivalent to finding the parent array. Note that the BFS tree is not unique. For example, in Figure 1, vertices 2 and 8 are both 1 away from the starting point, and vertex 5 is adjacent to both of them. Therefore, in Figure 2, vertex 8 is the parent of vertex 5, but vertex 2 could be the parent instead.
[0015] The first embodiment speeds up BFS in a simple, undirected, scale-free graph. Scale-free properties are observed in various real-world graphs such as web graphs and social graphs. The output of BFS is a BFS tree. A BFS tree is a tree that represents the visitation paths performed by BFS from the starting point to each vertex.
[0016] For example, performing a BFS starting from vertex 1 in Figure 1 yields the BFS tree shown in Figure 2. BFS trees provide a wealth of information, such as the distance between vertices and the shortest path, making them useful for many applications. Requesting the BFS tree by giving a starting point is called a BFS query.
[0017] Here, we consider a use case where users repeatedly issue BFS queries to a single graph. This situation arises, for example, in route searching on a graph representing a railway network. When searching for a route from one starting point (station) to another station, the starting point differs depending on the user's interest, so the starting point is specified sequentially for a single graph. Also, since BFS must be performed from each vertex of the graph in the rigorous calculation of between centrality, a large number of BFS queries are similarly generated for a single graph.
[0018] In the first embodiment, it is assumed that the input graph is connected. If it contains multiple connected components, the same process is performed for each connected component.
[0019] We assume a BFS with the following iterative process as the baseline method. That is, for each unvisited vertex v adjacent to a vertex marked as the frontier in the previous iteration, (i) mark v as the frontier for the next iteration, (ii) mark v as visited, and (iii) assign the visited vertex to p[v] in the parent array p. Repeat steps (i), (ii), and (iii) until there are no more frontiers. However, the starting point is marked as both the frontier and visited first, and the starting point itself is recorded in the parent array as the parent of the starting point before the iteration begins. An iteration in BFS can be thought of as a process of constructing the frontier for the next iteration from the frontier at that point.
[0020] Hybrid BFS is an efficient BFS approach that combines two search directions: top-down search and bottom-up search. As mentioned above, top-down search constructs the frontier for the next iteration by searching for unvisited vertices among the adjacent vertices of each vertex included in the frontier (frontier vertices). Conversely, bottom-up search checks whether a vertex is included in the next frontier by searching for visited vertices among the adjacent vertices of an unvisited vertex.
[0021] In a top-down search, it is always necessary to check the visited status of all adjacent vertices, whereas in a bottom-up search, once one visited vertex is found among the adjacent vertices, the check for the remaining adjacent vertices can be stopped. Therefore, in iterations with many vertices adjacent to the frontier, a bottom-up search tends to be more efficient than a top-down search.
[0022] Furthermore, in bottom-up search, it is known that checking the visit status of adjacent vertices in order of degree can be terminated more quickly. This is because vertices adjacent to many other vertices tend to be visited earlier. Thus, the computational cost of the two search directions differs depending on the state of the search, so hybrid BFS searches by appropriately switching between them.
[0023] Figures 3, 4, and 5 show examples of the hybrid BFS process. Figures 3, 4, and 5 are diagrams illustrating the hybrid BFS.
[0024] Several heuristics have been proposed for selecting the search direction, but we will not discuss them here. Instead, we will consider the case where the first, second, and third iterations are executed in the order of top-down, bottom-up, and bottom-up, respectively. The numbers written on each vertex are vertex IDs. Here, vertex 1 is the starting point.
[0025] In Figures 3, 4, and 5, vertices filled with a pattern are frontier vertices. Vertices enclosed by dotted lines are visited vertices that are not frontiers. The edges indicated by arrows represent checks of the visited state. In the first iteration (Figure 3), only the starting point constitutes the frontier, and the visited state of adjacent vertices is checked from vertex 1 using a top-down search.
[0026] In the subsequent second (Figure 4) and third (Figure 5) iterations, a bottom-up search is used. The advantage of bottom-up search, which is the early termination of checking adjacent vertices, can be seen, for example, at vertex 5 in the second iteration (Figure 4). Vertex 5 is adjacent to vertices 2, 8, and 9, but since vertex 8, which has the highest degree among them, is the frontier, checking the visit status of vertices 2 and 9 is omitted. By combining the two search directions in this way, the search can be made more efficient.
[0027] The configuration of the search device 10 will be explained using Figure 6. Figure 6 is a diagram showing an example of the configuration of the search device according to the first embodiment. As shown in Figure 6, the search device 10 has a communication unit 11, an input unit 12, an output unit 13, a storage unit 14, and a control unit 15.
[0028] The communication unit 11 performs data communication with other devices. For example, the communication unit 11 is an interface such as a NIC (Network Interface Card).
[0029] The input unit 12 accepts data input. The input unit 12 is an interface connected to input devices such as a mouse and a keyboard.
[0030] The output unit 13 outputs data. The output unit 13 is an interface connected to output devices such as a display and a speaker.
[0031] The storage unit 14 is a storage device such as an HDD (Hard Disk Drive), SSD (Solid State Drive), or optical disc. Alternatively, the storage unit 14 may be a rewritable semiconductor memory such as RAM (Random Access Memory), flash memory, or NVSRAM (Non-Volatile Static Random Access Memory). The storage unit 14 stores the OS and various programs executed by the search device 10.
[0032] The memory unit 14 stores graph information 141. The graph information 141 includes, for example, a graph G.
[0033] The control unit 15 controls the entire search device 10. The control unit 15 is, for example, an electronic circuit such as a CPU, MPU (Micro Processing Unit), or GPU (Graphics Processing Unit), or an integrated circuit such as an ASIC (Application Specific Integrated Circuit) or FPGA (Field Programmable Gate Array). The control unit 15 also has an internal memory for storing programs that define various processing procedures and control data, and executes each process using the internal memory.
[0034] Furthermore, the control unit 15 functions as various processing units through the operation of various programs. For example, the control unit 15 has a predetermined tree construction unit 151, an order unit 152, and a search unit 153.
[0035] The default tree construction unit 151 constructs a BFS tree starting from the vertex with the highest degree in the graph. The ordering unit 152 assigns numbers to the vertices of the BFS tree according to their proximity to the starting point and the magnitude of their degree. The search unit 153 performs a BFS starting from a specified vertex in the graph using bitwise operations on the bit values corresponding to each number.
[0036] The details of the processing of the search device 10 will be described below. Here, in the scale-free graph, the BFS tends to have little change in the search path due to the selection of the starting point. The scale-free graph is composed of a small number of high-degree vertices (hub vertices) and a large number of low-degree vertices. Since the hub vertices adjacent to many vertices are relatively close to any vertex, they are likely to be visited in the initial iterations of the BFS. As a result, regardless of the starting point, many vertices will be visited via the neighboring hub vertices. This is the reason why it is likely to have the same search path regardless of the starting point.
[0037] Based on this observation, the search device 10 optimizes data access by focusing on the search path when performing BFS from the vertex with the highest degree. To perform the optimization, the search device 10 adopts a two-stage framework of (i) pre-computation for the graph and (ii) BFS query processing.
[0038] The default tree construction unit 151 performs BFS from the vertex with the highest degree in the pre-computation and constructs a BFS tree. The BFS tree constructed here is called the default tree. The default tree construction unit 151 can construct the default tree according to the algorithm shown in FIG. 7. FIG. 7 is a diagram showing the algorithm for constructing the default tree.
[0039] The ordering unit 152 re-numbers (re-orders) the vertex IDs in the order of visit for the graph and the default tree in the pre-computation. By re-ordering in this way, the child vertex IDs in the BFS tree are consecutive. The ordering unit 152 can perform the re-ordering according to the algorithm shown in FIG. 8. FIG. 8 is a diagram showing the algorithm for re-ordering.
[0040] FIG. 9 shows the graph as a result of re-ordering the graph in FIG. 1. FIG. 9 is a diagram showing an example of the re-ordered graph. Also, FIG. 10 shows the default tree as a result of re-ordering the default tree based on the graph in FIG. 1. Note that when the adjacency relationship of the graph in FIG. 1 is supplemented with a dotted line in the default tree, it becomes like FIG. 11. FIGS. 10 and 11 are diagrams showing examples of the re-ordered default tree.
[0041] As shown in FIGS. 9 and 10, the vertex 1 that had the highest degree in FIGS. 1 and 2 has been re-numbered as vertex 0. The vertex IDs of the children of vertex 0 are consecutive as 1, 2, 3, and 4. When the vertices have consecutive IDs like this, the corresponding flag data is also arranged consecutively in memory. Therefore, in the BFS query processing, not only does the consecutive access to memory increase, but as will be described later, it becomes possible to collectively operate the flags of a plurality of vertices bit-parallelly with one instruction using bit operations.
[0042] Although the starting point specified by the user is not necessarily the vertex with the maximum degree, as described above, the BFS access path changes little depending on the starting point. Therefore, such efficient data access can be implemented in many parts of the BFS tree construction for any starting point.
[0043] The precomputation of the first embodiment can speed up the BFS tree construction from any starting point if it is performed once for the graph. Such a design is effective for shortening the overall processing time in a situation where the user repeatedly gives starting points for a single graph.
[0044] [Precomputation] As described above, in the precomputation, the construction of the default tree and the reordering are performed. Unless otherwise specified, the parent or child of a vertex means the parent and child of that vertex in the default tree. For efficient BFS query processing, it is preferable that the default tree reflects a search path that is less likely to change depending on the starting point. The BFS tree is not unique, and any adjacent vertex closer to the starting point than itself can be selected as the parent of that vertex.
[0045] Here, in a scale-free graph, high-degree vertices are likely to be accessed early, so the higher the degree of an adjacent vertex, the higher the probability that it is closer to the starting point than itself. Therefore, the default tree construction unit 151 constructs a default tree with little structural change by selecting the vertex with the highest degree as the parent.
[0046] As shown in the pseudocode in Figure 7, the default tree construction unit 151 first performs a BFS from the highest-degree vertex to obtain the distance between the parent array and each vertex. Next, for each vertex v excluding the starting point, the default tree construction unit 151 resets the parent array by setting the highest-degree adjacent vertex that is closer to the starting point than v as the parent. In this way, a BFS tree with small structural changes dependent on the starting point can be obtained.
[0047] In the subsequent reordering process, the ordering unit 152 assigns vertex IDs according to the order of visits in the path represented by the default tree. That is, the ordering unit 152 assigns the starting vertex ID to 0, and sequential IDs to the child vertices in order from the vertices closest to the starting point. At this time, in order to improve cache efficiency in BFS query processing, the ordering unit 152 sorts the children in descending order of degree. Since the data of vertices with higher degrees is accessed more frequently, the ordering unit 152 can improve locality by assigning IDs closer to the parent to vertices with higher degrees and placing them in close proximity in memory.
[0048] For example, the ordering unit 152 reorders the graph in Figure 1 and the default tree in Figure 2 according to the pseudocode in Figure 8 to obtain the graph in Figure 9 and the default tree in Figure 10.
[0049] [BFS Query Processing] Next, we will explain the BFS query processing after the user provides the starting point. By obtaining the vertex IDs of consecutive children through pre-calculation, the data manipulation of the children changes from irregular memory access to efficient contiguous memory access. To take advantage of this, the search unit 153 divides each BFS iteration into two steps: (i) visits to children and (ii) visits to non-child vertices.
[0050] Figure 12 shows the algorithm for BFS query processing.
[0051] As shown in Figure 12 from line 19 onwards, the search unit 153 performs visits to non-child databases in the same way as in conventional BFS (for example, hybrid BFS).
[0052] On the other hand, as shown in lines 9 to 18 of Figure 12, the search unit 153 improves the efficiency of visits to children compared to conventional methods by using two techniques: bit-parallel visits and visit aggregation.
[0053] [Bit-Parallel Visits] Bit-parallel visits are a technique for processing data from multiple vertices with a single instruction. In BFS, each vertex has a visit flag and a frontier flag. The visit flag and frontier flag are 1-bit values, one true and one false. This allows the search unit 153 to compactly store information for each vertex.
[0054] Here, the bit vector is implemented as an array of integers of a suitable word length. If the word length is w bits, the value of the index i corresponds to the i%w+1 bit of the integer value of the integer part + 1 of (i / w). Here, i%w represents the remainder when i is divided by w.
[0055] For example, an array of 64-bit integers with length 4 constitutes a bit vector with 256 elements. In this bit vector, the value at index 135 corresponds to the 8th bit of the 3rd integer value. Hereafter, the bit vectors for the visit flag and the frontier flag will be referred to as the visit vector and the frontier vector, respectively.
[0056] The search unit 153 performs BFS by updating a visit vector, which has a bit value as an element corresponding to each number of a vertex in the graph and indicating whether or not it has been visited, and a frontier vector, which has a bit value as an element corresponding to each number and indicating whether or not the vertex indicated by the number is a frontier.
[0057] In BFS, for each adjacent vertex of a frontier vertex, if it is not yet visited, three operations are performed: (i) mark it as visited, (ii) mark it as the next frontier, and (iii) record the source of the visit in the parent array.
[0058] The search unit 153 utilizes the fact that the vertex IDs of children among adjacent vertices are consecutive, and can implement (i) and (ii) by manipulating the values of the index range corresponding to the children in the bit vector, respectively.
[0059] First, in the process of marking a vertex as visited, the search unit 153 fills the range of the visit vector corresponding to the child vertex ID with 1. In this process, there may be a visited vertex among the children, but the operation of overwriting something that is already 1 with 1 is idempotent. Therefore, the search unit 153 does not need to distinguish the visit status of the children.
[0060] Furthermore, the frontier vector used by the search unit 153 in the next iteration has values where visited vertices at the start of this iteration are 0 and unvisited vertices are 1, and can be obtained by inverting the visit vector. Finally, the search unit 153 can omit recording the source of visits in the parent array by starting the search with the pre-calculated parent array of the default tree as the initial value of the parent array. This is because what is being discussed here is a visit from the parent of the default tree to its child, that is, a visit from a source recorded in the parent array of the default tree.
[0061] Therefore, the search unit 153 can perform operations on children only by padding (visiting) and inverting (finding the next frontier) consecutive bit sequences on the bit vector. Since padding and inverting of subscript ranges in a bit vector can be performed by word-level bit operations (rather than bit-level), multiple vertices can be processed simultaneously in bit-parallel. In this way, the present invention efficiently performs operations on children.
[0062] Figure 13 illustrates bitwise parallel processing. Assume that in the initial state of a certain iteration, only vertex 0 is a frontier vertex and has been visited. In this case, unlike the state in Figure 13, the visit vector is (1,0,0,0,0,0,0,0,0,0,0). The children of vertex 0, which is a frontier vertex, are vertices 1, 2, 3, and 4. Therefore, the search unit 153 updates the next frontier vector with 1111, which is the inverted bit sequence 0000 based on the values of the visit vectors corresponding to vertices 1, 2, 3, and 4.
[0063] [Visit Aggregation] To perform bit-parallel visits more efficiently, the search unit 153 aggregates operations on children for multiple frontier vertices and converts them into operations on a larger index range of the bit vector. This is called visit aggregation.
[0064] Visit aggregation is possible because vertices with consecutive IDs also have consecutive child IDs. For example, in the default tree in Figure 10, the children of vertices 1-4 (vertices 1, 2, 3, and 4) are vertices 5-8, and the child IDs are consecutive. Therefore, the search unit 153 can sometimes operate on vertices 5-8 together, rather than operating on the children of vertex 1 (vertices 5 and 6), the children of vertex 3 (vertex 7), and the children of vertex 4 (vertex 8) separately.
[0065] Since operations on bit vectors are performed on a word-by-word basis, the search unit 153 can process more efficiently by targeting a larger index range.
[0066] Here, the subscript range operated by the search unit 153 may include not only the children of the frontier vertex but also the children of any vertex visited up to the previous iteration. This relaxation is permissible because the processing result does not change even if the subscript range includes the children of any vertex visited up to the previous iteration.
[0067] The children of vertices visited up to the previous iteration have either already been visited in the current iteration or will be visited in the future. For this reason, the search unit 153 may write a 1 to the visit vector for the children of vertices visited up to the previous iteration.
[0068] Furthermore, the next frontier vector, which assigns 1 to unvisited vertices and 0 to visited vertices, is still obtained by inverting the visit vector, and therefore does not affect the calculation result. By utilizing this property, the search unit 153 can combine multiple subscript ranges to create an even larger subscript range.
[0069] [Application to Hybrid BFS] In the algorithm in Figure 12, V(G) is the set of vertices of graph G. Also, x[i:j] represents the range (including j) from the index i to j of the bit vector x.
[0070] As shown in Figure 12, the search unit 153 initializes the frontier vector, visit vector, and parent array based on the initially given starting point r (lines 1-6). The search unit 153 then repeats the iteration until there are no more frontier vertices (lines 7-34).
[0071] The iterations are broadly divided into visits to children (lines 9-18) and visits to non-children (lines 19-33).
[0072] The search unit 153 visits children in order from the frontier with the largest vertex ID. This is because visit aggregation requires the visit vector from the previous iteration. Since the search unit 153 modifies the visit vector b in the current iteration by overwriting it on the fly, it is necessary to avoid this modification affecting the result of visit aggregation.
[0073] Here, since the ID of a child vertex is always larger than that of its parent, processing vertices in order from the largest ID results in an update order where the modified portion of the visit vector extends from the back to the front. This allows the search unit 153 to calculate the subscript range [i:j] of the bit vector based on the visit aggregation while referring to the visit status of the previous iteration. The search unit 153 then calculates the next frontier vector (line 16) and marks the vertices as visited (line 17) for the subscript range [i:j].
[0074] On the other hand, the search unit 153 visits adjacent vertices other than children in much the same way as a typical hybrid BFS. The search unit 153 decides whether to use a top-down search or a bottom-up search (line 19). The method of decision can be a known method.
[0075] When using a top-down search, the search unit 153 processes each non-child adjacent vertex for each frontier vertex. When using a bottom-up search, the search unit 153 checks whether each adjacent vertex is a frontier for each unvisited vertex.
[0076] Here, the search unit 153 may exclude the parent of an adjacent vertex from the check (line 28). This is because if v is both a parent and a frontier, then u should have already been visited during the visit to the child in this iteration. In a scale-free graph, there are many vertices of low degree, so reducing the number of adjacent vertices to check by one for each of them is effective in terms of performance.
[0077] As described above, the search unit 153 can apply bit-parallel visits to the hybrid BFS. However, the search unit 153 may apply a method other than the hybrid BFS (for example, a top-down only BFS) to the portion of the search that visits adjacent vertices other than children.
[0078] [Example] Figures 14, 15, and 16 illustrate the changes in vectors during an actual search. Figures 14, 15, and 16 are diagrams illustrating the search process. Vertices filled with a pattern are frontier vertices. Vertices enclosed by dotted lines are visited vertices that are not frontiers.
[0079] The search unit 153 performs BFS on the reordered graph shown in Figure 9 and the reordered default trees shown in Figures 10 and 11.
[0080] Figures 14, 15, and 16 show the state of the default tree, visit vector b, next frontier vector f', and parent array p after the visit operation is completed in each iteration. The cells showing the pattern are elements of the vector that were written to.
[0081] The search direction for the hybrid BFS is top-down, bottom-up, bottom-up in that order.
[0082] As shown in Figure 12, the algorithm terminates when the frontier vector f = 0, so there is actually a fourth iteration after Figure 16. However, as shown in Figure 16, all vertices are visited in the third iteration, so the explanation of the fourth iteration is omitted. The next frontier vector is simply substituted into the frontier vector f.
[0083] The starting point is vertex 3. As shown in Figure 14, the search unit 153 starts the first iteration with a bit-parallel search, with only the starting point having been visited. Then, vertex 7, a child of vertex 3, is visited.
[0084] Next, the search unit 153 performs a top-down search and visits vertex 0, which is an adjacent vertex that is not a child of vertex 3.
[0085] As shown in Figure 15, in the second iteration, the search unit 153 performs a bitwise parallel search on vertices 1-4, which are children of vertex 0. Since only vertex 3 among the children of vertex 0 has been visited, the search unit 153 writes 1101, which is the inversion of the visit vector b[1:4] = 0010, to the next frontier vector f'[1:4].
[0086] In the subsequent bottom-up search, the search unit 153 omits checking for parents in the default tree. For example, vertex 9 is adjacent to vertices 5, 6, 7, and 8, but since vertex 5 is the parent, the check is omitted.
[0087] As shown in Figure 16, in the third iteration, vertices 1, 2, 4, and 9 are frontier vertices. Here, vertex 3 is not a frontier vertex, but it was visited in the previous (second) iteration. Therefore, the search unit 153 performs a single bit-parallel search on vertices 5-8, which are children of vertices 1-4, by visit aggregation. In this way, the search unit 153 can update the values of the elements of the visit vector corresponding to all children of all visited vertices in a single operation.
[0088] As a result, the search unit 153 can reduce the number of data operations compared to when it performs individual bit-parallel searches for the children of vertices 1 and 2 (vertices 5 and 6) and the child of vertex 4 (vertex 8). As shown in Figure 16, when performing individual bit-parallel searches, two data operations are required. Figure 17 is a diagram illustrating the reduction in the number of bit operations. Note that since vertices 5, 6, and 8 are not visited, the search unit 153 cannot perform a single bit-parallel operation on all frontier vertices together as children of vertices 1-9.
[0089] Looking at the three iterations as a whole, the parent array is rewritten only for vertices 0 and 9, while all others remain at the values of the parent array of the default tree. Since the bit vector is also rewritten for a contiguous range of indices, multiple vertices can be processed simultaneously. This reduction in the number of data accesses makes the BFS processing more efficient according to the first embodiment.
[0090] [Process Flow of the First Embodiment] The process flow for constructing a default tree will be explained using Figure 18. Figure 18 is a flowchart showing the process flow for constructing a default tree.
[0091] As shown in Figure 18, first, the default tree construction unit 151 performs a BFS starting from the highest-order vertex in the graph and calculates the parent array and the distance from the starting point to each vertex (step S101).
[0092] Here, the default tree construction unit 151 selects an unselected vertex if there is an unselected vertex other than the starting point (step S102; Yes) (step S103). Then, the default tree construction unit 151 sets the vertex with the highest degree among the adjacent vertices that are closer to the starting point than the selected vertex as the parent (step S104). After that, the default tree construction unit 151 returns to step S102 and repeats the process.
[0093] The default tree construction unit 151 outputs the parent array (step S105) and terminates processing if there are no unselected vertices other than the starting point (step S102; No).
[0094] Figure 19 will be used to explain the reorder process. Figure 19 is a flowchart showing the reorder process.
[0095] As shown in Figure 19, first, the ordering unit 152 adds the root vertex of the default tree to an empty list (step S201). Also, the ordering unit 152 changes the root vertex ID of the default tree to 0 (step S202).
[0096] If there are unselected vertices in the list (step S203; Yes), the ordering unit 152 selects an unselected vertex (step S204). Then, the ordering unit 152 adds the child vertices of the selected vertex in the default tree to the list in order of degree, and changes the vertex IDs to match the order in which they were added to the list (step S205). After that, the ordering unit 152 returns to step S203 and repeats the process.
[0097] If there are no unselected vertices in the list (step S203; No), the order unit 152 outputs the modified vertex ID (step S206) and terminates the process.
[0098] Figure 20 illustrates the BFS query processing flow. Figure 20 is a flowchart showing the BFS query processing flow.
[0099] First, as shown in Figure 20, the search unit 153 accepts input of a graph with modified vertex IDs, a default tree with modified vertex IDs, and a starting point (step S301). The search unit 153 also sets the value of the starting point of the frontier vector to 1 and the values of the other vertices to 0 (step S302). The search unit 153 also sets the value of the starting point of the visit vector to 1 and the values of the other vertices to 0 (step S303). The search unit 153 also sets the parent array of the default tree as the initial value of the parent array (step S304).
[0100] Here, if the values of the frontier vectors are not all zero (i.e., there is one) (step S305; No), the search unit 153 sets all the values of the next frontier vectors to zero (step S306).
[0101] Then, the search unit 153 updates the next frontier vector and visit vector by bit-parallel visits using visit aggregation (step S307).
[0102] Furthermore, the search unit 153 updates the next frontier vector, visit vector, and parent array using the hybrid BFS (step S308).
[0103] Then, the search unit 153 substitutes the next frontier vector into the frontier vector (step S309). After that, the search unit 153 returns to step S305 and repeats the process.
[0104] If all the values of the frontier vector are 0 (step S305; Yes), the search unit 153 outputs the parent array (step S310) and terminates the process.
[0105] As explained above, the default tree construction unit 151 constructs a BFS tree starting from the vertex with the highest degree in the graph. The ordering unit 152 assigns numbers to the vertices of the BFS tree according to their proximity to the starting point and the magnitude of their degree. The search unit 153 performs a BFS starting from a specified vertex in the graph using bitwise operations on the bit values corresponding to each number.
[0106] As a result, the search device 10 can implement at least a part of the BFS by manipulating bits on a word-by-word basis. Furthermore, the search device 10 can process multiple vertices simultaneously in bit-parallel. Consequently, the search device 10 can reduce the processing time of the BFS.
[0107] [System Configuration, etc.] Furthermore, each component of each illustrated device is a functional concept and does not necessarily have to be physically configured as shown. In other words, the specific forms of distribution and integration of each device are not limited to those shown, and all or part of them can be functionally or physically distributed or integrated in any unit according to various loads and usage conditions. In addition, each processing function performed by each device can be realized in whole or in any part by a CPU (Central Processing Unit) and a program that is analyzed and executed by the CPU, or it can be realized as hardware using wired logic. Note that the program may be executed not only by the CPU but also by other processors such as a GPU.
[0108] Furthermore, among the processes described in this embodiment, 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 by known methods. In addition, the processing procedures, control procedures, specific names, and information including various data and parameters shown in the above document and drawings can be arbitrarily changed unless otherwise specified.
[0109] [Program] In one embodiment, the search device 10 can be implemented by installing a search program that performs the above-mentioned search process as packaged software or online software on a desired computer. For example, by having the above-mentioned search program run on an information processing device, the information processing device can be made to function as the search device 10. The information processing device referred to here includes desktop or notebook personal computers. In addition, the category of information processing device also includes mobile communication terminals such as smartphones, mobile phones and PHS (Personal Handyphone System), and slate terminals such as PDA (Personal Digital Assistant).
[0110] Furthermore, the search device 10 can also be implemented as a search server device that uses a user's terminal device as a client and provides services related to the search process described above to that client. For example, the search server device can be implemented as a server device that takes a graph as input and provides a search service that outputs a BFS tree. In this case, the search server device may be implemented as a web server, or it may be implemented as a cloud that provides services related to the search process described above through outsourcing.
[0111] Figure 21 shows an example of a computer running a search program. Computer 1000 has, for example, memory 1010 and CPU 1020. Computer 1000 also has 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.
[0112] Memory 1010 includes ROM (Read Only Memory) 1011 and RAM (Random Access Memory) 1012. ROM 1011 stores, for example, a boot program such as BIOS (Basic Input Output System). The hard disk drive interface 1030 is connected to the hard disk drive 1090. The disk drive interface 1040 is connected to the disk drive 1100. For example, 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, for example, a mouse 1110 and a keyboard 1120. The video adapter 1060 is connected to, for example, a display 1130.
[0113] The hard disk drive 1090 stores, for example, the OS 1091, application program 1092, program module 1093, and program data 1094. That is, the program that defines each process of the search device 10 is implemented as a program module 1093 in which executable code for a computer is written. The program module 1093 is stored, for example, in the hard disk drive 1090. For example, a program module 1093 for performing the same processes as the functional configuration of the search device 10 is stored in the hard disk drive 1090. Note that the hard disk drive 1090 may be replaced by an SSD (Solid State Drive).
[0114] Furthermore, the configuration data used in the processing of the above-described embodiment is stored as program data 1094 in, for example, memory 1010 or hard disk drive 1090. The CPU 1020 then reads the program module 1093 and program data 1094 stored in memory 1010 or hard disk drive 1090 into RAM 1012 as needed and executes the processing of the above-described embodiment.
[0115] Furthermore, the program module 1093 and program data 1094 are not limited to being stored in the hard disk drive 1090; for example, they may be stored in a removable storage medium and read by the CPU 1020 via a 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 (LAN (Local Area Network), WAN (Wide Area Network), etc.). The program module 1093 and program data 1094 may then be read by the CPU 1020 from the other computer via a network interface 1070.
[0116] 10 Search device 11 Communication unit 12 Input unit 13 Output unit 14 Storage unit 141 Graph information 15 Control unit 151 Default tree construction unit 152 Order unit 153 Search unit
Claims
1. A search device comprising: a default tree construction unit that constructs a BFS tree starting from the vertex with the highest degree in the graph; an ordering unit that assigns numbers to the vertices of the BFS tree according to their proximity to the starting point and the magnitude of their degree; and a search unit that performs a BFS starting from a specified vertex in the graph using bitwise operations on the bit values corresponding to each of the numbers.
2. The search device according to claim 1, characterized in that the search unit performs the BFS by updating a visit vector, which has a bit value as an element corresponding to each of the numbers and indicating whether or not it has been visited, and a frontier vector, which has a bit value as an element corresponding to each of the numbers and indicating whether or not the vertex indicated by the number is a frontier.
3. The search device according to claim 2, characterized in that the search unit updates the values of the elements of the visit vector corresponding to all children of all visited vertices in a single operation.
4. A search method performed by a search device, comprising: a default tree construction step of constructing a BFS tree starting from the vertex with the highest degree of the graph; an ordering step of assigning numbers to the vertices of the BFS tree according to their proximity to the starting point and the magnitude of their degree; and a search step of performing a BFS starting from a specified vertex of the graph using bitwise operations on the bit values corresponding to each of the numbers.