1. Introduction
Given a weighted undirected connected graph, the minimum spanning tree (MST) problem involves finding a subgraph spanning all vertices in the graph without ring structures and with the minimized sum of edge weights. This problem was first introduced by Brouvka in 1926. Nesetril and Nesetrilova [
1] have provided a detailed overview of the origin and development of the MST problem. MST has widespread applications in real-life scenarios, including transportation problems, communication network design, and many other combinatorial optimization problems. For example, MST is commonly employed in clustering (see [
2,
3,
4]). It is a common method to study relationships in financial markets by constructing an MST from correlation matrices (see [
5,
6,
7]). MST is also used for analyzing brain networks (see [
8,
9,
10]). The MST problem is also common in various production and life applications, such as power grid configuration [
11], dynamic power distribution reconfiguration [
12], optimal configuration problem [
13], etc.
Real-world problems requiring solutions to the MST problem often involve graphs of immense scale and dynamic changes. Although polynomial-time algorithms exist for the MST problem, the real-time computation for large-scale graphs remains challenging. Moreover, real-world scenarios typically involve modifications to only a small portion of the original graph. Recalculating the entire graph using MST algorithms for the new graph results in significant redundant computations. This underscores the need for effective maintenance of the MST in dynamic graphs. Solutions designed for static problems are generally inadequate to meet the requirements of dynamic graphs [
14]. In the context of the Internet of Things (IoT) domain, Wireless Ad Hoc Networks are commonly used and often employ a minimum dominating tree (MDT) structure as the backbone for network traffic management [
15]. MDT is a spanning tree that encompasses a specific dominating set within the network. Given the dynamic nature of Ad Hoc Networks, they frequently change over time, necessitating corresponding adjustments in their backbone structure. To ensure efficient maintenance of the backbone, an effective solution to the dynamic minimum spanning tree (MST) problem is necessary. Moreover, the algorithm for dynamic MST can also be employed as a sub-procedure in the MDT algorithm to enhance convergence [
16].
This paper studies the problem of updating the original MST of a graph when its structure changes. Given a weighted undirected graph and its MST, the problem queries a new MST based on the original one if the graph changes its structure, i.e., if edges and vertices are added or removed.
Existing algorithms for maintaining the minimum spanning tree in dynamic graphs are usually designed for various scenarios. Frederickson et al. [
17] proposed a top-tree-based algorithm, which is specifically designed for graphs where the maximum degree of vertices is three. Amato et al. [
18] conducted the first experimental study on dynamic minimum spanning tree algorithms. They implemented different versions of Frederickson’s algorithm using partitioning and top-trees. Additionally, to achieve the fastest random input, Henzinger and King [
19] introduced a fully dynamic minimum spanning tree algorithm. Holm et al. [
20] improved the algorithm proposed by Henzinger and King. They were the first to introduce a fully dynamic minimum spanning tree algorithm with logarithmic-time complexity. Cattaneo et al. [
21] further optimized several algorithms for this problem. Eppstein et al. [
22] introduced sparsification techniques on top of Frederickson’s algorithm, reducing the time complexity to
. Based on Eppstein’s work, Kopelowitz et al. [
23] proposed the algorithm with the best-known results, achieving a time complexity of
per update for each vertex, but only allowing single-edge updates. Tarjan and Wereck [
24] conducted experiments on two variants of dynamic tree data structures (self-adjusting and worst-case) and compared their advantages and disadvantages. Chen et al. [
25] proposed the LDP-MST algorithm, which calculates density based on the results of the natural neighbor search algorithm, identifies local density peaks, and then constructs the minimum spanning tree. Junior et al. [
26] proposed an algorithm for solving the variant of the fully dynamic minimum spanning tree problem, addressing the incremental minimum spanning tree problem through complete backtracking. Anderson et al. [
22] proposed a parallel batch-processing dynamic algorithm for incremental minimum spanning trees. They introduced a parallel data structure for batch-processing incremental MSF problems, achieving polynomial time for each edge insertion, which is more efficient than the fastest sequential single-update data structure for sufficiently large batches. Tseng et al. [
27] implemented parallelization based on Holm et al.’s work and proposed a parallel batch algorithm to maintain MSF.
After reviewing the current state of research, it is apparent that the majority of the existing studies have predominantly concentrated on scenarios involving single changes. In this paper, our objective is to explore a specific scenario where a portion of the graph undergoes alteration. Furthermore, we propose a method that is well suited for preserving MST in situations where the graph undergoes iterative structural modifications, with only a small segment of the graph being altered in each iteration.
The following of the paper is organized as follows:
Section 2 describes the problem studied by this paper in detail;
Section 3 introduces the proposed MST maintenance algorithm;
Section 4 includes theoretical proofs and an analysis of the time complexity of the proposed algorithm;
Section 5 presents the experiments conducted and evaluates the proposed algorithm; finally,
Section 6 concludes the paper and outlines prospects for future work.
2. Problem Description
Given a weighted undirected graph , where V is the set of vertices and E is the set of edges, and its minimum spanning tree, this paper investigates a rapid updating and generation algorithm for the new minimum spanning tree when partial structural changes occur in graph G. If the updated graph becomes a non-connected graph, the algorithm should provide a minimum spanning forest. This section describes two specific scenarios of graph changes and generalizes the common variations in the graph accordingly.
2.1. Minimum Spanning Tree of the Subgraph in the Original Graph
If the changes to the graph only involve the removal from the original graph, the updated graph is a subgraph of the original. The problem then becomes finding the minimum spanning tree of a subgraph of the original graph. This is defined as follows: Given a weighted undirected graph and its spanning tree T, the task is to find the minimum spanning tree of graph , where .
The MST of a subgraph may differ from or be identical to the MST of the original graph.
Figure 1 illustrates an example of the subgraph MST problem. Given the original graph shown in
Figure 1a, where solid lines represent edges in the MST (following schematic figures), a subgraph is formed by removing edge
, as depicted in
Figure 1b. It can be observed that the MST of this subgraph is different from that of the original graph. If the removed edge is not part of the original MST, the MST of the subgraph is identical to the original MST, as shown in
Figure 1c.
Removing a vertex from the original graph can be reduced to removing multiple edges. The new minimum spanning tree obtained after removing a vertex from the original graph has the same weight as the minimum spanning forest obtained by removing all edges connected to this vertex, after which this vertex becomes an isolated vertex, and its presence or absence does not affect the weight of the minimum spanning tree. For example, in the original graph shown in
Figure 2a, after deleting vertex
B, the subgraph and its minimum spanning tree are shown in
Figure 2b. After deleting all edges connected to vertex
B, the subgraph and its minimum spanning forest are shown in
Figure 2c. Deleting a vertex from the original graph changes the minimum spanning tree.
2.2. Minimum Spanning Tree of the Supergraph in the Original Graph
If the modifications to the graph only involve additions to the original graph, then the updated graph becomes a supergraph of the original. The problem becomes finding the minimum spanning tree (MST) of a certain supergraph of the original graph. The definition is as follows: Given a weighted undirected graph and its spanning tree T, the objective is to find the minimum spanning tree of graph , where .
Figure 3 illustrates an example of the supergraph minimum spanning tree problem. Given the original graph and its spanning tree shown in
Figure 3a, the supergraph with the added edge
and its minimum spanning tree are depicted in
Figure 3b. It can be observed that in this example, the spanning tree of the supergraph differs from that of the original graph. Through analysis, it can be deduced that when the weight of the added edge is less than the weight of a certain edge forming a cycle in the original MST, the new MST changes. For example, in this instance, adding
creates a cycle in the original MST:
—
—
; the weight of
is less than the weight of
in the cycle. If the weight of the added edge is greater than the weights of all other edges in the cycle, then the MST of the supergraph remains the same as that of the original graph, as shown in
Figure 3c.
From the original graph, the addition of a vertex can be reduced to adding multiple edges. Consider the vertex to be added firstly as an isolated vertex in the original graph, and then add the edges associated with it to the original graph. For example, considering the original graph and its spanning tree shown in
Figure 4 (left), after adding vertex
Q along with edges
and
, the resulting supergraph and its minimum spanning tree are illustrated in
Figure 4 (right). Adding a non-isolated vertex to the original graph inevitably alters the minimum spanning tree.
2.3. Minimum Spanning Tree after Modifications to Original Graph
When the modified graph is not a subgraph or supergraph of the original graph, the transformation can be broken down into two distinct sub-processes: removing edges and adding new edges. This leads to the transformation of the original problem into two processes, solving a subgraph minimum spanning tree and a supergraph minimum spanning tree.
Let the original graph be denoted by and the changed graph by . First, we determine the set of edges removed in compared with G as and the set of edges added in compared with G as . Subsequently, we calculate the minimum spanning tree of subgraph . Then, we calculate the minimum spanning tree of supergraph , where is equivalent to .
For example, as depicted in
Figure 5a, the original graph transforms into the new graph shown in
Figure 5c (by deleting
and adding
). To find the minimum spanning tree of the resulting graph, one can first determine the minimum spanning tree of the subgraph (by deleting
), as shown in
Figure 5b, and then compute the minimum spanning tree of the supergraph (by adding
), which is equivalent to the graph in
Figure 5c.
3. Fast Updating and Maintenance Algorithm for Minimum Spanning Trees
This section describes an algorithm for efficiently updating and maintaining the minimum spanning tree in a dynamic graph. To facilitate the subsequent algorithm descriptions, we first define the following symbols:
: ordered set of edges in graph E, where the edges are sorted in ascending order of weight.
: set of edges added in the new graph compared with the original graph.
: set of edges removed in the new graph compared with the original graph.
D: array representing the disjoint-set data structure. If , it signifies that vertex i is a non-representative vertex, and denotes the representative vertex number of the connected component containing vertex i. If , it indicates that vertex i is the representative vertex of its connected component, and the absolute value of is the number of vertices in the current connected component. This data structure is globally visible throughout the algorithm.
V: visitation array used as an auxiliary data structure for reconstructing the disjoint set during sub-processes. indicates that vertex i has been visited; otherwise, . This data structure is globally visible throughout the algorithm.
T: set of edges for the current spanning tree.
: set of edges for the updated spanning tree.
3.1. Framework of the Algorithm
The overall framework of the algorithm is described in Algorithm 1. The input to the algorithm consists of the given graph G, the ordered edge set of G, the minimum spanning tree T of G, the set of edges to be added , and the set of edges to be removed . The algorithm first calculates the minimum spanning tree of the subgraph obtained by removing the edges in from the original graph (Line 7). Subsequently, it computes the minimum spanning tree of the new graph obtained by adding the edges in to this subgraph and its spanning tree (Line 11).
It is worth noting that the algorithm requires information about the sorted edges of the current graph based on edge weights (ordered edge set
) to enhance computational speed. Upon completion of the algorithm, the ordered edge set
of the new graph will be returned for subsequent updates and maintenance of the minimum spanning tree when further changes occur. The updating algorithm for the minimum spanning tree of the subgraph in Algorithm 1, as well as the updating algorithm for the supergraph, will be specifically described in the following sections.
Algorithm 1 MST updating: dynamic graph MST fast updating and maintenance algorithm |
- 1:
Input: Graph , an ordered edge set , a minimum spanning tree T, sets of edges to be added and to be removed . - 2:
Output: Updated minimum spanning tree and modified edge set . - 3:
procedure MST_UPDATE() - 4:
- 5:
if then - 6:
Remove edges in from G. - 7:
- 8:
end if - 9:
if then - 10:
Add edges in to G. - 11:
- 12:
end if - 13:
return - 14:
end procedure
|
3.2. Updating and Maintenance of Minimum Spanning Trees for Subgraphs
This section describes the updating algorithm for the minimum spanning tree of the subgraph, as depicted in Algorithm 2.
Algorithm 2 MST updating subgraph: dynamic graph MST fast updating and maintenance algorithm |
- 1:
Input: Graph , ordered edge set , minimum spanning tree T, set of edges to be removed . - 2:
Output: Updated minimum spanning tree . - 3:
procedure MST_UPDATE() - 4:
- 5:
if T’ = T then - 6:
return - 7:
end if - 8:
- 9:
if then - 10:
return - 11:
end if - 12:
for do - 13:
if and then - 14:
- 15:
end if - 16:
if then - 17:
return - 18:
end if - 19:
end for - 20:
return - 21:
end procedure
|
The algorithm takes as input the current graph G, the minimum spanning tree T before the graph changes, the set of deleted edges , and the ordered set of edges from the original graph. The algorithm first removes from the original minimum spanning tree T to obtain the pruned subgraph (Line 4). Subsequently, the algorithm reconstructs and returns the disjoint set data structure D based on by using a depth-first traversal process, along with the count (n) of connected components in .
If equals T or forms a connected structure (), then it is the updated minimum spanning tree (Lines 6–8). Otherwise, the algorithm iteratively examines the edges in set that do not belong to or , and if an edge connects two different connected components in , it is added to until has edges. At this point, becomes the updated minimum spanning tree (Lines 9–16).
The latter part of the algorithm (Lines 9–16) is essentially similar to Kruskal’s algorithm. The key distinction lies in the fact that Kruskal’s algorithm starts building the minimum spanning tree from scratch, while Algorithm 2 maximizes the utilization of the original graph’s minimum spanning tree. It begins constructing the new graph’s minimum spanning tree from the substructure
derived from the original graph’s minimum spanning tree. To facilitate the continuation of Kruskal’s algorithm based on substructure
, a disjoint set structure
D matching the current
is required. Algorithms 3 and 4 describe the logical steps for obtaining the corresponding disjoint set
D based on input
.
Algorithm 3 Rebuilding disjoint set and returning current component count |
- 1:
Input: Minimum spanning tree . - 2:
Output: Component count n. - 3:
procedure REBUILD_DISJOINT_SET() - 4:
Set all elements in D to - 5:
Set all elements in V to FALSE - 6:
) - 7:
- 8:
while do - 9:
- 10:
- 11:
- 12:
) - 13:
end while - 14:
return n - 15:
end procedure
|
Algorithm 4 Recursive sub-procedure for rebuilding the disjoint set |
- 1:
Input: Minimum spanning tree , root vertex , current vertex v. - 2:
Output: None. - 3:
procedure COUNT_RECUR() - 4:
Reverse Neighbors of vertex v in - 5:
for do - 6:
if then - 7:
- 8:
- 9:
- 10:
COUNT_RECUR() - 11:
end if - 12:
end for - 13:
end procedure
|
Algorithm 3 initializes D and V. It starts by searching for an unvisited vertex in after initialization (Line 6), marks it as visited, and performs a depth-first traversal starting from it (Line 11). If there are no unvisited vertices after this depth-first traversal, the algorithm terminates; otherwise, it starts over from another unvisited vertex. The sub procedure find_unvisited in Algorithm 3 traverses the vertices in and returns the index of the first vertex corresponding to a FALSE V value. If all vertices have TRUE V values, find_unvisited returns −1. The detailed logic of the depth-first traversal process count_recur is described in Algorithm 4.
Algorithm 4 is an iterative depth-first traversal operation for a subgraph to rebuild the disjoint set, with the representative vertex and the current vertex v. If , the value represents the representative of vertex v; if , it indicates that v is a root representative representing all the other vertices in this connected component, and its absolute value represents the number of vertices in the connected component.
Algorithm 5 checks whether the two endpoints of edge
e are connected to the two connected components in the current subgraph
T. If true, it adds edge
e to the current subgraph
T, updates the corresponding
D values, and returns the updated subgraph
. The process of Algorithm 5 is identical to the corresponding steps in Kruskal’s algorithm.
Algorithm 5 Checking if edge e belongs to minimum spanning tree |
- 1:
Input: Minimum spanning tree T, edge e. - 2:
Output: Updated minimum spanning tree . - 3:
procedure CHECK_IF_TREE_EDGE() - 4:
- 5:
starting vertex of e - 6:
ending vertex of e - 7:
while do - 8:
- 9:
end while - 10:
while do - 11:
- 12:
end while - 13:
if then - 14:
if then - 15:
- 16:
- 17:
else - 18:
- 19:
- 20:
end if - 21:
- 22:
end if - 23:
return - 24:
end procedure
|
This algorithm differs from Kruskal’s algorithm in that it does not compute the spanning tree from scratch but utilizes the original minimum spanning tree of the graph and reconstructs its corresponding disjoint set. The depth-first traversal operation has linear-time complexity, whereas obtaining the same disjoint-set structure using Kruskal’s algorithm involves polynomial-time complexity.
3.3. Updating and Maintenance of Minimum Spanning Trees for Supergraphs
This subsection describes the minimum spanning tree updating algorithm for supergraphs. The algorithmic logic is shown in Algorithm 6. The input of Algorithm 6 includes the current graph
G, the minimum spanning tree
T before the graph changes, the set of added edges
, the set of deleted edges
, and the ordered set of edges
in the original graph. Algorithm 6 first obtains the union of
T and
, denoted by
; then it executes Kruskal’s algorithm with elements only from
; finally, it generates the ordered edge set
for the current graph
G based on
,
, and
, which will be used for the subsequent iterations to update the minimum spanning tree. Although a supergraph does not contain any deleted edges compared with the original graph, the deleted edges
here are the ones from the previous subgraph procedure and are used to generate the ordered edge set
for the next iteration.
Algorithm 6 Supergraph minimum spanning tree fast updating and maintenance algorithm |
- 1:
Input: Graph G, ordered edge set , minimum spanning tree T, set of edges to be added , set of edges to be removed . - 2:
Output: Updated minimum spanning tree , updated ordered edge set . - 3:
procedure MST_UPDATE_SUPER() - 4:
- 5:
: Sort elements in by weight in ascending order - 6:
Set all elements in D to - 7:
- 8:
for do - 9:
- 10:
if then - 11:
goto 14 - 12:
end if - 13:
end for - 14:
- 15:
return - 16:
end procedure
|
Algorithm 7 describes how to generate the ordered edge set
for the current graph
G. The logic involves a one-time merge–sort operation on two ordered setsone-time merge sort of two ordered sets: the ordered set of elements from
and the ordered set
, excluding elements belonging to
. It is important to note that when scanning elements from
one by one, elements belonging to
should be skipped.
Algorithm 7 Updating ordered edge set |
- 1:
Input: Ordered edge set , set of edges to be added , set of edges to be removed . - 2:
Output: Updated ordered edge set . - 3:
procedure GEN_SORTED_EDGES() - 4:
Sort elements in by weight in ascending order - 5:
- 6:
, - 7:
while and do - 8:
while and do - 9:
- 10:
end while - 11:
if then - 12:
goto 22 - 13:
end if - 14:
if then - 15:
Add to the end of - 16:
- 17:
else - 18:
Add to the end of - 19:
- 20:
end if - 21:
end while - 22:
if then - 23:
Append all remaining elements in from position j to - 24:
else - 25:
Append all remaining elements in from position i to excluding the ones in - 26:
end if - 27:
return - 28:
end procedure
|
This algorithm differs from Kruskal’s algorithm in that it does not use the complete current graph edge set but only the edge set , where is the union of the edge set of the original minimum spanning tree and the added edge set. For large sparse graphs with a relatively small added edge set, the size of is much smaller than the complete edge set E. Consequently, the number of instruction operations in this algorithm is lower than that of the operations required for performing the complete Kruskal’s algorithm on the current graph.
5. Experimental Analysis
This section presents an experimental analysis of the efficiency of the proposed algorithm. The dynamic graph minimum spanning tree updating and maintenance algorithm proposed in this paper was tested in the following three scenarios.
(1) Given the original graph and its spanning tree, solve the minimum spanning tree of the original graph’s supergraph. (2) Given the original graph and its spanning tree, solve the minimum spanning tree of the original graph’s subgraph. (3) Solve the minimum spanning tree of the new graph after changes to the original graph.
Additionally, a comparison of the runtime between the proposed algorithm and Kruskal’s algorithm, which recalculates the new graph, was conducted.
5.1. Experimental Data
The algorithms used in the experiments were implemented in Java. The experimental platform consisted of a computer with a six-core processor (Intel Core i7 2.6 GHz) and 16 GB of memory, running on the Windows 11 operating system. The timing for all algorithms in the experiments was measured in milliseconds.
The test instances were obtained from a common set of instances for the minimum dominating tree problem [
28]. Each instance represents a weighted undirected graph
, where
V is the set of vertices and
E is the set of edges. The instances were generated as follows:
vertices were randomly deployed in a
area, and edges connected vertices if the straight-line distance between them was less than a certain distance. The edge weights were assigned as the distances between the vertices. The instance set was divided into three groups based on the maximum vertex connection distance, namely, Range_100, Range_125, and Range_150 (the number indicates the maximum vertex connection distance, and a larger number indicates a denser graph). Each group contained 12 instances with a specified number of nodes
. All instances can be obtained from the author or online (
https://github.com/xavierwoo/Dynamic-MST, accessed on 25 March 2024).
To evaluate the algorithm’s performance in large-scale scenarios, we generated multiple clustered graph instances of massive scale. The generation process followed these steps: (1) Vertices were organized into clusters using a matrix layout. (2) Within each cluster, vertices were randomly placed within a square and connected with random probability, where the edge cost was determined by the distance. (3) Adjacent clusters were interconnected by introducing edges between two randomly selected vertices from each, with the distance representing the edge cost. These generated instances, as well as the generator used, are available from the author.
5.2. Experimental Evaluation of Supergraph Minimum Spanning Tree Maintenance Algorithm
This section presents the experimental results for the proposed algorithm applied to the updating and maintenance of the minimum spanning tree (MST) for the original graph’s supergraph.
5.2.1. Experimental Methodology for Supergraph
To evaluate the performance of the proposed algorithm for maintaining the minimum spanning tree of a supergraph, the following testing procedure was employed:
Start with a test graph . Randomly remove k edges to obtain a graph , using G as the input for the algorithm.
Use the ordered set of edges in E as the algorithm input parameter .
Use the minimum spanning tree of G as the algorithm input parameter T.
Use the set as the algorithm input parameter .
Set as an empty set.
At this point, the test graph is a supergraph of graph G. The experiments were conducted for different values of k (). The total running time of the algorithm was recorded and compared with the time taken by Kruskal’s algorithm to find the minimum spanning tree of .
Since the algorithm’s single run time is very short, each test case was independently repeated 1000 times, and the total running time was recorded. To improve the accuracy of the experiments, each set of data was calculated 100 times, and the average running time was reported in seconds.
In all comparative experiments presented in this paper, the timing of the proposed algorithm and Kruskal’s algorithm were conducted independently. The experiments used the same random seed to generate random sets, ensuring that each algorithm calculated on the same graph for every experiment.
5.2.2. Analysis of Experimental Results for Supergraph
The experimental results of the supergraph minimum spanning tree maintenance algorithm are shown in
Table 1. The first column of
Table 1 represents the group name of the test case, the second column is the name of the test case, and the next six columns compare the time consumption of the maintenance algorithm (MT) and Kruskal’s algorithm (Kru) under different conditions. The last column describes the number of vertices and edges in the current test case. We define a time consumption evaluation index, where
(
represents the runtime of Kruskal’s algorithm, and
T represents the runtime of the maintenance algorithm).
indicates the performance difference between the maintenance algorithm and Kruskal’s algorithm. The larger
is, the better the performance of the maintenance algorithm is. Boldfaced
in the table indicates that the corresponding algorithm’s runtime is smaller than that of the comparison algorithm. The formats and meanings of the subsequent tables are the same as those of
Table 1.
From
Table 1, we can conclude that the proposed algorithm for maintaining the minimum spanning tree in supergraphs is significantly superior to Kruskal’s algorithm for a complete recalculation of the MST in the new graph. When comparing Kruskal’s algorithm for different numbers of added edges in the same test case, we observe a relatively smooth fluctuation in its runtime. The fewer edges the maintenance algorithm adds, the larger the value of
is, indicating a greater advantage of the supergraph maintenance algorithm. Additionally, it is evident that for graphs with the same number of vertices and a similar number of graph changes, the
value is larger for denser graphs. This suggests that the updating algorithm performs better in calculating the MST of supergraphs, particularly on denser graphs compared with sparse ones.
5.3. Experimental Design for Subgraph
This section tests the updating and maintenance algorithm for the original graph’s subgraph.
5.3.1. Experimental Methodology for Subgraph
We tested the maintenance algorithm for the minimum spanning tree of the subgraph by using the following approach:
Let the example graph be denoted by , and use graph G as the input to the algorithm. Randomly remove k edges from G to obtain the subgraph .
Let the ordered set of edges from the edge set of the graph G be the algorithm input parameter .
Let the minimum spanning tree of graph G be the algorithm input parameter T.
Set as an empty set for the algorithm input parameter.
Let be the set .
At this point, the example graph is a subgraph of graph G. The experiment tested the cases where , recorded the total runtime of the entire algorithm, and compared it with the runtime taken by Kruskal’s algorithm to solve the minimum spanning tree for graph .
The experiment protocol is the same as the one used in the supergraph test.
5.3.2. Analysis of Experimental Results for Subgraph
Through
Table 2, we can conclude that for the solution of the minimum spanning tree in the subgraph, the proposed subgraph minimum spanning tree maintenance algorithm in this paper is significantly better than Kruskal’s algorithm, which recomputes from the scratch. By comparing the runtime of Kruskal’s algorithm when deleting different numbers of edges in the same test case, it was observed that the runtime fluctuation of Kruskal’s algorithm is relatively small. The fewer edges the maintenance algorithm deletes, the larger the
value is, indicating a greater advantage of the subgraph minimum spanning tree maintenance algorithm. It was also observed that for graphs with the same number of vertices and a similar number of graph changes, denser graphs yield larger
values. This suggests that the updating algorithm performs better on dense graphs compared with sparse graphs when computing the minimum spanning tree of the subgraph.
5.4. Experimental Evaluation of Dynamic Graph Minimum Spanning Tree Maintenance Algorithm
This section tests the proposed dynamic graph minimum spanning tree maintenance algorithm in this paper in general scenarios.
5.4.1. Experimental Design for Dynamic Graph Minimum Spanning Tree Maintenance Algorithm
As presented in this section, we tested the dynamic graph minimum spanning tree maintenance algorithm through continuous multiple iterations.
The initial iteration’s algorithm parameters were set as follows:
Let the example graph be . Randomly delete k edges from it to obtain the graph G, which serves as the input original graph for the algorithm.
Denote the ordered set of edges from graph G by , and let it be the algorithm input parameter. Denote the minimum spanning tree of graph G by T, and let it be the algorithm input parameter.
Let be the set and be a randomly selected subset of size k from set E.
For each subsequent iteration, the algorithm parameters were generated based on the results of the previous iteration, as follows:
Remove all edges in from graph G, and add all edges in to obtain the graph .
Set , and let be a randomly selected subset of size k from set .
is the minimum spanning tree of graph , as given by the previous iteration.
is the ordered set of edges from set , as given by the previous iteration.
These parameters ( and are used as the input for the new iteration.
The experiment protocol is the same as the previous ones.
5.4.2. Analysis of Maintenance Algorithm Results for Dynamic Graph
From
Table 3, we can conclude that for solving the minimum spanning tree problem in general dynamic graphs, the proposed dynamic graph minimum spanning tree maintenance algorithm is significantly better than Kruskal’s algorithm, which recomputes from scratch. By comparing different numbers of modified edges (additions and deletions) within the same test case, it was observed that the more edges are modified, the smaller the value of
is, indicating that the advantage of the dynamic graph minimum spanning tree maintenance algorithm diminishes. Additionally, it was observed that for the same number of vertices and a similar graph modification number, higher-density graphs yield larger
values. This implies that the updating algorithm performs better on dense graphs than on sparse ones.
5.5. Analysis for Massive Cluster Graphs
In this subsection, we evaluate the performance of our proposed algorithm on massive cluster graphs. We compared our algorithm with Kruskal’s (Kru) and Prim’s (Pri) algorithms. Due to the larger size of the instances used in this experiment compared with those in the previous sections, each test was conducted over 50 iterations, with 50 edges being modified in each iteration. The results are presented in
Table 4. The columns
and
represent the performance differences between our maintenance algorithm and Kruskal’s and Prim’s algorithms, respectively. The instances’ names follow the format
cluster-nxn-g-p-s, where
nxn denotes the matrix layout of the entire graph,
g represents the number of vertices in a single cluster,
p represents the connection probability, and
s denotes the random seed used to generate the instance.
Based on the results presented in
Table 4, it is evident that the maintenance algorithm outperforms Kruskal’s and Prim’s algorithms on cluster graphs. Specifically, Prim’s algorithm demonstrated better performance compared with Kruskal’s algorithm in this experiment. This observation aligns with the fact that Prim’s algorithm tends to be more efficient than Kruskal’s algorithm when dealing with dense graphs, which was the case for all instances used in this experiment. However, despite this advantage, Prim’s algorithm is still 5 to 8 times slower compared with the proposed maintenance algorithm.
5.6. Analysis of Algorithm Performance with Graph Changes
We conducted experiments on the dynamic graph minimum spanning tree maintenance algorithm iteratively, with the same experimental protocol as the dynamic graph minimum spanning tree maintenance algorithm experiments described above. We wanted to determine the specific point at which computing from scratch becomes more advantageous than maintaining the existing version.
We selected six test cases with different densities and various vertex numbers for experimentation. For each test case, we gradually increased the number of modified edges and recorded the algorithm’s running time. To enhance experimental accuracy, each set of data underwent 100 calculations. We also tested using Kruskal’s algorithm to compute from scratch and compared the results. Note that when edge sets and exceeded half of the total number of edges in the graph, the new graph became entirely different from the original, rendering the algorithm results meaningless.
The results are shown in
Figure 6. The x-axis in the figures represents the increasing number of added and deleted edges, while the y-axis represents the algorithm’s running time. Through the comparison of the running time results of the six test cases, it was observed that the maintenance algorithm had a significant advantage when the number of modified edges was small. As the number of modified edges increased, the gap between the two algorithms gradually narrowed. When the number of modified edges approached half of the total edges in the test case, the running times of the two algorithms became close. By comparing the figures, we found that with fewer modified edges, an decrease in the graph density led to a greater advantage for the maintenance algorithm.