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

Figure JP2025005473_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] Breadth-first search (BFS) is a well-known method for manipulating data in graph structures. BFS is used in fields such as data mining, route planning (car navigation, transit information), network design, and circuit design.
[0003] One method for constructing a BFS tree involves performing a BFS on the entire graph from a given starting point each time. In contrast, an efficient breadth-first search method based on 2-core decomposition is known (see, for example, Patent Document 1).
[0004] The technology described in Patent Document 1 focuses on the fact that subgraphs with a tree structure in a graph appear in the BFS tree in their original form. Specifically, the technology described in Patent Document 1 efficiently constructs a BFS tree using a two-stage framework: pre-calculation of the graph and BFS tree construction processing when a starting point is given by the user. In the pre-calculation, the graph is decomposed into a collection of trees (forest) and non-tree parts. The non-tree parts are identical to 2-cores in graph theory. In the BFS tree construction processing, if the starting point is in a 2-core, normal BFS is performed only within the 2-core, and the trees included in the forest are joined to the resulting BFS tree. If the starting point is in a forest, normal BFS is performed on the path from the starting point to the 2-core and in the 2-core, and similarly, the trees included in the forest are joined. In this way, the technology described in Patent Document 1 reduces computational cost by excluding most of the forest from the BFS search range.
[0005] International Publication No. 2024 / 176415
[0006] Robert Tarjan, "Depth-first search and linear graph algorithms," SIAM Journal on Computing, Vol. 1, pp. 146-160, 1972.
[0007] However, conventional technologies have the problem of long processing times. For example, the technology described in Patent Document 1 cannot effectively reduce computation time when the 2-core of the graph is large.
[0008] To solve the above-mentioned problems and achieve the objective, the search device is characterized by having: an identification unit that identifies the joint point closest to the first block in each of the second blocks, which are blocks other than the first block, which is a plurality of doubly connected components included in the graph; and a first search unit that constructs a first sub-BFS tree by performing BFS from the joint point identified by the identification unit for each of the second blocks.
[0009] According to the present invention, the processing time of BFS can be shortened.
[0010] Figure 1 shows an example graph. Figure 2 shows an example BFS tree. Figure 3 shows an example configuration of the search device according to the first embodiment. Figure 4 shows the pre-computation algorithm. Figure 5 is a diagram illustrating a block (dual-connected component). Figure 6 shows an example block-cut tree. Figure 7 shows an example of a sub-BFS tree corresponding to each block. Figure 8 is a diagram illustrating the search range when the starting point is included in the largest block. Figure 9 is a diagram illustrating the correspondence between the BFS tree and each block when the starting point is included in the largest block. Figure 10 shows the algorithm for constructing the entire BFS tree. Figure 11 is a diagram illustrating the search range when the starting point is not included in the largest block. Figure 12 is a diagram illustrating the correspondence between the BFS tree and each block when the starting point is not included in the largest block. Figure 13 is a flowchart showing the pre-computation process flow. Figure 14 is a flowchart showing the overall BFS tree construction process flow. Figure 15 shows an example of a computer executing the search program.
[0011] 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.
[0012] [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.
[0013] 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).
[0014] Figure 2 shows an example of a BFS tree. Figure 2 shows a BFS tree constructed starting from vertex 7 of the graph.
[0015] [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.
[0016] 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.
[0017] [Definition of BFS Query Problem] Given vertices s, the problem of finding a BFS tree starting from vertex s is called a BFS query problem. One objective of this embodiment is to solve BFS query problems efficiently.
[0018] Here, in the graph of FIG. 1 (hereinafter referred to as graph G), vertices 8, 1, and 3 form a tree structure. And this tree structure appears as is in the lower right part of the BFS tree in FIG. 2. Based on such an observation, in the technique described in Patent Document 1, the processing cost of BFS tree construction is reduced by extracting the tree structure in advance.
[0019] [Definition of an articulation point] When the number of connected components of a graph increases by deleting a certain vertex, that vertex is called an articulation point.
[0020] [Definition of a biconnected component] A maximal subgraph without articulation points is called a biconnected component. A biconnected component is also called a block.
[0021] [Definition of a block-cut tree] A tree that uses the blocks of a graph as vertices and the connections between blocks via articulation points as edges is called a block-cut tree.
[0022] In the first embodiment, similar to the technique described in Patent Document 1, two-stage processing of pre-computation and BFS tree construction processing (BFS query processing) is performed. The central idea of the first embodiment is to divide the graph into blocks. Since blocks are connected via articulation points, when entering another block from a block in the BFS search, an articulation point must be passed through. Therefore, for a certain block B i if the starting point of BFS is outside B i then, in the BFS tree of the entire graph (overall BFS tree), the part corresponding to B i (partial BFS tree) necessarily has a structure with an articulation point as the root. Utilizing this, in the first embodiment, a partial BFS tree with an articulation point as the root is constructed for each block as pre-computation. And when the starting point of BFS is given by the user, the overall BFS tree is constructed without searching the entire graph by joining the partial BFS trees of each block.
[0023] The configuration of the search device 10 will be described using FIG. 3. FIG. 3 is a diagram showing a configuration example of a search device according to the first embodiment. As shown in FIG. 3, the search device 10 includes a communication unit 11, an input unit 12, an output unit 13, a storage unit 14, and a control unit 15.
[0024] 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).
[0025] The input unit 12 receives data input. The input unit 12 is an interface connected to input devices such as a mouse and a keyboard, for example.
[0026] The output unit 13 outputs data. The output unit 13 is an interface connected to output devices such as a display and a speaker, for example.
[0027] The storage unit 14 is a storage device such as a HDD (Hard Disk Drive), SSD (Solid State Drive), or optical disk. Note that the storage unit 14 may be a semiconductor memory capable of rewriting data, such as a RAM (Random Access Memory), flash memory, or NVRAM (Non-Volatile Static Random Access Memory). The storage unit 14 stores the OS and various programs executed by the search device 10.
[0028] The storage unit 14 stores graph information 141. The graph information 141 includes, for example, the graph G.
[0029] The control unit 15 controls the entire search device 10. The control unit 15 is, for example, an electronic circuit such as a CPU (Central Processing Unit), 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 and control data that define various processing procedures, and executes each process using the internal memory.
[0030] Furthermore, the control unit 15 functions as various processing units through the operation of various programs. For example, the control unit 15 has a specific unit 151, a search unit 152, and a connection unit 153.
[0031] The identification unit 151, in the pre-calculation, identifies the joint point closest to the first block in each of the second blocks, which are all blocks other than the first block (the block with the most vertices) among the multiple doubly connected components included in the graph. The search unit 152 then constructs a first sub-BFS tree for each of the second blocks by performing BFS from the joint points identified by the identification unit 151. At this time, the search unit 152 functions as the first search unit.
[0032] In BFS tree construction (BFS query processing), the search unit 152 constructs a second partial BFS tree by performing BFS from a specified starting point in a subgraph derived from a set of vertices contained in a third block containing a specified starting point of the graph and an ancestor block of the third block on a block-cut tree whose vertices are multiple blocks and whose root is the first block. At this time, the search unit 152 functions as a second search unit. The junction unit 153 junctions the first partial BFS tree, constructed for blocks among the multiple blocks that are not included in the set and that share vertices with the second partial BFS tree, to the second partial BFS tree.
[0033] The following provides a detailed explanation of the pre-calculation and BFS tree construction.
[0034] [Pre-calculation] Figure 4 shows the algorithm for pre-calculation. In the pre-calculation, the search unit 152 constructs a rooted block-cut tree and a sub-BFS tree corresponding to each block. The search unit 152 can construct the block-cut tree using, for example, the lowlink method (see Non-Patent Literature 1). The search unit 152 uses the block with the most vertices (the largest block) as the root of the block-cut tree. The reason will be explained later.
[0035] Next, the search unit 152 constructs a sub-BFS tree for each block.
[0036] As mentioned above, if the starting point is in another block, the search within the block is performed via the articulation points, so the block's BFS tree has a structure with the articulation points as its roots. However, a block may be connected to other blocks at multiple articulation points, and which articulation points are used for the search within the block depends on the choice of the starting point. If we were to try to construct a sub-BFS tree with every articulation point as its root, the time required for pre-computation and the amount of memory consumed could increase to an unrealistic level.
[0037] Therefore, in the first embodiment, it is assumed that the starting point of the BFS is located within the largest block with a high probability. Under this assumption, the search for each block is performed starting from the articulation point closest to the largest block, thus limiting the number of sub-BFS trees to one per block. Furthermore, since the block containing the starting point does not take the BFS tree structure with the articulation point as its root, a sub-BFS tree for the largest block is not constructed. For these reasons, in the pre-computation, a sub-BFS tree is constructed for each block other than the largest block, with the articulation point closest to the largest block as its root. The search unit 152 generates the block cut tree obtained in this way and the sub-BFS trees for each block in the pre-computation.
[0038] As an example, the pre-calculation process will be explained using the graph in Figure 1. As shown in Figure 1, deleting any of vertices 2, 8, or 9 increases the number of connected components in the graph to two or more, so the identification unit 151 identifies vertices 2, 8, and 9 as joint points.
[0039] There are five maximal subgraphs (blocks) that do not have articulation points, as shown in Figure 5. A block cut tree representing the connection relationships of these blocks is shown in Figure 6. Figure 5 is a diagram illustrating a block (dual-connected component). Figure 6 is a diagram showing an example of a block cut tree.
[0040] First, the search unit 152 constructs a block cut tree as shown in Figure 6. The largest block is B, which contains 4 vertices. 2 Next, the search unit 152 is B 2 Construct a sub-BFS tree for each block other than the others.
[0041] As shown in Figure 7, the search unit 152 is B1 Regarding this, a sub-BFS tree is constructed with vertex 9, the only joint point, as the root. Figure 7 shows an example of a sub-BFS tree corresponding to each block. The search unit 152 is B 3 Regarding the two joint points, vertices 2 and 8, B 2 (B) 2 A subBFS tree is constructed with vertex 2 (included in) as the root. The search unit 152 is B 4 , B 5 Similarly, a sub-BFS tree is constructed for this as well.
[0042] [BFS Tree Construction] Next, we will explain the process after the user provides the starting point for the BFS, i.e., the BFS tree construction process. Here, we accept the specification of the vertex that will be the starting point. We will explain the case where the starting point is included in the largest block and the case where the starting point is not included in the largest block separately.
[0043] The search unit 152, if the starting point is included in the largest block, performs a normal BFS from the starting point inside the largest block to obtain a sub-BFS tree corresponding to the largest block. The junction unit 153 obtains the overall BFS tree by joining the pre-calculated sub-BFS trees to each joint point in order of proximity to the largest block.
[0044] Figure 8 illustrates the search range when the starting point is included in the largest block. In the example in Figure 8, vertex 7 is the starting point. Vertex 7 is in the largest block, B. 2 Since it is included in B, the search unit 152 is B 2 Explore only the interior of [the element].
[0045] As a result, the search unit 152 constructs the structure of the portion including vertices 7, 9, 5, and 2 in Figure 9. Figure 9 is a diagram illustrating the correspondence between the BFS tree and each block when the starting point is included in the largest block.
[0046] Vertex 9 and vertex 2 are joint points. The joint 153 is connected to vertex 9 by block B 1 Join them, and block B to vertex 2. 3 The two are joined together. Furthermore, the joint 153 connects to the vertex 8, which is the joint point, and block B 4 and Block B 5The elements are joined together. This results in a BFS tree similar to that in Figure 2, as shown in Figure 9.
[0047] This section explains the case where the starting point is not included in the largest block. The algorithm for this case is shown in Figure 10. Figure 10 is a diagram showing the algorithm for constructing the entire BFS tree.
[0048] Note that the pre-calculated partial BFS tree has a structure where the articulation point closest to the largest block is the root. Such a structure appears in the overall BFS tree only when visited from the parent block in the block cut tree. Therefore, the pre-calculated partial BFS tree cannot be used for the block containing the starting point. Similarly, the ancestors of that block in the block cut tree cannot be visited from the children, so the pre-calculated partial BFS tree cannot be used for them either. Therefore, the search unit 152 treats those blocks as targets for BFS in the usual way. The junction unit 153 then obtains the overall BFS tree by joining the partial BFS trees of blocks not included in the search range to the result.
[0049] If the starting point is contained within the largest block, then "the block containing the starting point and its ancestors in the block-cut tree" will only include the largest block. Therefore, this processing procedure allows processing without distinguishing whether the block containing the starting point is the largest block or not.
[0050] Figure 11 illustrates the search range when the starting point is not included in the largest block. In the example in Figure 11, vertex 1 is the starting point. Vertex 1 is B 4 It is included in B. 4 It is not the largest block. In this case, the search unit 152 is B 4 And, in the block-cut tree (Figure 6), B 4 B, the ancestor of 3 and B 2 This will be the target of a standard BFS search.
[0051] The search area is B in Figure 11. 2 , B 3 , B 4This is the range included. In other words, vertices 6, 0, and 3 are not included in the search range. The search unit 152 performs BFS from vertex 1 within this search range to construct a tree structure including vertices 1, 8, 2, 4, 7, 9, and 5 in Figure 12. The junction unit 153 applies BFS to the constructed tree structure. 1 and B 5 The entire BFS tree is obtained by joining the sub-BFS trees.
[0052] [Process Flow of the First Embodiment] The process flow of the pre-calculation will be explained using Figure 13. Figure 13 is a flowchart showing the process flow of the pre-calculation.
[0053] As shown in Figure 13, first, the search unit 152 finds a block which is a doubly connected component of the graph (step S101). The search unit 152 also sets the block with the most vertices as the maximum block (step S102). The search unit 152 constructs a block cut tree with the found blocks as vertices and the maximum block as the root (step S103).
[0054] If the search unit 152 finds an unselected block among the blocks other than the largest block (step S104; Yes), it selects the unselected block (step S105). Then, the search unit 152 obtains the joint point, which is the vertex of the selected block that is closest to the largest block (step S106). The joint point may also be identified by the identification unit 151.
[0055] The search unit 152 performs BFS from the articulation points within the selected block and constructs a partial BFS tree (step S107). The search unit 152 repeats the process from steps S104 to S107 until there are no unselected blocks.
[0056] If the search unit 152 finds that there are no unselected blocks among the blocks other than the largest block (step S104; No), it outputs the constructed sub-BFS tree (step S108) and terminates the process. The search unit 152 may also store the constructed sub-BFS tree in the storage unit 14.
[0057] Figure 14 is used to explain the process flow for constructing the entire BFS tree. Figure 14 is a flowchart showing the process flow for constructing the entire BFS tree.
[0058] As shown in Figure 14, first the search unit 152 accepts input for the starting point (step S201). Next, the search unit 152 obtains a subgraph derived from the set of vertices of the block containing the starting point and the ancestor block on the block cut tree (step S202).
[0059] Next, the search unit 152 performs BFS from the starting point within the subgraph to construct a sub-BFS tree (step S203).
[0060] Here, the search unit 152 selects an unselected block (step S205) if there is an unselected block among the blocks that are not included in the subgraph and share vertices with the constructed sub-BFS tree (step S204; Yes).
[0061] The junction unit 153 joins the selected block to a vertex shared by the sub-BFS tree (step S206). Then, the search unit 152 returns to step S204 and repeats the process.
[0062] If the search unit 152 finds that there are no unselected blocks among the blocks other than the largest block (step S204; No), it outputs the joined partial BFS tree (step S207) and terminates the process.
[0063] As explained above, the identification unit 151 identifies the joint point closest to the first block in each of the second blocks, which are the blocks other than the first block, which is the block with the most vertices among the multiple doubly connected components included in the graph. The search unit 152 constructs the first sub-BFS tree by performing BFS on each of the second blocks from the joint points identified by the identification unit 151.
[0064] Furthermore, the search unit 152 constructs a second sub-BFS tree by performing a BFS from the specified starting point in a subgraph derived from a set of vertices contained in a third block containing the specified starting point of the graph and an ancestor block of the third block on a block-cut tree whose vertices are multiple blocks and whose root is the first block. The junction unit 153 joins the first sub-BFS tree, which was constructed for blocks among the multiple blocks that are not included in the set and that share vertices with the second sub-BFS tree, to the second sub-BFS tree.
[0065] The technology described in Patent Document 1 achieves efficient processing by searching only 2-cores during BFS tree construction and omitting forest search. Since all vertices in the forest, except for roots and leaves, are articulation points, two connected vertices in the forest each form one block.
[0066] On the other hand, in the first embodiment, since only blocks on the path from the block containing the starting point to the maximum block are searched during the BFS tree construction process, the forest search can be omitted, similar to the technology described in Patent Document 1. Furthermore, since the first embodiment divides the 2-core into blocks, the search range can sometimes be made smaller than the entire 2-core. In other words, the search range required by the first embodiment is always a subset of the search range of the technology described in Patent Document 1. As a result, the BFS tree construction process can be made more efficient than the technology described in Patent Document 1 according to the first embodiment.
[0067] For example, in Figure 5, 2-core is B 1 , B 2 , B 3 That is. Also, Mori is B 4 , B 5 Here, we consider the construction of a BFS tree when vertex 1 is specified as the starting point. In the technology described in Patent Document 1, the path from the starting point to 2-core (B 4 ) and 2-core (B 1 , B 2 , B 3 ) becomes the search range. In contrast, in the first embodiment, as shown in Figure 11, B 2 , B 3 , B4 The search range is defined as follows: B1 is not included in the search range. Therefore, according to the first embodiment, the processing time of BFS can be shortened.
[0068] [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.
[0069] 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.
[0070] [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).
[0071] 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.
[0072] Figure 15 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.
[0073] 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.
[0074] 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).
[0075] 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.
[0076] 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 from the other computer by the CPU 1020 via a network interface 1070.
[0077] 10 Search device 11 Communication unit 12 Input unit 13 Output unit 14 Storage unit 141 Graph information 15 Control unit 151 Identification unit 152 Search unit 153 Connection unit
Claims
A identifying unit that identifies the joint point closest to the first block, which is included in each of the second blocks, which are blocks other than the first block, which is a set of blocks that are double-connected components included in the graph and have the most vertices, A first search unit constructs a first partial BFS tree by performing BFS from the joint points identified by the identification unit for each of the second blocks, A search device characterized by having the following features. A second search unit constructs a second sub-BFS tree by performing BFS from the specified starting point in a subgraph derived from a set of vertices contained in a third block containing a specified starting point of the graph and an ancestor block of the third block on a block-cut tree whose vertices are the plurality of blocks and whose root is the first block, A junction is provided to join the first sub-BFS tree, which is constructed with respect to blocks among the plurality of blocks that are not included in the set and that share vertices with the second sub-BFS tree, to the second sub-BFS tree. The search device according to claim 1, characterized by having the following features. A search method performed by a search device, A process of identifying the joint point closest to the first block, which is included in each of the second blocks, which are blocks other than the first block, which is a set of blocks that are double-connected components included in the graph and have the most vertices, A first search step involves constructing a first partial BFS tree by performing BFS from the joint points identified by the specific step for each of the second blocks, A search method characterized by including