Partition calculation method for reachable matrix of undirected graph
By partitioning large network graphs and independently computing the reachable matrix of subgraphs, combined with the boundary equivalent data update mechanism, the problem of insufficient computing speed of large network graphs is solved, and the ability to efficient topological analysis and fast response is achieved.
Patent Information
- Application Number
- CN202411722095.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-21
AI Technical Summary
When the prior art processes large network graphs with a number of vertices exceeding 3,000, the calculation speed is insufficient, making it difficult to meet the needs of efficient topological analysis.
The undirected graph is divided into multiple subgraphs through partitioning algorithms, and the reachable matrix of each subgraph is independently calculated to reduce the complexity and resource requirements of global computing. At the same time, a boundary equivalent data update mechanism is introduced to achieve rapid adjustment of local matrices and avoid global recalculation.
It significantly improves the computing efficiency of large-scale network topology analysis, reduces the computing resource requirements, and improves the system's response speed in dynamic environments. It is especially suitable for areas such as power grid operation analysis and dynamic traffic scheduling.
Smart Images

Figure CN119670856A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data mining, and in particular to a partition calculation method for an undirected graph reachable matrix. Background Art
[0002] In the context of the rapid development of artificial intelligence, it is necessary to significantly improve the analysis and calculation speed of the reachability matrix of large networks. The existing technology has proposed a vertex set-based undirected graph reachability matrix calculation method based on the binary relation transitive closure Warshall algorithm. This method is fast and can meet the business needs in most cases. However, when encountering a large network graph with more than 3,000 vertices, its calculation speed is still insufficient, and it is necessary to further improve the topological analysis speed of large networks.
[0003] The speed of topological analysis depends largely on the dimension of the adjacency matrix, that is, the larger the number of vertices in the graph, the higher the dimension of the adjacency matrix, and the slower the calculation speed. If the graph is partitioned and analyzed for each subgraph, the speed of topological analysis can be greatly improved. Considering that the graphs used in practical engineering are mostly undirected graphs, and their adjacency matrices are sparse matrices. For this reason, the present invention adopts a partitioning method to further improve the calculation speed of the reachable matrix of the graph. The theoretical basis of the partition calculation method of the reachable matrix is an undirected graph reachable matrix algorithm based on a vertex set, particularly a boundary equivalence method therein.
[0004] The above information disclosed in this Background section is only for enhancement of understanding of the background of the present disclosure and therefore it may contain information that does not constitute the prior art that is already known to one of ordinary skill in the art. Summary of the invention
[0005] The purpose of the present invention is to provide a partition calculation method for the reachable matrix of an undirected graph, which divides the undirected graph into multiple subgraphs through a partition algorithm, and independently calculates the reachable matrix of each subgraph, thereby reducing the complexity and resource requirements of global calculations and improving calculation efficiency. In addition, by utilizing a multi-core and distributed computing environment, it is possible to efficiently handle scenarios with high real-time requirements such as power grid operation analysis and dynamic traffic scheduling. In response to dynamic changes in the network, the present invention introduces a boundary equivalent data update mechanism to achieve rapid adjustment of local matrices without the need for global recalculation, significantly improving the response speed of the system in scenarios with frequent topological changes, and is suitable for fields such as power grid operation analysis and dynamic traffic scheduling, effectively ensuring the efficient operation and real-time response capabilities of the system to solve the problems in the above-mentioned background technology.
[0006] In order to achieve the above object, the present invention provides the following technical solution: a partition calculation method for an undirected graph reachability matrix, the specific steps are as follows:
[0007] Partition the graph G into m partitions, where the kth partition is the subgraph G.k , using the partitioning algorithm to calculate the graph G k On the graph G, the reachable matrix P k , the calculation steps are as follows:
[0008] Step 1 Generate the adjacency matrix A of graph G, where the element a is in row i and column j. ij The definition is as follows:
[0009]
[0010] Step 2: prepare basic data A[n,n+2] and B[n,n+2], where matrix B is used to store partition equivalent data.
[0011] Step 3: Calculate equivalent data for each partition in the B[n,n+2] matrix;
[0012] Step 4: Complement the graph G in the A[n,n+2] matrix kb Calculation of boundary equivalent matrix;
[0013] Step 5: In the A matrix, use the reachable vertex set algorithm to calculate the graph G k The reachability matrix P on the graph G k .
[0014] Preferably, the specific implementation steps of step 2 are:
[0015] Step 2-1 expands the columns of the adjacency matrix A to form an A[n,n+2] matrix, where the n+1 column is used to mark the data validity and the n+2 column is used to mark the partition area code.
[0016] Preferably, in step 2-2, two matrices A[n,n+2] and B[n,n+2] are prepared, wherein matrix A is an extended adjacency matrix and matrix B is a partitioned equivalent data matrix.
[0017] Preferably, in step 3, an equivalent vertex set is calculated for each partition in the B[n,n+2] matrix, and the method for calculating the equivalent vertex set is:
[0018] Step 3-1: Set the initial value s=1;
[0019] Step 3-2 uses the reachable vertex set algorithm to calculate the reachable vertex set of partition s in the B matrix, that is, for b (i,n+2) =s to calculate the reachable vertex set;
[0020] Step 3-3, add 1 to the loop variable s, if s≤m, go to step 3-2; otherwise, end.
[0021] Preferably, in step 4, the graph G is complemented in the matrix A[n,n+2] kbThe boundary equivalent matrix calculation of is as follows:
[0022] Step 4-1: Remove the items in A[n,n+2] that do not belong to G k The n+1 column of the row corresponding to the vertex of is set to 0, that is, the following operations are performed: (i,n+1) =0|a (i,n+2) ≠k};
[0023] Step 4-2: For the matrix B[n,n+2] that does not belong to G k The row corresponding to the vertex of b (i,n+1) =1, copy the row to the row corresponding to A[n,n+2], that is, perform the following operations:
[0024]
[0025] Step 4-3: In the matrix A[n,n+2], use the reachable vertex set algorithm to calculate the graph G k The reachable vertex set of the complement graph, that is, for a (i,n+2) The rows with ≠k are used to calculate the reachable vertex set.
[0026] Preferably, in step 5, the adjacency expansion matrix A after boundary equivalence is calculated using the reachable vertex set algorithm. k The reachability matrix P on the graph G k .
[0027] Preferably, the computational effort of topological analysis is reduced by making the boundary topology of the partitioned subgraphs equivalent. k The adjacency matrix A k When changes occur, if G k The complement of G kb No change, skip steps 2 to 4, and directly use step 5 to calculate subgraph G k The reachability matrix on G.
[0028] Preferably, the partitions and complements of the graph are defined as follows:
[0029] Definition 1: Let graph G = <V, E> be an n-order undirected graph. The m partition subgraphs Gs of graph G <V, E> should satisfy the following properties:
[0030] Gs=<Vs,Es>, S=1,2...m, Vs is not empty;
[0031] V1∪V2∪…V m =V;
[0032]
[0033] Definition 2: The connected subgraph Gr between different partitions of graph G satisfies the following properties:
[0034] Gr=<Vr,Er>, Vr is not empty;
[0035] and
[0036] And E1∪E2∪…E m ∪Er=E.
[0037] In the above technical solution, the technical effects and advantages provided by the present invention are:
[0038] The present invention divides the original undirected graph into multiple subgraphs through a partitioning algorithm, and each subgraph represents a relatively independent small-scale computing unit. The reachable matrix calculation of each subgraph is completed independently, thereby decomposing the originally large and complex global computing task into multiple small-scale, low-complexity parallel tasks. In this way, the demand for computing resources is significantly reduced, which not only reduces the time consumption of a single calculation, but also makes full use of multi-core computing and distributed computing environments, and realizes efficient topological analysis of large-scale networks, which is particularly suitable for scenarios with high real-time requirements such as power grid operation analysis and large-scale transportation network simulation.
[0039] The present invention realizes rapid adjustment of local areas by dynamically updating the partition and boundary equivalent data. Specifically, when a subgraph undergoes a topological change, only the matrix of the related subgraph data needs to be updated, and the calculation results of other subgraphs can be directly reused using an equivalent method. This local update mechanism significantly improves the response speed of the system in a dynamic environment and reduces the time and resources required for global recalculation, especially in scenarios with a large number of nodes and frequent topological changes. When applied to fields such as power network topology analysis and dynamic traffic scheduling, it can effectively cope with frequent changes in network topology and ensure the efficient operation and real-time response capabilities of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0041] Figure 1 The electrical network diagram G and the partition diagram G corresponding to the embodiment of the present invention are k .
[0042] Figure 2 It is an extended adjacency matrix corresponding to the embodiment of the present invention.
[0043] Figure 3is the equivalent matrix of each partition corresponding to the embodiment of the present invention.
[0044] Figure 4 is the boundary equivalent adjacency matrix of the first partition on G in the embodiment of the present invention.
[0045] Figure 5 It is the reachable vertex set of the first partition on the graph G in the embodiment of the present invention.
[0046] Figure 6 is the reachable matrix of the first partition on the graph G in the embodiment of the present invention. DETAILED DESCRIPTION
[0047] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these example embodiments are provided so that the description of the present disclosure will be more comprehensive and complete, and the concept of the example embodiments will be fully conveyed to those skilled in the art.
[0048] The present invention provides a partition calculation method for an undirected graph reachable matrix, and the specific steps are as follows:
[0049] Partition graph G into k partitions, where the kth partition is subgraph G k . Use the partitioning algorithm to calculate the graph G k On the graph G, the reachable matrix P k , the calculation steps are as follows:
[0050] Step 1: Generate the adjacency matrix A of graph G, where the element a is in row i and column j. ij The definition is as follows:
[0051]
[0052] Step 2: Prepare basic data A[n,n+2] and B[n,n+2], where matrix B is used to store partition equivalent data.
[0053] Step 2-1 expands the adjacency matrix A of graph G by 2 columns to obtain the extended adjacency matrix A[n,n+2].
[0054] in,
[0055] a i(n+1) =1
[0056] a i(n+2) =s|s=1,2,…m
[0057] s is the partition number;
[0058] Step 2-2 Copy A[n,n+2] to B[n,n+2];
[0059] Step 3: Calculate equivalent data for each partition in the B[n,n+2] matrix. The steps are as follows:
[0060] Step 3-1: Set the initial value s=1;
[0061] Step 3-2 uses the reachable vertex set algorithm to calculate the reachable vertex set of partition s in the B matrix, that is, for b (i,n+2) =s to calculate the reachable vertex set;
[0062] Step 3-3 adds 1 to the loop variable s. If s≤m, go to step 3-2; otherwise, end.
[0063] Step 4: Complement the graph G in the A[n,n+2] matrix kb Boundary equivalent matrix calculation of .
[0064] Step 4-1. Remove the items in A[n,n+2] that do not belong to G. k The n+1 column of the row corresponding to the vertex of is set to 0, that is, the following operations are performed: (i,n+1) =0|a (i,n+2) ≠k};
[0065] Step 4-2 For the matrix B[n,n+2] that does not belong to G k The row corresponding to the vertex of b (i,n+1) =1, copy the row to the row corresponding to A[n,n+2] (overwriting the original row). That is, perform the following operations:
[0066]
[0067] Step 4-3: In the matrix A[n,n+2], use the reachable vertex set algorithm to calculate the graph G k The reachable vertex set of the complement graph, that is, for a (i,n+2) The rows with ≠k are used to calculate the reachable vertex set.
[0068] Step 5: In the A matrix, use the reachable vertex set algorithm to calculate the graph G k The reachability matrix P on the graph G k .
[0069] So far, G k ∈G’s reachability matrix P k When the subgraph G k The adjacency matrix A k When changes occur, as long as G k The complement of G kb If it does not change, we can skip steps 2 to 4 and directly use step 5 to calculate the subgraph G. kThe reachability matrix on G. If you need to calculate the reachability matrix of another partition, just treat the other partition as G k .
[0070] In step 2, step 3, and step 4, the partitioning and patching conform to the following definitions:
[0071] Definition 1: Let graph G = <V, E> be an n-order undirected graph. The m partition subgraphs Gs of graph G <V, E> should satisfy the following properties:
[0072] Gs=<Vs,Es>,S=1,2...m, Vs is not empty,
[0073] V1∪V2∪…V m =V,
[0074]
[0075] Definition 2: The connected subgraph Gr between different partitions of graph G satisfies the following properties:
[0076] Gr=<Vr,Er>, Vr is not empty;
[0077] and
[0078] and
[0079] According to the above definition, for the partition graph G k ∈{G s |s=1,2,…m}, its complement is
[0080]
[0081] Example: Figure 1 As shown in FIG. 1 , it is an electrical network diagram used in the embodiment, in which switches S1-3, S1-5, S1-7, S1-8, S2-5, S2-7, S2-8, S3-5, S3-6, S3-9, and S3-10 are in the open state, and the remaining switches are in the closed state; Figure 2 As shown in FIG. 1 , it is an extended adjacency matrix of the electrical network diagram of Example 1, with a total of 24 rows and 26 columns. The elements in the 25th column are all 1, and the elements in the 26th column are the partition numbers of the vertices corresponding to the row. Figure 3 As shown in , it is the equivalent matrix of each partition, where the row with the element 1 in the 25th column is the equivalent vertex set of the partition. The equivalent matrix of each partition is obtained by using the vertex set method. Figure 4As shown in , it is the boundary equivalent adjacency matrix of the first partition on G. Among them, the rows corresponding to partition 1 are the same as the extended adjacency matrix, and the rows corresponding to partitions 2 and 3 are the same as the equivalent matrices of each partition. Figure 5 As shown in the figure, it is the reachable vertex set of the first partition on the graph G. The reachable vertex set is Figure 4 Based on , the vertex set method is used to transform , where the row where the element with 1 in the 25th column is located is the reachable vertex set of the first partition on the graph G. Figure 6 As shown, this is the reachable matrix of the first partition on the graph G, which corresponds to the reachable vertex set.
[0082] The present invention greatly optimizes the computational complexity by partitioning undirected graphs, providing an efficient solution for large network topology analysis. In traditional methods, especially matrix multiplication of reachable matrices, the computational complexity is usually O(n 3 ), the consumption of computing resources grows exponentially with the increase in the number of nodes, leading to performance bottlenecks. The present invention divides the original undirected graph into multiple subgraphs through a partitioning algorithm, and each subgraph represents a relatively independent small-scale computing unit. The reachable matrix calculation of each subgraph is completed independently, thereby decomposing the originally large and complex global computing task into multiple small-scale, low-complexity parallel tasks. In this way, the demand for computing resources is significantly reduced, which not only reduces the time consumption of a single calculation, but also makes full use of multi-core computing and distributed computing environments to achieve efficient topological analysis of large-scale networks. This method is particularly suitable for scenarios with high real-time requirements such as power grid topology analysis and large-scale transportation network simulation.
[0083] In response to the topological analysis needs of dynamically changing networks, the present invention introduces a boundary equivalent matrix calculation mechanism in the partition calculation process. When the network structure changes, such as adding or deleting nodes and edges, traditional algorithms usually need to recalculate the reachable matrix of the entire graph, which is time-consuming and inefficient in practical applications. The present invention achieves rapid adjustment of local areas by dynamically updating the partition and boundary equivalent data. Specifically, when a subgraph undergoes a topological change, only the matrix of the related subgraph needs to be updated, and the calculation results of other subgraphs can be directly equivalent and reused. This local update mechanism significantly improves the response speed of the system in a dynamic environment, reduces the time and resource waste required for global recalculation, and performs particularly well in scenarios with a large number of nodes and frequent topological changes. When applied to fields such as power grid topology analysis and dynamic traffic scheduling, it can effectively cope with frequent network topology changes and ensure the efficient operation and real-time response capabilities of the system.
[0084] The above embodiments are examples of implementation methods of the present invention, but the implementation methods of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, simplifications that do not deviate from the spirit and principles of the present invention, including matrix vectorization, column notation, etc., should be regarded as equivalent replacement methods of the present invention and are included in the protection scope of the present invention.
[0085] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0086] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0087] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0088] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0089] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks or optical disks.
[0090] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A partition calculation method for an undirected graph reachability matrix, characterized in that: The specific steps are as follows: Partition the graph G into m partitions, where the kth partition is the subgraph G. k , using the partitioning algorithm to calculate the graph G k On the graph G, the reachable matrix P k , the calculation steps are as follows: Step 1: Generate the adjacency matrix A of graph G, where the element a is in row i and column j. ij The definition is as follows: Step 2: Prepare basic data A[n,n+2] and B[n,n+2], where matrix B is used to store partition equivalent data. Step 3, calculate equivalent data for each partition in the B[n,n+2] matrix; Step 4: Complement the graph G in the A[n,n+2] matrix kb Calculation of boundary equivalent matrix; Step 5: In the A matrix, use the reachable vertex set algorithm to calculate the graph G k The reachability matrix P on the graph G k .
2. The partition calculation method of an undirected graph reachable matrix according to claim 1, characterized in that: The specific implementation steps of step 2 are: Step 2-1 expands the columns of the adjacency matrix A to form an A[n,n+2] matrix, where the n+1 column is used to mark the data validity and the n+2 column is used to mark the partition code.
3. The partition calculation method of an undirected graph reachable matrix according to claim 3 is characterized in that: Step 2-2, prepare two matrices A[n,n+2] and B[n,n+2], where matrix A is an extended adjacency matrix and matrix B is a partitioned equivalent data matrix.
4. The partition calculation method of an undirected graph reachable matrix according to claim 1, characterized in that: In step 3, the equivalent vertex set is calculated for each partition in the B[n,n+2] matrix. The method for calculating the equivalent vertex set is: Step 3-1: Set the initial value s=1; Step 3-2 uses the reachable vertex set algorithm to calculate the reachable vertex set of partition s in the B matrix, that is, for b (i,n+2) =s rows to calculate the reachable vertex set; Step 3-3 adds 1 to the loop variable s. If s≤m, go to step 3-2; otherwise, end.
5. The partition calculation method of an undirected graph reachable matrix according to claim 1 is characterized in that: In step 4, fill in the A[n,n+2] matrix G kb The boundary equivalent matrix calculation of is as follows: Step 4-1. Remove the items in A[n,n+2] that do not belong to G. k The n+1 column of the row corresponding to the vertex of is set to 0, that is, the following operations are performed: (i,n+1) =0|a (i,n+2) ≠k}; Step 4-2 For the matrix B[n,n+2] that does not belong to G k The row corresponding to the vertex of b (i,n+1) =1, copy the row to the row corresponding to A[n,n+2], that is, perform the following operations: Step 4-3: In the matrix A[n,n+2], use the reachable vertex set algorithm to calculate the graph G k The reachable vertex set of the complement graph, that is, for a (i,n+2) The rows with ≠k are used to calculate the reachable vertex set.
6. The partition calculation method of an undirected graph reachable matrix according to claim 1, characterized in that: In step 5, the adjacency expansion matrix A after boundary equivalence is calculated using the reachable vertex set algorithm. k The reachability matrix P on the graph G k .
7. The partition calculation method of an undirected graph reachable matrix according to claim 1 is characterized in that: By making the boundary topology of the partitioned subgraphs equivalent, the computational effort of topological analysis is reduced. k The adjacency matrix A k When changes occur, if G k The complement of G kb No change, skip steps 2 to 4, and directly use step 5 to calculate subgraph G k The reachability matrix on G.
8. The partition calculation method of an undirected graph reachable matrix according to claim 1 is characterized in that: The partition and complement of the graph are defined as follows: Definition 1: Let graph G = <V, E> be an n-order undirected graph. The m partition subgraphs Gs of graph G <V, E> should satisfy the following properties: Gs=<Vs,Es>, S=1,2...m, Vs is not empty; V1∪V2∪…V m =V; Definition 2: The connected subgraph Gr between different partitions of graph G satisfies the following properties: Gr=<Vr,Er>, Vr is not empty; and and
Citation Information
Cited By
Power industry cross-domain computing power dynamic scheduling system based on super intelligent fusion
CN121560530A