Connected component calculation method, device and apparatus for long diameter dense graph
By preprocessing marking dense vertices and sparse vertices, combined with BFS and UF algorithms, the connectivity component calculation of long-diameter dense graphs is optimized, which solves the problem of high computing overhead in traditional methods, significantly improves the computing performance, and is suitable for traffic and communication networks. .
Patent Information
- Application Number
- CN202411327354.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-23
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-09-23
AI Technical Summary
The traditional method of connecting component calculation is high when facing long diameter dense graphs, which is difficult to effectively reduce, especially in traffic road networks and communication networks, which affects the computing performance.
Preprocessing marks dense vertices and sparse vertices, combined with BFS and UF algorithms, first iteratively accesses dense vertices from the vertex with the highest number of second-order neighbors, and then converts to UF algorithms to access unvisited vertices. Using the advantages of the two algorithms, optimizes the calculation process.
It significantly reduces the computing overhead of the connectivity component of the long-diameter dense graph, improves the computing performance, and is suitable for node identification and connectivity analysis of traffic road networks and communication networks.
Smart Images

Figure CN118839036B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of graph computing technology and relates to a method, device and equipment for computing connected components of a long-diameter dense graph. Background Art
[0002] A graph is an abstract data structure used to represent the relationship between objects. It is described using vertices and edges: vertices represent objects, and edges represent the relationship between objects. Data that can be abstracted into a graph is called graph data. Graph computing is the process of using a graph as a data model to express and solve problems. A subgraph is a subset of a graph, consisting of some vertices and edges in the graph. A connected component is actually a subgraph, in which each vertex can be directly or indirectly connected to other vertices in the subgraph. Therefore, for different connected components, there can be no connection relationship between them. The connected component algorithm (CC) aims to find all connected components in a graph. The diameter of a graph is defined as the maximum value of the shortest distance from any vertex in the graph to other vertices, and a dense graph refers to a subgraph in the graph with a high average degree, that is, the connections between vertices are complex. In order to calculate the connected components of a graph, there have emerged methods such as the connected component calculation method based on BFS (Breath First Search), UF (Union-Find) and its variants. However, the traditional connected component calculation method still has the technical problem of high computational overhead when calculating long-diameter dense graphs. Summary of the invention
[0003] In response to the problems existing in the above-mentioned traditional methods, the present invention proposes a method for calculating connected components for long-diameter dense graphs, a device for calculating connected components for long-diameter dense graphs, and a computer device, which can significantly reduce the computational overhead when calculating connected components for long-diameter dense graphs.
[0004] In order to achieve the above objectives, the embodiments of the present invention adopt the following technical solutions:
[0005] On the one hand, a method for calculating connected components of a long diameter dense graph is provided, comprising the steps of:
[0006] Obtaining a long-diameter dense graph to be processed; the long-diameter dense graph is a traffic road network or a communication network;
[0007] Preprocessing is performed on the long diameter dense graph to mark dense vertices and sparse vertices in the long diameter dense graph;
[0008] Starting from the identity of the vertex with the highest number of second-order neighbors, the BFS algorithm is used to iteratively visit other vertices in the long-diameter dense graph until all dense vertices have been visited;
[0009] The UF algorithm is used to visit unvisited vertices in the long-diameter dense graph;
[0010] The connected components obtained after the BFS algorithm and the UF algorithm complete the visit to the vertices in the long diameter dense graph are output as all the connected components in the long diameter dense graph; the connected components are used for node identification of the traffic network, or for connectivity and redundancy analysis of the communication network.
[0011] In one of the embodiments, in the process of marking dense vertices and sparse vertices in a long diameter dense graph, the square of the average degree of the long diameter dense graph is used as a threshold; the threshold is used to determine whether the vertices in the long diameter dense graph are dense vertices or sparse vertices.
[0012] On the other hand, a connected component calculation device for a long diameter dense graph is also provided, comprising:
[0013] A graph acquisition module, used to acquire a long-diameter dense graph to be processed; the long-diameter dense graph is a traffic network or a communication network;
[0014] A preprocessing module, used for performing preprocessing on the long diameter dense graph, marking dense vertices and sparse vertices in the long diameter dense graph;
[0015] The first access module is used to iteratively access other vertices in the long-diameter dense graph using the BFS algorithm starting from the identity of the vertex with the highest number of second-order neighbors until all dense vertices have been visited;
[0016] The second access module is used to access the unvisited vertices in the long diameter dense graph using the UF algorithm;
[0017] The component output module is used to output the connected components obtained after the BFS algorithm and the UF algorithm complete the visit to the vertices in the long diameter dense graph as all the connected components in the long diameter dense graph; the connected components are used for node identification of the traffic road network, or for connectivity and redundancy analysis of the communication network.
[0018] In one of the embodiments, the preprocessing module uses the square of the average degree of the long diameter dense graph as a threshold value in the process of marking dense vertices and sparse vertices in the long diameter dense graph; the threshold value is used to determine whether the vertices in the long diameter dense graph are dense vertices or sparse vertices.
[0019] On the other hand, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned method for calculating connected components for long-diameter dense graphs are implemented.
[0020] One of the above technical solutions has the following advantages and beneficial effects:
[0021] The above-mentioned connected component calculation method, device and equipment for long diameter dense graphs, according to the characteristics of long diameter dense graphs, first mark the dense vertices and sparse vertices in the long diameter dense graph after obtaining the long diameter dense graph to be processed, and then use the BFS algorithm to iteratively visit other vertices in the long diameter dense graph starting from the identity of the vertex with the highest number of second-order neighbors, and after obtaining the connected components of the dense vertices, use the UF algorithm to visit other unvisited vertices in the long diameter dense graph, and finally obtain all connected components in the diameter dense graph. By deeply combining the BFS algorithm and the UF algorithm at different stages of the connected component calculation process of the diameter dense graph, the advantages of the two algorithms are effectively utilized, the computational overhead when calculating the connected components for the long diameter dense graph is greatly reduced, and the calculation performance of the connected components of the long diameter dense graph is significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 A schematic diagram of a flow chart of a method for calculating connected components of a long-diameter dense graph in one embodiment;
[0024] Figure 2 The module structure block diagram of a connected component calculation device for a long diameter dense graph in one embodiment. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with the accompanying drawings and Examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art of the present invention. The terms used in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0026] It should be noted that the reference to "embodiment" in this article means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The presentation of this phrase at various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It will be appreciated by those skilled in the art that the embodiments described herein may be combined with other embodiments. The term "and / or" used in the specification of the present invention and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0027] The following will describe the implementation of the present invention in detail with reference to the accompanying drawings in the embodiment diagram of the present invention.
[0028] The connected component calculation method based on BFS is to start from a vertex that has not been visited, and traverse all vertices that can be traversed according to the BFS algorithm. At this time, the vertices that have been visited by this BFS constitute a connected component; then repeat the above process until all vertices are visited. The connected component calculation method of UF and its variants is to initialize so that all vertices set their own labels to their own IDs (identity identifiers); in the first step, all vertices traverse their own neighbor vertices and set their own labels to the smallest neighbor vertex label (or the largest, which does not affect the correctness of the algorithm, and the smallest is taken as an example here); in the second step, starting from the vertex with the smallest ID, traverse all vertices from small to large, and perform label update operations. This label update operation is a recursive operation. If the vertex corresponding to a label is not equal to the vertex's own ID, then continue to visit the vertex corresponding to the label and continue the above recursion until a vertex with a label equal to the vertex's own ID is found, and then set its own label to the current vertex label.
[0029] After in-depth research, it was found that the connected component (CC) calculation method based on BFS performs well in dense areas because the vertex labels in the BFS algorithm do not change frequently. However, when the graph diameter is long and sparse, such as in road network data, the performance of the BFS algorithm becomes worse. In theory, this is because BFS can only advance one layer per iteration. When there is a chain-like structure, the BFS algorithm needs to execute multiple rounds to end, and the computational overhead is high. The algorithm of UF and its variants is more efficient when processing sparse graphs. Even when processing chain structures, only log(N) iterations are required to complete the calculation. In dense graphs, the ID of the vertex itself will be frequently updated, resulting in higher computational overhead. Therefore, for graphs with dense areas and long-diameter sparse areas, it is difficult for the existing CC calculation method to achieve high performance, and new calculation methods continue to be designed to solve the aforementioned technical problems.
[0030] In one embodiment, Figure 1 As shown, a connected component calculation method for a long diameter dense graph is provided, which may include the following processing steps S10 to S18:
[0031] S10, obtain the long diameter dense graph to be processed; the long diameter dense graph is a traffic road network or a communication network. It can be understood that the system can obtain the long diameter dense graph that needs to be calculated and processed currently by direct collection, database pulling or user uploading, etc., but is not limited to. The long diameter dense graph to be processed can be, for example, the traffic road network and communication network of a large city or a densely populated area. These networks are relatively dense, but the traffic road network and communication network of cities with backward economic development and sparsely populated areas are relatively sparse, and the path from the latter to the former usually conforms to the characteristics of the long diameter. Therefore, these networks can be represented by a long diameter dense graph. For the sake of convenience, take the traffic road network as an example of the long diameter dense graph to be processed. The city / a certain place can be regarded as a vertex in the long diameter dense graph, and the road can be regarded as an edge in the long diameter dense graph. The edges can be divided into several categories according to the nature of the roads (country roads, highways, national roads and expressways), and the vertices can also be divided into several categories according to the nature of the vehicles. For example, a large truck may not be able to travel on a country road. Therefore, the accessibility problem between two locations of a certain vehicle can be solved by the method of the present invention and can be used to identify key vertices in the graph, randomly delete one or several vertices and their adjacent edges, and if the number of added connected components becomes more and more, it means that these vertices are more important.
[0032] Correspondingly, for the communication network, the base stations and terminal devices in the network can be regarded as vertices in the long-diameter dense graph, and the communication links between devices can be regarded as edges in the long-diameter dense graph.
[0033] S12, performing preprocessing on the long diameter dense graph, marking dense vertices and sparse vertices in the long diameter dense graph.
[0034] Specifically, the preprocessing stage is performed on the long-diameter dense graph: the number of second-order neighbors of all vertices is counted respectively (second-order neighbors are adjacent vertices of adjacent vertices). When the number of second-order neighbors of any vertex exceeds the set threshold, the vertex is marked as a dense vertex, otherwise it is marked as a sparse vertex; at the same time, the ID of the vertex with the highest number of second-order neighbors is recorded, which can be recorded as vmax; and the total number of dense vertices is recorded, which can be recorded as densenum. The threshold can usually be set based on historical experience, or it can also be set based on the average degree of the long-diameter dense graph currently being calculated and processed, as long as it can be used to accurately distinguish dense vertices from sparse vertices.
[0035] S14, starting from the identity of the vertex with the highest number of second-order neighbors, use the BFS algorithm to iteratively visit other vertices in the long-diameter dense graph until all dense vertices have been visited.
[0036] It can be understood that starting from the vertex corresponding to vmax, other vertices are iteratively accessed using the calculation method of the BFS algorithm. During each iteration, the newly accessed vertices are stored in the active array active[ ], and then the number of dense vertices stored in it is counted, and then densenum is updated (that is, the number of dense vertices in active[ ] is subtracted). When the number of dense vertices in densenum is 0, the UF algorithm is executed.
[0037] S16, using the UF algorithm to visit unvisited vertices in the long diameter dense graph;
[0038] S18, outputting the connected components obtained after the BFS algorithm and the UF algorithm complete the visit to the vertices in the long diameter dense graph as all the connected components in the long diameter dense graph; the connected components are used for node identification of the traffic road network, or for connectivity and redundancy analysis of the communication network.
[0039] Specifically, the UF algorithm is executed on the unvisited vertices in the long diameter dense graph. After the calculation is completed, all the connected components in the long diameter dense graph are obtained, and the calculation process is completed. All the connected components in the calculated long diameter dense graph can be used to identify independent traffic subsystems in the traffic network. If a part of a dense graph is divided (such as a road closure or airport suspension), the connected component analysis can quickly identify which traffic nodes are still connected and which have been separated, which helps to efficiently formulate emergency traffic scheduling or resource allocation plans and maintain the efficient operation of the traffic network.
[0040] In the communication network, all the connected components in the long-diameter dense graph can be used to evaluate the connectivity and redundancy of the communication network. By analyzing the connected components in a dense communication network, network designers / operators can quickly understand which parts will remain connected and which parts will be split if some communication nodes or paths fail, which helps optimize the communication network structure to improve its fault tolerance and reliability.
[0041] Specifically, the UF algorithm is executed on the unvisited vertices in the long diameter dense graph. After the calculation is completed, all the connected components in the long diameter dense graph are obtained, and the calculation process ends.
[0042] It can be understood that this embodiment, based on the study of the characteristics of the long diameter dense graph and the limitations of the traditional calculation method, combines the advantages of the above two calculation methods, first borrows the iterative model of the BFS algorithm, but modifies the termination condition of the algorithm. It no longer stops after visiting all accessible vertices, but stops after visiting the dense area of the long diameter dense graph, and then switches to executing the more efficient UF algorithm on the sparse graph, ultimately achieving a significant reduction in the computational overhead when calculating the connected components of the long diameter dense graph.
[0043] The above-mentioned method for calculating connected components for long diameter dense graphs, according to the characteristics of long diameter dense graphs, first marks the dense vertices and sparse vertices in the long diameter dense graph after obtaining the long diameter dense graph to be processed, and then uses the BFS algorithm to iteratively visit other vertices in the long diameter dense graph starting from the identity of the vertex with the highest number of second-order neighbors. After obtaining the connected components of the dense vertices, the UF algorithm is used to visit other unvisited vertices in the long diameter dense graph, and finally obtains all connected components in the diameter dense graph. By deeply combining the BFS algorithm and the UF algorithm at different stages of the calculation process of the connected components of the diameter dense graph, the advantages of the two algorithms are effectively utilized, the computational overhead of calculating the connected components for the long diameter dense graph is greatly reduced, and the calculation performance of the connected components of the long diameter dense graph is significantly improved.
[0044] In one embodiment, regarding the above step S12, in the process of marking the dense vertices and sparse vertices in the long diameter dense graph, the square of the average degree of the long diameter dense graph is used as the set threshold; the set threshold is used to determine whether the vertices in the long diameter dense graph are dense vertices or sparse vertices.
[0045] It can be understood that in this embodiment, the square of the average degree of the long diameter dense graph currently being calculated and processed is used as the threshold value, so that a vertex marking effect with higher accuracy corresponding to the long diameter dense graph can be achieved. The calculation of the average degree of the graph can be understood by referring to the existing average degree calculation method of the graph in the art, and will not be described in detail in this embodiment.
[0046] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of the steps, and the steps can be executed in other orders. Moreover, Figure 1At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0047] In one embodiment, Figure 2 As shown, a connected component calculation device 100 for a long diameter dense graph is also provided, comprising a graph acquisition module 11, a preprocessing module 13, a first access module 15, a second access module 17 and a component output module 19. The graph acquisition module 11 is used to acquire a long diameter dense graph to be processed; the long diameter dense graph is a traffic road network or a communication network. The preprocessing module 13 is used to perform preprocessing on the long diameter dense graph and mark the dense vertices and sparse vertices in the long diameter dense graph. The first access module 15 is used to iteratively access other vertices in the long diameter dense graph using the BFS algorithm starting from the identity of the vertex with the highest number of second-order neighbors until all dense vertices have been visited. The second access module 17 is used to access the unvisited vertices in the long diameter dense graph using the UF algorithm. The component output module 19 is used to output the connected components obtained after the BFS algorithm and the UF algorithm complete the access to the vertices in the long diameter dense graph as all the connected components in the long diameter dense graph; the connected components are used for node identification of the traffic road network, or for connectivity and redundancy analysis of the communication network.
[0048] The above-mentioned connected component calculation device 100 for long diameter dense graph, according to the characteristics of long diameter dense graph, first marks the dense vertices and sparse vertices in the long diameter dense graph after obtaining the long diameter dense graph to be processed, and then uses the BFS algorithm to iteratively access other vertices in the long diameter dense graph starting from the identity of the vertex with the highest number of second-order neighbors, and after obtaining the connected components of the dense vertices, uses the UF algorithm to access other unvisited vertices in the long diameter dense graph, and finally obtains all connected components in the diameter dense graph. By deeply combining the BFS algorithm and the UF algorithm at different stages of the connected component calculation process of the diameter dense graph, the advantages of the two algorithms are effectively utilized, the computational overhead when calculating the connected components for the long diameter dense graph is greatly reduced, and the calculation performance of the connected components of the long diameter dense graph is significantly improved.
[0049] In one embodiment, the preprocessing module 13 uses the square of the average degree of the long diameter dense graph as a threshold value when marking dense vertices and sparse vertices in the long diameter dense graph; the threshold value is used to determine whether the vertices in the long diameter dense graph are dense vertices or sparse vertices.
[0050] For the specific limitations of the connected component calculation device 100 for long diameter dense graphs, please refer to the limitations of the connected component calculation method for long diameter dense graphs above, which will not be repeated here. Each module in the above-mentioned connected component calculation device 100 for long diameter dense graphs can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0051] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the following processing steps when executing the computer program: obtaining a long diameter dense graph to be processed; the long diameter dense graph is a transportation road network or a communication network; performing preprocessing on the long diameter dense graph, marking dense vertices and sparse vertices in the long diameter dense graph; starting from the identity of the vertex with the highest number of second-order neighbors, using the BFS algorithm to iteratively visit other vertices in the long diameter dense graph until all dense vertices have been visited; using the UF algorithm to visit the unvisited vertices in the long diameter dense graph; outputting the connected components obtained after the BFS algorithm and the UF algorithm complete the visit to the vertices in the long diameter dense graph as all the connected components in the long diameter dense graph; the connected components are used for node identification of the transportation road network, or for connectivity and redundancy analysis of the communication network.
[0052] It can be understood that the above-mentioned computer device, in addition to the memory and processor mentioned above, may also include other software and hardware components not listed in this specification. The specific details can be determined according to the model of the specific graphics computing device in different application scenarios, and this specification will not list them one by one in detail.
[0053] In one embodiment, when the processor executes the computer program, it can also implement the steps or sub-steps added in each embodiment of the above-mentioned method for calculating connected components for long-diameter dense graphs.
[0054] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following processing steps are implemented: obtaining a long diameter dense graph to be processed; the long diameter dense graph is a transportation road network or a communication network; performing preprocessing on the long diameter dense graph, marking dense vertices and sparse vertices in the long diameter dense graph; starting from the identity of the vertex with the highest number of second-order neighbors, using the BFS algorithm to iteratively visit other vertices in the long diameter dense graph until all dense vertices have been visited; using the UF algorithm to visit the unvisited vertices in the long diameter dense graph; outputting the connected components obtained after the BFS algorithm and the UF algorithm complete the visit to the vertices in the long diameter dense graph as all the connected components in the long diameter dense graph; the connected components are used for node identification of the transportation road network, or for connectivity and redundancy analysis of the communication network.
[0055] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus dynamic random access memory (RambusDRAM, referred to as RDRAM) and interface dynamic random access memory (DRDRAM).
[0056] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0057] The above embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of protection of the invention. It should be pointed out that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the attached claims.
Claims
1. A method for calculating connected components of a long-diameter dense graph, characterized in that: Includes steps: Acquire a long-diameter dense graph to be processed; the long-diameter dense graph is a traffic road network or a communication network; Preprocessing is performed on the long diameter dense graph to mark dense vertices and sparse vertices in the long diameter dense graph; the preprocessing includes counting the number of second-order neighbors of all vertices respectively, marking any vertex as a dense vertex when the number of second-order neighbors of any vertex exceeds a set threshold, otherwise marking it as a sparse vertex, and at the same time, recording the identity of the vertex with the highest number of second-order neighbors and recording the total number of dense vertices; Starting from the identity of the vertex with the highest number of second-order neighbors, the BFS algorithm is used to iteratively access other vertices in the long-diameter dense graph until all dense vertices have been visited; wherein, starting from the vertex with the highest number of second-order neighbors, other vertices are iteratively accessed in the calculation method of the BFS algorithm, and in each round of iteration, the newly accessed vertex is stored in the active array, and then the number of dense vertices stored in the active array is counted, and then the total number of dense vertices is subtracted from the number of dense vertices in the active array to update the total number of dense vertices, and when the number of dense vertices in the total number of dense vertices is 0, the UF algorithm is executed; Using the UF algorithm to visit unvisited vertices in the long diameter dense graph; The connected components obtained after the BFS algorithm and the UF algorithm complete the visit to the vertices in the long diameter dense graph are output as all the connected components in the long diameter dense graph; the connected components are used for node identification of the transportation network, or for connectivity and redundancy analysis of the communication network.
2. The method for calculating connected components of a long diameter dense graph according to claim 1, characterized in that: In the process of marking the dense vertices and the sparse vertices in the long diameter dense graph, the square of the average degree of the long diameter dense graph is used as a threshold; The set threshold is used to determine whether the vertices in the long diameter dense graph are dense vertices or sparse vertices.
3. A connected component calculation device for a long diameter dense graph, characterized in that: include: A graph acquisition module, used to acquire a long-diameter dense graph to be processed; the long-diameter dense graph is a traffic network or a communication network; A preprocessing module is used to perform preprocessing on the long diameter dense graph and mark the dense vertices and sparse vertices in the long diameter dense graph; the preprocessing includes counting the number of second-order neighbors of all vertices respectively, and when the number of second-order neighbors of any vertex exceeds a set threshold, marking the any vertex as a dense vertex, otherwise marking it as a sparse vertex, and at the same time, recording the identity of the vertex with the highest number of second-order neighbors and recording the total number of dense vertices; A first access module is used to iteratively access other vertices in the long-diameter dense graph starting from the identity identifier of the vertex with the highest number of second-order neighbors using the BFS algorithm until all dense vertices have been visited; wherein, starting from the vertex with the highest number of second-order neighbors, other vertices are iteratively accessed in a calculation manner of the BFS algorithm, and in each round of iteration, the newly accessed vertex is stored in an active array, and then the number of dense vertices stored in the active array is counted, and then the total number of dense vertices is subtracted from the number of dense vertices in the active array to update the total number of dense vertices, and when the number of dense vertices in the total number of dense vertices is 0, the UF algorithm is executed; A second access module is used to access unvisited vertices in the long diameter dense graph using a UF algorithm; A component output module is used to output the connected components obtained after the BFS algorithm and the UF algorithm complete the visit to the vertices in the long diameter dense graph as all the connected components in the long diameter dense graph; the connected components are used for node identification of the transportation network, or for connectivity and redundancy analysis of the communication network.
4. The connected component calculation device for a long diameter dense graph according to claim 3, characterized in that: The preprocessing module uses the square of the average degree of the long diameter dense graph as a set threshold in the process of marking the dense vertices and the sparse vertices in the long diameter dense graph; The set threshold is used to determine whether the vertices in the long diameter dense graph are dense vertices or sparse vertices.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method for calculating connected components for long-diameter dense graphs according to claim 1 or 2 are implemented.
