Abstract
This study deals with the facility location problem of locating a set of facilities on a graph such that the subgraph induced by is connected. We consider the connected median problem on a cactus graph whose vertices and edges have nonnegative weights. The aim of a connected median problem is to minimize the sum of weighted distances from every vertex of a graph to the nearest vertex in . We provide an time algorithm for the connected median problem, where is the number of vertices.
1. Introduction
The median and center problems are central to the field of location theory and logistics and are now well studied in operations research. Applications of the two problems include the location of industrial plants, warehouses, distribution centers, and public service facilities in transportation networks, as well as the location of various facilities in telecommunication networks [1, 2].
To determine the backup sites or to balance the workloads among the center vertices in real networks effectively, Yen and Chen [3] originally proposed the connected center problem and showed that the connected center problem is NPhard on both bipartite graphs and split graphs. Yen [4] studied the connected center problem on block graphs. Bai et al. [5, 6] considered the connected center problem on cactus graphs and devised an algorithm.
Similar to the connected center problem, Shan et al. [7] introduced the connected median problem and considered the connected median problems on interval and circulararc graphs. Kang et al. [8] studied the connected median problem on block graphs and proved that the problem is linearly solvable on block graphs which have unit edge lengths.
In this study, we consider the problem of finding the optimal location of connected median on a cactus graph. The study is organized as follows. In the next section, we formally introduce the notations and the problem that we studied in this study. In Section 3, we study the connected median problem on a cactus graph and devise an algorithm with time complexity of . Finally, we conclude this study.
2. Problem Formulation
Let be a connected graph with vertex set and edge set , where each vertex (or ) has a weight (or ) and each edge has a certain length . For any two vertices , let be the shortest path from to , and be the length of . A vertex set is called a connected vertex set if the induced subgraph of is connected.
A cycle is a sequence of clockwise indexed vertices, such that is an edge, . A graph is called a cactus graph if any two cycles of have at most one vertex in common. The vertex set of a cactus graph can be divided into three disjoint subsets: vertices, vertices, and hinges. A vertex is called a vertex if it is in a cycle of and its degree is 2 in . A vertex is called a hinge if it is in a cycle of and its degree is at least three. A vertex is called a vertex if it is not in a cycle of .
Given a cactus graph , a subtree is a connected subgraph of induced by some vertices and hinges that does not contain any cycle. A subtree is called as a graft if it is maximal and without two hinges belonging to the same cycle. A cycle or a graft is called a block of .
For convenience, we use a tree to represent the skeleton of (Figure 1). Then, we convert into a rooted tree as follows: select an arbitrary block, e.g., , as the “root” of . For each vertex (block or hinge) in , let be the level of . Let be the maximal one of all levels. For each hinge , by deleting the last edge of the path from to , we obtain two subtrees of . Let be the subcacti of induced by the vertices of and all subcacti hanging from it, and let be the subcacti . Note that the father of any block is always a hinge, which is called the block’s companion hinge. For simplicity, we choose an arbitrary vertex as the virtual companion hinge of . Denote by the block if its companion hinge is . Let be the subcactus of induced by the vertices of and all subcacti hanging from , and let be the subcacti . Specially, and .
(a)
(b)
For each vertex set in , let be the sum of weighted distances from all vertices in to , that is,where .
Problem 1. Find a connected vertex set in , such that is minimized. This problem is known as the connected median problem (CpM). The optimal solution is called a connected median of .
Given a graft of and an integer , , for each vertex , the aim of the problem is to find a connected vertex set of , such that is minimized and is the closest vertex to in . We call the corresponding subset as restricted connected median of .
Given a cycle of indexed vertices and an integer , , for any two vertices , the aim of the problem is to find a connected vertex set of , such that is minimized and contains only the vertices of the path from to on in clockwise direction. The corresponding subset is called as restricted clockwise connected median of .
Given a subgraph and an integer , for each hinge of , the aim of the problem is to find a connected vertex set of , such that is minimized. The corresponding subset restricted is called as connected median of .
For all subcacti of , denote by (respectively, ) the possible restricted (restricted clockwise) connected medians (respectively, ). For all hinges of , denote by the possible restricted connected medians . The following lemma establishes a significant relationship between the problems on and all restricted median problems.
Lemma 1. Given a cactus graph , there exists a connected median in .
Proof. Suppose that is the closest vertex to in . Then, could be a vertex, a vertex, or a hinge. We distinguish three cases.
Case 1. Given a graft of and a vertex of , suppose that is a restricted connected median of , then is a feasible solution to the problem, that is,On the other hand, since is also a restricted connected vertex of , we haveThus, , which means is a connected median of .
Case 2. Given a cycle of and two vertices of , . Suppose that includes only the vertices of the path from to on in clockwise direction, and is a restricted clockwise connected median of . Similar as Case 1, we deduce thatThus, , is a connected median of .
Case 3. For the case is a hinge, we distinguish three subcases. Subcase 3.1. The neighbor of is a graft . We can obtain and is a connected median of through the same discussion as in Case 1. Subcase 3.2. The neighbor of is a cycle , and includes the vertices of the path from to on in clockwise direction, . We can obtain and is a connected median of through the same discussion as in Case 2. Subcase 3.3. The neighbor of belongs to more than one block. Assume that is a restricted connected median of . Similar as Case 1, we deduce thatThus, , and is a connected median of .
From the discussion above, there exists a vertexrestricted connected median whose sum of weighted distances of is equal to the sum of weighted distances of a connected median of .
In view of Lemma 1, we will design an algorithm to find all the restricted connected medians in . The algorithm uses the idea of dynamic programming. Traverse the tree “upward,” from the vertices (block or hinge) with higher levels to the vertices with lower levels. An arbitrary order is defined when vertices are with the same levels. In each loop, we select a block or a hinge . If is a graft, we calling program GRAFT to deal with the problem on ; otherwise, we call program CYCLE . When it comes to , we call program HINGE . For the further computations, all useful data are transferred to . When the block has been checked, these data can be used to find a connected median of .
3. Algorithm for the CpM Problem on Cactus Graph
3.1. The Program GRAFT (B,h)
In this subsection, for each graft of and each possible positive integer , our task is to find all restricted connected medians .
Denote by the given graft . Assume that is rooted at the hinge . Denote by . For each vertex , we can obtain two subtrees of by deleting the last edge of the path from to . Let be the subtree that contains , and let . Let and be the subgraphs of corresponding to and , respectively.
For each vertex , let be the edges of that are incident with , and let . After sorting the edges of in an arbitrary order, the ^{th} edge is denoted by . If , then is called as the farther of and is called as the ^{th} of . Let be all sons of . For the subtree , let be the maximal connected subtree that contains but not any edge for . Particularly, and .
For the subgraph , let be the subgraph induced by all vertices of and all subcacti hanging from it. For the subgraph , let be the connected vertex set that contains but not any vertex for . We define the sum of weighted distances of over as follows.
Definition 1. Given a subgraph , the optimal value of is defined aswhere . Let be the corresponding set to .
Once we obtain all values and , the sum of weighted distances from vertices in to can be calculated asFor the block , we first deal with all vertices in . For each vertex , letFor each hinge vertex , let
3.1.1. The Calculation of and
Suppose that, when the phase begins, all values have been calculated for each vertex with level in . In the phase , we search for all vertices of level . For each of these vertices , we first calculate all values by the following method, and then, go to the next vertex with level . If is a vertex or , we start by assigning
If is a hinge such that , we start by assigning
Assuming that, for all , the values have been calculated. Then, the value can be calculated as follows:
For the right side of the above formula, the minimal value of the set inside corresponds to the case , while the value behind corresponds to the case (Figure 2).
If , setwhere and are the corresponding subsets to and , respectively. Otherwise, set
Note that there are at most values which can be calculated by traversing the edges in . Each calculation contains finding the minimum in at most terms. Then, all the values can be computed in time.
3.1.2. The Calculation of
We start by assigning . Suppose that, for all vertices with level in , all values have been calculated when the phase begins. In the phase , we traverse all vertices of level . For each of these vertex , we set and compute as follows:
After all values have been calculated, all values can be calculated by traversing vertices in “downward.” The total calculations take time. Then, all values can be computed by formula (7) in time.
3.2. The Program CYCLE (B,h)
In this subsection, we are given a cycle and the relevant subcactus ; for all pairs and all possible positive numbers , our task is to find all restricted connected medians .
Denote by the . Assume that , and all vertices are indexed in clockwise. For each vertex in , let , where be the subgraph that contains and all subcacti hanging from it, . For any pair , let be the subgraph induced by all vertices of the path from to in clockwise (counterclockwise) direction. Let be the subgraph induced by and all subcacti hanging from it, and let . The calculation of . Given a pair and a integer , denote by the connected vertex set in that includes and . For each integer , , and the sum of the weighted distances of over is defined as
Let be the corresponding set to .
Suppose that the midpoint of the path lies in the edge . In particular, if the midpoint is a vertex, assume it coincides with . By deleting from , we obtain two subgraphs and , which contain and , respectively. Next, we defineto denote the partial sum of the weighted distances to and , respectively.
Once all the values defined above have been computed, we can calculate the sum of the weighted distances of :
We assign .
Given a vertex of . If is a vertex or , we start by assigning
If is a hinge that is not equal to , we start by assigning
Since is a graft, for all and possible numbers , the values can be calculated by running GRAFT on . The computation of the values for all vertices and of takes time.
For the sake of simplicity, we only describe the calculation of , while the values of can be calculated in a similar way.
Note that, for all pair of , the corresponding middle edges can be found by the method similar as in [5] in time. For each edge of , denote by all pairs of vertices of whose middle edge is , where . Let .
By traversing all vertices in , for , all values can be calculated by the following formula:in time. Thus, the calculation of all values takes time.
Last, the value is reassigned as , which can be computed in time. Then, all the values can be computed by formula (18) in time.
3.3. The Program HINGE
In this subsection, we are given a hinge and the relevant subcactus ; for all possible positive integers , our task is to find the restricted connected medians .
Assume that is a hinge of . If is the hinge of the block with a lower level in , then we call as the farther of and as the of . Let be all sons of and . Let be all edges that incident with . By sorting all edges of in an arbitrary order, the ^{th} edge is denoted as . For each subgraph , denote by the maximal connected subgraph that contains and all subcacti hanging from it but not any block for . Particularly, and (Figure 3).
For each subgraph , denote by the connected vertex set that contains but not any vertex of for . Next, we define the optimal value of over .
Definition 2. In subgraph , definewhere . Let be the corresponding set to .
Once we obtain the values , the sum of weighted distances from vertices of to can be calculated asWe assign .
According to our assumption, we obtainand assign
3.3.1. The Calculation of and
Suppose that, when the phase begins, the value or has been calculated for each block of level . In the phase , we search all hinges of level . For each of these hinges , we calculate all values by the following method, and then, go to the next hinge with level .
Assuming that, for all , the values have been calculated. Then, the value can be calculated as follows:if is graft, otherwise,
If is graft, setotherwise, setwhere , , and are the corresponding sets to , , and , respectively.
There are at most values which can be calculated by traversing the edges in . Each calculation contains finding the minimum in at most terms. Then, all the values can be computed in time.
Last, is assigned as , which takes constant time.
3.4. The Procedure HINGE
In this subsection, given a hinge and the relevant subcactus , our task is to calculate the sum of weighted distances from vertices in s to and the total weights of .
3.4.1. The Calculation of and
We start by assigning and . Suppose that, when the phase begins, the value of and has been calculated for each hinge with level . In the phase , we search all hinges of level . For each of these hinges , set
Suppose that in and the hinge of is (Figure 3). Then, can be computed as follows:if is a graft, otherwise,
Note that all values and can be calculated by traversing all vertices of “downward.” The total calculations take time.
3.5. Algorithm for the CpM Problem
According to Lemma 1, we can find a connected median from . The sum of weighted distance from vertices of to can be calculated as
Next, we design Algorithm 1 to solve the problem. For a given cactus graph , as a preprocessing of Algorithm 1, first, the distancematrix of the cactus will be calculated. Then, we construct the rooted skeleton graph of the cactus and calculate maximum level . This preprocessing will be finished in time.
