1. Introduction
The Steiner
-eccentricity on a given fixed
-subset of vertices measures the maximum distance from the subset to all
k-sets, each of which contains the subset. This metric reflects a kind of optimal connectivity challenge. This concept can engage in metaphorically multi-attribute decision-making (MADM) [
1], where each attribute could represent a “vertex” and the optimization of the overall system’s performance corresponds to finding the “Steiner point” that maximizes “distance” to all objectives. The Steiner distance is the minimum number of edges in a connected subgraph that contains a given subset of vertices. This distance between two subsets is the distance for their union.
Particularly, if
, the Steiner
-eccentricity turns to be Steiner
k-eccentricity on a specific vertex. The research of Steiner
k-eccentricity can be traced back to the 1990s [
2]. Researchers have studied extensively mathematical properties of Steiner
k-eccentricity [
3,
4,
5,
6,
7]. Steiner
k-eccentricity has indeed found practical applications. Huilgol et al. [
4], in their 2024 study, applied Steiner
k-eccentricity in predicting the boiling points of primary and secondary amines, demonstrating its effectiveness in chemical property prediction. In addition, it has been used to calculate network similarity measures [
8]. Additionally, it is leveraged for predicting the molecular activity of substances [
9]. Collectively, these advancements highlight the adaptability and significance of Steiner
k-eccentricity as a tool in the fields of network analysis and chemical predictive modeling. For a given fixed
-set of vertices
R, the Steiner
-eccentricity on
R is the maximum number of edges in a minimum distance Steiner tree with
vertices and containing
R. An optimal solution of this is a corresponding Steiner tree. When, as for us, the underlying graph is a tree, every Steiner tree is uniquely determined by, and is easily computed from by, any set of its vertices that includes all its leaves.
In decision making contexts, seeking a solution that optimizes across various attributes is to find a Steiner tree in a network of objectives, where the goal is to minimize the cumulative or maximum ’cost’ associated with achieving all objectives simultaneously. Since the well-known
minimum Steiner tree problem has been proven to be NP-hard [
10], it is not easy to compute Steiner
-eccentricity. In recent years, algorithms for computing Steiner
k-eccentricity have been developed [
11]. Li et al. studied average Steiner 3-eccentricity on trees [
12] and devised a polynomial algorithm [
11] for finding the Steiner
k-eccentricity of a given vertex in a tree. Later, Li et al. [
13] tried to compute Steiner
k-eccentricity on general graphs by using the algorithm on trees. But, the time-complexity is really unbearable.
In 2024, Gengji Li et al. delved into the realm of graph theory, specifically focusing on the Steiner
-eccentricity of a 2-set within trees in their research work [
14]. This study not only explores this particular aspect of Steiner distances but also contributes by establishing several bounds—both lower and upper—for the average Steiner
-eccentricity on trees. Despite these advancements, computational studies and algorithmic developments for the broader concept of Steiner
-eccentricity remain limited, indicating an area of future research where the practical computation and efficiency of such measures could be further investigated.
In this study, the structure of an optimal solution of Steiner -eccentricity on a fixed -set in a tree is studied. For a given -set in a tree T and an integer , we prove that an optimal solution of Steiner -eccentricity on R takes some optimal solution of Steiner -eccentricity on R as a partial solution of it. In addition, given a subtree which is an optimal solution of Steiner -eccentricity on a fixed -set R in a tree T, there is an optimal solution of Steiner -eccentricity on R such that contains the given .
Finally, an
-time algorithm is devised to solve Steiner
-eccentricity in a tree. The time complexity meets with the result in [
11] for computing Steiner
k-eccentricity.
The rest of this paper is organized as follows.
Section 2 proposes basic terminologies and properties. We define and explore the concepts of
quasi-pendent paths and the
eccentricity of a subgraph in this section, which serve as foundational elements for the entire paper. The structural properties of optimal solutions are examined in
Section 3. Particularly,
Section 3 focuses on the relationship between Steiner
-eccentricity and Steiner
-eccentricity on a given fixed
-set.
Section 4 shows that Steiner
-eccentricity can be solved in
-time. We conclude the paper in
Section 5 and propose several directions for future work.
2. Preliminary
In the remainder of this paper, we focus on trees and the underlying graph is always a tree. A tree is a connected graph which has no cycles. The vertex set and edge set of a tree T are, respectively, denoted as and . If a tree is composed of a single vertex, then the tree is said to be trivial. If a tree contains more than one vertex, it is said to be non-trivial. The unique path between and in a tree T is denoted by . A vertex is a neighbor of another vertex if they are adjacent in a tree. The set of neighbors of a vertex v in a tree T is denoted as . The degree of a vertex v in a tree T is denoted as which is the number of neighbors of v, i.e., . If , then v is said to be a leaf of T. The set of leaves in a tree T is denoted as . If , then v is said to be an internal vertex of T. If , then v is said to be a branching vertex or a branch of G. If G itself is a path, then a leaf of the path is also said to be an endpoint.
Let and , respectively, be a subset of vertices and edges in a tree T. The induced subgraph of in T is denoted by which is a subgraph of T such that an edge of T is in if and only if its two endpoints are both in . The induced subgraph of in T is denoted as which is a subgraph of T such that .
Lemma 1. Let and be two sub-trees of a tree T such that . Let be two distinct vertices. We have .
Proof. Recall that the path P is unique, since T is a tree. Since and is connected, P must be a sub-tree of the tree . In addition, and is connected, P must be a sub-tree of the tree . So, P is a path both in and in . Therefore, all vertices belonging to P are also in . □
Lemma 2. Let and be two distinct paths in a tree T. If then the subgraph induced by is a single path in T.
Proof. Suppose on the contrary that the subgraph induced by common edges has more than one component. Obviously, each component is a sub-path of , as well as . Let p and be two different components. For the reason that T is connected, there exists two distinct sub-paths connecting p and , respectively, in and . This implies a cycle in the tree T. □
The minimum Steiner tree on a set in a tree T is denoted by . For us, the size of a tree is the number of edges in it. Each vertex in S is said to be a terminal vertex, while each vertex in is said to be a Steiner vertex. The Steiner distance on a set S is the size of a , and is denoted as . A vertex set is a k-set if .
Lemma 3. Let T be a tree and . The set of leaves in a minimum Steiner tree on S is a subset of S, i.e., .
Proof. Any leaf not in S of a tree that connects S can be removed without disconnecting S. So, the leaves in a minimum Steiner tree of S should all belong to S. □
Lemma 4. Let be a vertex set of a tree T. For every two vertices , the path is contained by the minimum Steiner tree .
Proof. The path is unique in the tree T. In addition, the vertex u and v should be connected in . So, the path is contained in the minimum Steiner tree . □
Given a fixed
-set
of a tree
T, Steiner
-eccentricity of
R in
T is defined as:
If
, then
is defined to be zero. In this paper, we consider the case that
. If
, then Steiner
-eccentricity of R turns to be Steiner
k-eccentricity of a given vertex. The computation of Steiner
k-eccentricity on trees has been studied in paper [
11,
12].
Given a fixed -set R, if S is a k-set such that and , then S is said to be a Steiner -ecc R-set corresponding to . The minimum Steiner tree is an optimal solution corresponding to and said to be a Steiner -ecc R-tree corresponding to S. In this paper, stands for a Steiner -ecc R-tree, and stands for a Steiner -ecc R-set.
Lemma 5. Let be a fixed -set in a tree T. The Steiner tree on R in T is a subgraph of for every .
Proof. If , then is the single vertex in R. Obviously, is a subgraph of a Steiner -ecc R-tree, for every . The following proof considers the case that .
In order to prove that is a subgraph of , we need to prove . Because both and are trees, by Lemma 1, implies that . Since and , we are going to prove that .
Suppose on the contrary that there is a vertex such that . Since , then there are two vertices such that the path contains the vertex v. Because , and , the path does not go through v any more. Then, there are at least two different paths between u and w in the tree T, which is a contradiction. Therefore, is a subgraph of , for every . □
Lemma 6. Let be a fixed -set in a tree T. If , then . Otherwise, .
Proof. Suppose on the contrary that in the case that . Since , there is at least one vertex such that . Because contains exactly k vertices and R must be contained by , there must be a vertex such that .
On the other hand, suppose on the contrary that in the case that . Let be a vertex such that the degree of is at least two in T. In other words, . Since , there must be a leaf such that .
So neither nor is a leaf in the tree T. However, they are both in the set . In addition, and are both leaves in the set , but not in the set . In the following proof, we will prove that neither the scene nor the scene could occur, which implies that the lemma holds true.
Let us prove that the scene of and could not occur. The proof is performed through the two following cases.
There are two vertices such that is an internal vertex of the path . Since the path between and in T is unique, the unique path must be owned by a Steiner -ecc R-tree. Let be the Steiner -ecc R-tree which contains . In other words, contains naturally whenever and is in the . Now, let us consider which is another k-set. This minimum Steiner tree of this k-set has at least one more edge than that of the set , because and the minimum Steiner tree on the k-set must contain . This means that is not the maximum, which is a contradiction.
For any two vertices ∈, is not an internal vertex of the path . Since , there exists a neighbor such that . Now we consider the new k-set . The minimum Steiner tree on the new k-set is strictly larger than that on the set . This is also a contradiction.
Therefore, if , then .
The scene of and also could not occur. The proof is the same as the above. Replacing with and then replacing with in the above, one will complete the proof. Therefore, if , . □
Let be a -set in a tree T. By Lemma 6, if , then the Steiner -ecc R-tree is the entire tree T, because . This is trivial for computation. In this article, we examine in the absence of any specific instructions.
Corollary 1. Let be a fixed -set in a tree T. If , then every vertex in the set is a leaf of . Moreover, for every two integers and satisfying that , if , then we have .
Proof. By Lemma 6, if , then every vertex in the set is a leaf of T. So, for every vertex u in the set , could not be larger than one, since is a sub-tree of T. For every integer , if , by Lemmas 3 and 6, we have = ∪. Since , > holds true. Therefore, >. □
2.1. Quasi-Pendent Path
Given a fixed -set in a tree T, according to Lemma 5, a Steiner -ecc R-tree always contains . In this paper, always stands for the minimum Steiner tree of the given -set R. In other words, .
Recall that a path
P is said to be
a pendent path in a graph
G if each internal vertices of
P is also an internal vertex of
G, while one endpoint of
P is a leaf of
G [
15]. Here, we extends the concept of
pendent path and named it as
quasi-pendent path, which is defined as follows. Let
be a sub-tree of
T such that
and
. The
quasi-pendent path of the leaf
in
is a non-trivial path such that: (1)
u is one endpoint of
; (2) If
contains internal vertices, then each internal vertex of
is also an internal vertex of
(with degree 2 in
) but does not belong to
; (3) The other endpoint of
is either in
or a branching vertex of
. Please see
Figure 1 for an example of quasi-pendent paths.
Lemma 7. For every fixed -set R of a tree T and every sub-tree satisfying that and , the quasi-pendent path of a leaf always exists and is unique.
Proof. Let and . Since is a tree, is the unique path between u and v in . Note that the path always exists since T is a tree which is connected. Let be the nearest vertex to u among all vertices on satisfying: (1) if , then and for each vertex ; (2) either or .
Since , the vertex could not be u. In addition, there could not be two distinct vertices on such that both of them satisfies the above conditions. Otherwise, either one of them would not be the nearest one to u, or there would be a cycle in T. So the quasi-pendent path of a leaf in a tree is unique and always exists. □
Lemma 8. Let be a fixed -set in a tree T. Let v be the endpoint of such that . Let . Let F be the forest obtained by deleting the edge from T. Let and be the sub-trees in F, respectively, containing v and w. We have .
Proof. If , then let . According to the definition of the quasi-pendent path, . So . Then, must have common vertex with the path . So, a vertex in must be a degree larger than two. This contradicts the fact that is a quasi-pendent path. □
2.2. Eccentricity of a Steiner -ecc R-Tree
Let H be a subgraph of a tree T, and . The shortest path between v and H in T is denoted by . In , v is marked as while the other endpoint of is marked as . The distance between v and H in T which is denoted by is the size of . The eccentricity of H in T is = .
Lemma 9. Let H be a subgraph of a tree T, and . Let . Then, and .
Proof. If , then according to the definition, . So, obviously, and .
If , then . Suppose on the contrary that . There is a vertex such that and . Let be the sub-path between v and u. Due to the reason that is the shortest path between v and , its sub-path is a shortest path between v and u. In addition, the length of is strictly smaller than that of since . This contradicts the fact that is a shortest path between v and H, because u is a vertex in and is smaller than . □
Lemma 10. Let and be two distinct sub-trees of a tree T such that . If , then .
Proof. Let . Suppose on the contrary that . Let . Let w be the nearest vertex to among all vertices in , i.e., .
If , then the path P would be the form because the path from to in tree T is unique. Thus, . By Lemma 9, this contradicts the fact that P is the shortest between v and .
Now, let us consider the case that . Then, then the path between u and does go through w. Since is a tree u and w are connected in . To ensure the connectivity in , the path between u and w is the form , and must be in the tree . Then, the path between w and is in . This contradicts the fact that does not belong to . □
Let H be a subtree in a tree T. If satisfies , then the path is said to be an H-ecc path. In addition, v is said to be the head of the H-ecc path and is marked as , while the other endpoint is said to be the tail of the H-ecc path and marked as . Let be the set of heads of all H-ecc paths. Every vertex in is said to be a farthest vertex away from H in T.
Lemma 11. Let be a sub-tree of a tree T such that . Every vertex in is a leaf of T.
Proof. Let . Then, because of . Let be the head of a -ecc path, and be the tail of the -ecc path. By Lemma 9, . If , then there must be a leaf such that the path has no common edges with the -ecc path. Then, the path is the shortest path between and , since in a tree, there is a unique path . Moreover, is strictly longer than the path , which contradicts the fact that is a -ecc path. □
Lemma 12. Let be a fixed -set in a tree T. Let and , respectively, be two distinct Steiner -ecc R-trees. Let be a -ecc path and be a -ecc path. If , then both and belong to the set .
Proof. Since , we have . In other words, there are common vertices between and . So there are three configurations for the positions of and . The first one is that and both belong to the set . The second configuration is that one of them is in and the other one is in . The last one is that and . In the following proof, we will, respectively, show that the second and third configurations could not occur.
Let us prove that the second configuration could not occur. By Lemma 9, could not in , and could not in . Without loss of generality, let and . We will derive a contradiction through the following statements.
Let
such that
v is the nearest vertex to
among all vertices in
. See
Figure 2a for this configuration. By Lemma 10, no vertex of
is in
. By the assumption,
. Because
is a
-ecc path of
and the path between
v and
is the shortest path between
and
, the length of
is no less than the length of the path between
v and
in
T. Since
,
is longer than
.
According to the assumption, is also a vertex in . Therefore, the contradiction is that is not a -ecc path. So, the second configuration could not occur.
Finally, let us prove that the third configuration could also not occur. Suppose on the contrary that
and
. Let
such that
v is the nearest vertex to
among all vertices in
. Let
such that
u is the nearest vertex to
among all vertices in
. By Lemma 10,
and
both hold true. See
Figure 2b, for this configuration.
Without loss of generality, let the length of be no larger than that of , i.e., . Since , then the path between v and is strictly longer than the path . This contradicts the fact that the path between v and is the shortest path between and and is a -ecc path. So the third configuration also could not occur.
All in all, and both belong to the set . □
Theorem 1. Let be a fixed -set in a tree T. Let and , respectively, be two distinct Steiner -ecc R-trees. We have .
Proof. If , by Lemma 6, . Otherwise, from Lemma 12, we know that the tail of -ecc path and the tail of -ecc path are both in the set . In addition, by Lemma 1, the induced subtree is the same as . Let . Then, the -ecc path, as well as the -ecc path is just the -ecc path. Therefore, the length of -ecc path is equal to that of -ecc path. □
3. The Structure of Optimal Solutions
This section studies the structure of optimal solutions on trees, which is a support for the
-time algorithm of
Section 4. The structural properties are stated in Theorems 2 and 3. Given a vertex
-set
and an integer
, Theorem 2 indicates that each Steiner
-ecc
R-tree contains some Steiner
-ecc
R-tree. But, this does not mean that each any Steiner
-ecc
R-tree is contained by a Steiner
)-ecc
R-tree. A trivial questions whether there is a Steiner
)-ecc
R-tree not owned by any Steiner
-ecc
R-tree. Theorem 3 answers this question and says that each Steiner
-ecc
R-tree is contained by some Steiner
-ecc
R-tree. It is a little stronger.
Lemma 13. Let be a fixed -set in a tree T such that . Let u be a leaf in . If , then there exists and such that and .
Proof. Since
has common edges with
, then there exist
and
such that
. Given vertex
, let
be the vertex set such that
holds true for every vertex
. Let
be the endpoint of
such that
. By Lemma 2, let
such that the common portion of
and
is
, where
. Without loss of generality, let
be farther to
x than
. See
Figure 3.
We claim that . Since is a sub-path of , then, by Lemma 8 and the definition of quasi-pendent path . Now we prove that . Assume on the contrary that . Then, by Lemma 5, contains a path between and a vertex in . This implies that the degree of is at least three in . Recall that is an internal vertex of . By definition, this is a contradiction.
Now, we prove that and there is a vertex such that . Because , we just need to prove that and there is a vertex such that . We prove this proposition by discussing whether is in or not.
If , then the path satisfying that . Thus, and .
Now, let us consider the case that . By Lemma 5, since the path and are connected, there is a vertex and a vertex such that w and is connected through a path in and , since is a sub-tree of .
We claim that . Otherwise, let such that there is a path between w and in . Then, the degree of w in is at least three since the path is also a part of . This contradicts the fact that is a quasi-pendent path.
So w must be equal to . Then, such that . Therefore, the lemma holds. □
Lemma 14. Given a leaf , if there exist two distinct leaves and a vertex such that , and , then neither the other endpoint of nor the other endpoint of is in the set .
Proof. Let be the other endpoint of , and be the other endpoint of . By Lemma 2, the common part which is shared by and is a single path. In addition, the common part which is shared by and is also a single path. Suppose on the contrary that is not on the path . Then, . In addition, v is neither on the path nor on the path because and every vertex in does not belong to . In the tree T, the two paths and are connected by some edges of , because they both share edges with .
Because the vertices excluding the endpoints of and are all internal vertices in , there is no edge of connecting and in . So, in the tree , there is a sub-tree connecting the three vertices v, and such that , since . This implies that there is a cycle in the tree T. It is in the same way to prove that could not be in the set . So, the lemma holds. □
Lemma 15. Given a leaf , if there exist two distinct leaves and a vertex such that , and , then it is impossible that and occur simultaneously.
Proof. Let , be the other endpoint of and be the other endpoint of . By Lemma 2, let be the common part of and . Let be the common part of and .
By Lemma 14, and . It might only be possible that and . Since there is no cycle in tree T, as well as in , and are connected in the tree by only the edges of . In addition, and are connected in the tree by only the edges of . Suppose on the contrary that and occur simultaneously. Then, one endpoint of and , excluding and , would have degree three. This is a contradiction because and are both quasi-pendent paths in . □
Lemma 16. Let be a -set in a tree T. If , then there is a leaf such that .
Proof. Suppose on the contrary that for every leaf the quasi-pendent path has common edges with . Then, by Lemma 13, for every leaf there exist and such that and . In addition, by Lemma 15, for a leaf , two distinct leaves and a vertex do not exist, such that , and are all true. This implies that the number of leaves in is no less than that in . This contradicts Corollary 1. □
Lemma 17. Let be a -set in a tree T such that . Let be a quasi-pendent path of a leaf such that . Let S be the -set corresponding to , and . We have .
Proof. Let
, where
is the other endpoint such that
. If all edges in
were deleted from
, we would achieve a series of sub-trees which, respectively, contain
and
u. Let
be the sub-tree containing the vertex
. Please see
Figure 4 for this configuration.
Because has no common edge with , we have . Otherwise, suppose on the contrary that there is a vertex such that w is also in S. By Lemma 8, we have . So there is a vertex such that and there is a path between w and in . Moreover, the path between w and is unique in the T. So the path between w and in must contain the edge . This leads to a contradiction that has a common edge with .
Thus, the minimum Steiner tree on the set contains the entire path , but does not contain any edge in any more. Therefore, the quasi-pendent path of u in must contain the entire path . □
Let and , respectively, be two trees. The union of and is a new tree T such that and .
Theorem 2. Let be a -set in a tree T. If , then given a Steiner -ecc R-tree , there is a Steiner -ecc R-tree which is contained by .
Proof. Suppose on the contrary that a Steiner -ecc R-tree does not contain any Steiner -ecc R-tree. Let be a Steiner -ecc R-tree. Then, by the assumption, does not contain the entire tree .
By Lemma 16, there is a leaf such that the quasi-pendent path has no common edge with . Let be the other endpoint (which is different from u) of the path .
Let , where is the Steiner -ecc R-set corresponding to . The tree is the minimum Steiner tree on the -set . Because if is not a minimum Steiner tree on , then the union of a smaller Steiner tree on (than ) and the path could span all vertices in the set , which contradicts the fact that is a minimum Steiner tree.
By that assumption, is strictly smaller than . In other words, . Moreover, according the construction, the union of and is the entire tree , i.e., + = .
Now, let us turn to . Let be the Steiner -ecc R-set corresponding to . Let . In the following proof, we are going to show that the minimum Steiner tree on the set is strictly larger than . This contradicts the fact that is the maximum over all minimum Steiner trees on k-sets containing R.
Let be the minimum Steiner tree on the set . By Lemma 17, the path is a sub-path of . So, we have ≥ + > + = . Therefore, is strictly larger than . This brings us to the contradiction. □
Corollary 2. Let be a -set in a tree T such that . Let be a Steiner -ecc R-tree that is contained by a known Steiner -ecc R-tree . There is a -ecc path P such that the union of and P is the tree . In addition, + .
Proof. Let be a and be a such that is contained by . Let and be the Steiner -ecc R-set and Steiner -ecc R-set, respectively, corresponding to and .
Since , by Lemma 6, has exactly one more vertex than . Again, by Lemma 6, the extra vertex in the set compared to the set is a leaf of T. So the extra vertex is one of those vertices in . Thus, the union of and one of -ecc paths is . And the summation of the sizes of them is equal to the size of . □
Theorem 3. Let be a -set in a tree T. If , then given a , there is a such that contains this .
Proof. Let be the given . Suppose on the contrary that there is no such that contains . Let be a . By Theorem 2, let be the which is contained by .
According to the assumption, and are distinct. By Theorem 1, we have . By Corollary 2, the union of and one of its -ecc paths is just the tree . So we have .
Let us turn to the tree
. Let
P be an
-ecc path and
w be the head of
P, i.e.,
. By Lemma 11,
w is a leaf of
T. Let
be the Steiner
-ecc R-set corresponding to
. Then,
is a
k-set. The size of
is:
According to the assumption that is not contained by any , then is not a Steiner -ecc R-tree. So, . Then, we have , which contradicts the fact that they are both Steiner -ecc R-trees. Therefore, the theorem holds. □
Corollary 3. Let be a -set in a tree T. If , then given a Steiner -ecc R-tree , the union of and P is a Steiner -ecc R-tree of R, where P is one of its -ecc paths. In addition, the Steiner -eccentricity of R is .
Proof. By Theorem 3, let be a such that contains . By Corollary 2, there is a -ecc path P such that the union of P and is . And, the size of is equal to . □
4. The Algorithm
Let R be a given fixed -set in a tree T. Let k be an integer such that . If , by Lemma 6, the whole tree T is the optimal solution corresponding to Steiner -eccentricity of a given -set. Now, we focus on the case that .
According to Lemma 5, in order to compute the Steiner -eccentricity of R in a tree T, firstly we find the minimum Steiner tree on the set R, and then search for the remaining portion of a Steiner -ecc R-tree. This is the logical framework of our approach. This section presents an algorithm to realize this framework, in which the algorithm can not only find a minimum Steiner tree of a given set in -time, but can also find the remaining portion of an optimal solution in -time.
Given a vertex set
of a tree
T, Algorithm 1 is to find
in the tree
T.
is represented by black-colored vertices in the algorithm. Initially, the vertices in
S are all colored
black, while the vertices out of
S are all colored white, since
S must be in the tree
. The next task is to find Steiner vertices so as to connect all vertices of
S with a minimum number of edges. The algorithm runs a breadth-first search (BFS) procedure [
16] beginning with an arbitrary
source vertex in
S. Whenever the search discovers an unvisited vertex
v in the course of scanning an already discovered vertex
u, the vertex
v is marked as “visited”. We say that
u is the
predecessor or
parent of
v. The parent of vertices is stored in an array
in Algorithm 1. By Lemma 4, whenever it meets a black vertex, all the vertices which are on the path from the source vertex to this newly discovered black vertex are colored black. Meanwhile, the parents of all these newly colored black vertex are marked as ⌀. This procedure is realized in Steps 15–17 in the Algorithm 1. At the end of the algorithm, every vertex in
is colored black, while those vertices out of
are all colored white.
Algorithm 1: Steiner-Tree(S, T)
|
| Input: A tree T and a vertex set |
| Output: The minimum Steiner tree of S in T.
|
1 | foreach do ← white; ← ⌀; ;
|
2 | foreach do ← black;
|
3 | s ← Pick a vertex from S;
| | // The source for BFS |
4 | Q ←∅;
| | // Initialize an empty queue Q |
5 | ENQUEUE(Q, s); |
6 | while do |
7 | | | u ←;
|
8 | | | ;
|
9 | | | foreach do |
10 | | | | | if white and then |
11 | | | | | | | ←u;
|
12 | | | | | | | ;
|
13 | | | | | else if black and then |
14 | | | | | | | x ←u;
|
15 | | | | | | | while do | | // By Lemma 4 |
16 | | | | | | | | ← black; ; ; ; | |
17 | | | | | | | end |
18 | | | | | | | ← ⌀;
|
19 | | | | | | | ;
|
20 | | | end |
21 | end |
22 | return The two arrays: and .
|
Now let us turn to the approach of computing Steiner -eccentricity. If , then the Steiner -eccentricity of a fixed -set R is the size of in a tree T. The optimal solution can be earned directly from Algorithm 1. If , by Corollary 3, our idea to find a Steiner -ecc R-tree basically needs the three following stages. Firstly, obtain a Steiner -ecc R-tree which is noted as . Next, choose the maximum distance between and every leaf in . Finally, merge the shortest path which is between and the leaf into . If , then it is in the same way to earn . Otherwise, can be earned by Algorithm 1. The whole process for computing Steiner -eccentricity of a given -set in a tree is summarized in Algorithm 2. Its details are going to be stated in the following.
Given a vertex set of a tree T, by Lemma 5, the set of vertices in is naturally included in it. Algorithm 2 starts with the in Step 1. The tree is marked with black-colored vertices which are stored in the array . Subsequently, the algorithm calculates the distance between and each leaf of T in Step 2. Finally, the Algorithm 2 goes through rounds of iteration in a while-loop, in which at each iteration it merges a farthest leaf with its corresponding shortest path into a partial solution.
Algorithm 3 calculate the distance between each vertex and the (already-discovered) partial solution. Note that every vertex in the partial solution has been colored black. If a vertex is in the partial solution, then the distance is zero. So the
for each black vertex is zero. The algorithm is a BFS procedure beginning with a black vertex. Once a white vertex
u occurs in the course of scanning an already discovered vertex
v, then
. Recall that by Lemma 4 those vertices with a white vertex as an ancestor is white. Therefore, at the end of Algorithm 3, the array
stores the distances between each vertex and the black-colored partial solution.
Algorithm 2: Steiner-ECC(R, k, T)
|
| Input: A tree T, a vertex set and an integer |
| Output: Steiner -eccentricity of R.
|
1 | , ← Steiner-Tree(R, T);
| | // Algorithm 1 |
2 | ← Get-dis(T, , );
| | // Algorithm 3 |
3 | i ← 1;
| |
4 | while do | | // By Corollary 3 |
5 | | v ← Find the maximum among all leaves in ;
| |
6 | | P ← ∅;
| | // An initial empty set P representing a path |
7 | | P ← ;
| |
8 | | while do P ←; ; | |
9 | | foreach do ← black; ; ; | |
10 | | Update(P, , T); | | // Algorithm 4 |
11 | end |
12 | return The size of the subtree induced by the set of black vertices.
|
Algorithm 3: Get-dis(T, , )
|
| Input: A tree T, two arrays and |
| Output: The distance between every vertex and a subtree which is colored black
|
1 | foreach do ;
|
2 | s ← Pick a black vertex;
| // The source for BFS. |
3 | ← 0;
|
4 | Q ←∅;
| // Initialize an empty queue Q |
5 | ;
|
6 | while do |
7 | | | u ←;
|
8 | | | ;
|
9 | | | foreach do |
10 | | | | | if white and then |
11 | | | | | | ← | |
12 | | | | | | ;
| |
13 | | | | | else if black and then |
14 | | | | | | ← 0;
| |
15 | | | | | | ;
| |
16 | | | end |
17 | end |
18 | return The array .
|
Once a leaf and its corresponding shortest path are merged into a partial solution, the array should be updated because the distances between the remaining leaves and the newly constructed partial solution would become smaller. The updating procedure is listed in Algorithm 4. Recall that only the distances of those vertices with ancestors on this merged shortest path might be decreased. So, Step 10 only considers those sub-trees hanging at the merged path. Algorithm 4 assigns 0 to for each vertex on the merged path, and runs a BFS procedure starting with each internal vertex of the merged path. Black vertices and those vertices on the merged path will not be traversed in this procedure.
Theorem 4. There is an -time algorithm to compute Steiner -eccentricity of a given fixed -set in a tree T, where n is the order of T.
Proof. By Lemma 6, if , the whole tree T is an optimal solution corresponding to Steiner -eccentricity of R. So it takes -time to earn Steiner -eccentricity.
If , then the Algorithm 2 can be adopted to compute Steiner -eccentricity. Now we analyze the time complexity of Algorithm 2.
Steps 1 and 2 in Algorithm 2 are both BFS procedures on the whole tree T. So Steps 1 and 2 take time. Now let us consider the time consumed by the while-loop in Algorithm 2.
If , the while-loop does not work anymore. It takes time for Algorithm 2. If , in each round of the while-loop, a path is merged into a partial solution. Meanwhile, the array is updated in Step 10. Once a path is merged into a partial solution, every vertex on the path is colored black (see Steps 8–9 in Algorithm 2). Once a leaf and its corresponding path are merged into a partial solution, in the worst case, the distances of the remaining vertices (which are neither in the partial solution nor in the newly merged path) should all be updated by Algorithm 4. In addition, in the worst case, each round of the while-loop only merges one vertex into a partial solution. So, the total number of times the elements in the array needs to be modified is . Thus, the worst case of the whole while-loop takes -time. Thus, it takes time for Algorithm 2.
All in all, there is an -time algorithm to solve the Steiner -eccentricity of a -set in a tree T. □
Algorithm 4: Update(P, , T)
|
| Input: A tree T, a path P and an array |
1 | foreach do ; |
2 | foreach do |
3 | | | ; |
4 | | | ; |
5 | | | Q ← ∅; | | // Initialize an empty queue Q |
6 | | | ; |
7 | | | while do |
8 | | | | | ; |
9 | | | | | foreach do |
10 | | | | | | | if and then |
11 | | | | | | | | | ;
|
12 | | | | | | | | | ;
|
13 | | | | | | | | | ;
|
14 | | | | | end |
15 | | | end |
16 | end |