GRAPH MUTATION, GRAPH DISTANCE, AND GRAPH GRADIENT By Mohammad Hosein Khalifeh A DISSERTATION Submitted to Michigan State University in partial fulfillment of the requirements for the degree of Computer Science โ€“ Doctor of Philosophy 2023 ABSTRACT Most networks constantly change, and predicting links or recovering from link failures is crucial for maintaining a network. Distance-based graph invariants are important criteria for network maintenance. A graph mutation is a change in the edge set of a graph, and a graph gradient is the change in a graph invariant after a mutation. We present the general concepts of discrete integral and derivative for vertex and edge weighted graphs as a tool. Using the concepts, some related problems are solved more efficiently, flexibly, and simpler than the existing solutions. Let ๐บ = (๐‘‰(๐บ), ๐ธ(๐บ)) be a graph with vertex weight function ๐‘“๐บ and edge weight function ๐‘ค๐บ . And ๐‘‘๐บ (๐‘ข, ๐‘ฃ) denotes the distance of ๐‘ข, ๐‘ฃ โˆˆ ๐‘‰(๐บ), the minimum sum of edge weights across all the paths connecting ๐‘ข and ๐‘ฃ. Then assume. ๐‘Š๐›ผ,๐›ฝ (๐บ) = โˆ‘{๐‘ข,๐‘ฃ}โІ๐‘‰(๐บ)[๐›ผ๐‘“๐บ (๐‘ข) ร— ๐‘“๐บ (๐‘ฃ) + ๐›ฝ(๐‘“๐บ (๐‘ข) +๐‘“๐บ (๐‘ฃ))]๐‘‘๐บ (๐‘ข, ๐‘ฃ), ๐›ผ, ๐›ฝ โˆˆ โ„, and ๐‘‡ is a spanning tree (ST) of ๐บ. If an edge ๐‘’ โˆˆ ๐ธ(๐‘‡) fails, it creates ๐‘‡ โˆ’ ๐‘’ with two components. If ๐‘‡ โˆ’ ๐‘’ reconnected with ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) and form ๐‘‡๐œ–\๐‘’ = ๐‘‡ + ๐œ– โˆ’ e such that ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) is minimum, then ๐œ– is a best swap edge (BSE) of ๐‘’ w.r.t ๐‘Š ๐›ผ,๐›ฝ . We devise an algorithm that finds a BSE ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) w.r.t ๐‘Š ๐›ผ,๐›ฝ for each ๐‘’ โˆˆ ๐ธ(๐‘‡) and computes ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ). We call the algorithm โ€œall best swap edges w.r.t. ๐‘Š ๐›ผ,๐›ฝ โ€(ABSEW). Preprocessing for ABSEW takes ๐‘‚(๐‘›)-time, whereas solving ABSEW has an average time- complexity of ๐‘‚((๐‘š โˆ’ ๐‘›)log ๐‘›) and a best time-complexity of ๐‘‚(๐‘š โˆ’ ๐‘›), all in ๐‘‚(๐‘š)-space, where (๐‘š, ๐‘›) = (|๐ธ(๐บ)|, |๐‘‰(๐บ)|). For dense graphs, however, the average time reaches ๐‘‚(๐‘š โˆ’ ๐‘›). ๐‘‡โ€™s routing cost (RC) for a given set of sources ๐‘† โІ ๐‘‰(๐บ) equals โˆ‘(๐‘Ž,๐‘)โˆˆ๐‘‰(๐‘‡)ร—๐‘† ๐‘‘๐‘‡ (๐‘ข, ๐‘ฃ). For 2-edge-connected positively edge-weighted graphs and some specified |๐‘†|, researchers have found a BSE for each edge of an ST w.r.t. RC. The solutions have time complexities of ๐‘‚(๐‘š2๐‘‚(๐›ผ(2๐‘š,2๐‘š)) . log 2 ๐‘›) (|๐‘†| = ๐‘‚(1) or ๐‘›), ๐‘‚(๐‘š. log ๐‘› + ๐‘›2 ) (|๐‘†| = 2), and ๐‘‚(๐‘š๐‘›) (|๐‘†| > 2) for the specified |๐‘†|โ€™s. Our algorithm outperforms existing algorithms regarding RC with no limit on |๐‘†|, edge and vertex weights, or graph type, while also computing the RC for each BSE. Assume ๐‘‡ is a positively weighted ๐‘›-vertex tree, and ๐‘’ โˆˆ ๐ธ(๐‘‡) fails. If we reconnect the components of ๐‘‡ โˆ’ ๐‘’ with ๐œ– โˆˆ ๐ธ(๐‘‡ ๐‘ ) such that, ๐‘Š ๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) is minimum, then ๐œ– is called a best switch (BS) of ๐‘’ w.r.t. ๐‘Š๐›ผ,๐›ฝ . For the inputs ๐‘’ โˆˆ ๐ธ(๐‘‡) and ๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„+ , we find ๐œ–, ๐‘‡๐œ–\๐‘’ , and ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) with the worst average time of ๐‘‚(log ๐‘›) and the best average time of ๐‘‚(1) where ๐œ– is a BS of ๐‘’ w.r.t. ๐‘Š๐›ผ,๐›ฝ and the weight of ๐œ– is ๐‘ค. There are comparable algorithms to ours only w.r.t ๐‘Š1,0 or ๐‘Š 0,1 which are relatively complicated and limited. In our algorithm ๐›ผ, ๐›ฝ can be changed at any step without affecting complexities or preprocessing. A subgraph ๐ป of a simple graph ๐บ is isomeric if ๐‘‘๐บ (๐‘ข, ๐‘ฃ) = ๐‘‘๐ป (๐‘ข, ๐‘ฃ), โˆ€๐‘ข, ๐‘ฃ โˆˆ ๐‘‰(๐ป). And ๐บ is distance-preserving if it has at least a ๐‘˜-vertex isometric subgraph for each ๐‘˜, 1 โ‰ค ๐‘˜ โ‰ค |๐‘‰(๐บ)|. There is a relatively old conjecture by Nussbaum and Esfahanian that ๐‘› says: if deg ๐บ (๐‘ฃ) > 2, โˆ€๐‘ฃ โˆˆ ๐‘‰(๐บ), then G is distance-preserving. We will have a close asymptotic approach to the conjecture. One added edge to a simple graph ๐บ (๐‘ค๐บ = 1) is called inset edge and mutates ๐บ. Establishing some regular and extensive matrix tools, we devised an algorithm that computes and sorts the gradient of the inset edges of a tree regarding the total distance, ๐ท(๐บ) = โˆ‘{๐‘ข,๐‘ฃ}โІ๐‘‰(๐บ) ๐‘‘๐บ (๐‘ข, ๐‘ฃ) for ๐บ. The algorithmsโ€™ average time complexity is minimal, reducing the previous algorithm from ๐‘‚(๐‘›5 ) to an average of ๐‘›2 ๐‘‚(log ๐‘›), where ๐‘› = |๐‘‰(๐บ)|. Indeed, we compute the total distance of ๐‘‚(๐‘›2 ) unicyclic graphs each on average of ๐‘‚(log ๐‘›)-time and the best time of ๐‘‚(1). Copyright by MOHAMMAD HOSEIN KHALIFEH 2023 Dedicated to Mom and Dad v TABLE OF CONTENTS LIST OF ABREVIATIONS ................................................................................... viii LIST OF SYMBOLS.................................................................................................. ix CHAPTER 1: DEFINITIONS AND NOTATIONS ............................................ 1 1.1 Basic Definitions ............................................................................................. 1 1.2 Problems Statement ....................................................................................... 7 1.2.1 Best Swap Edge of Optimal Spanning Trees.......................................... 7 1.2.2 Best Switch Edge of Trees ..................................................................... 9 1.2.3 Distance Preserving Graphs and ๐›ฟ ........................................................ 10 1.2.4 Inset Edge of Trees and Wiener Index .................................................. 11 REFERENCES ................................................................................................... 12 CHAPTER 2: DISCRET CALCULUS .................................................................. 14 2.1 Discrete Derivative ........................................................................................ 15 2.2 Discrete Integral ............................................................................................ 20 APPENDIX......................................................................................................... 22 CHAPTER 3: BEST SWAP EDGE OF OPTIMAL SPANNING TREES.... 25 3.1 Introduction ................................................................................................... 25 3.2 Gradient of Swap Edges ................................................................................ 28 3.3 All BSE Algorithm ........................................................................................ 34 3.4 Examples and ABSEW algorithm for ABSER............................................... 37 REFERENCES ................................................................................................... 39 CHAPTER 4: BEST SWITCH EDGE OF TREES ............................................ 41 4.1 Introduction ................................................................................................... 41 4.2 Main Algorithm for Switch and ๐‘Š๐›ผ,๐›ฝ ............................................................. 44 4.3 Some Comparisons and Discussion ................................................................ 58 REFERENCES ................................................................................................... 60 APPENDIX......................................................................................................... 63 CHAPTER 5: DISTANCE PRESERVING GRAPHS AND ๐œน ........................ 64 5.1 Introduction ................................................................................................... 64 5.2 On Distance Preserving Conjecture ............................................................... 65 REFERENCES ................................................................................................... 68 CHAPTER 6: INSET EDGE OF TREES AND WIENER INDEX ................ 69 6.1 Introduction ................................................................................................... 69 6.2 Main Tools and Preliminary Results ............................................................. 70 vi 6.3 Main Result: An algorithm For Inset Edge of Trees ...................................... 88 6.3.1 Some Tools to Divide and Conquer ...................................................... 88 6.3.2 A Matrix Norm Technique.................................................................... 91 6.3.3 Main Algorithm for Inset Edge of Trees ............................................... 94 6.3.4 Algorithm Complexity and Conclusion ................................................. 98 REFERENCES ................................................................................................. 101 APPENDIX A: EQUATIONS 6-10 TO 6-12 ..................................................... 103 APPENDIX B: THE FORMULAS OF THEOREM 6.6 ................................... 104 APPENDIX C: FOR COROLLARY 6.8 AND THEOREM 6.9 ........................ 107 APPENDIX D: ALGORITHM 6.21 IN pg ........................................................ 109 vii LIST OF ABREVIATIONS ABSER All Best Swap Edges w.r.t. RC ABSEW All Best Swap Edges w.r.t. W ฮฑ,ฮฒ BS Best Switch BSE Best Swap Edge dp distance-preserving dh distance-hereditary ๐‘“๐บโ€ฒ -L ๐‘“๐บโ€ฒ -adjacency list MRCT Minimum Routing Cost Spanning Tree RC Routing Cost sdp sequentially distance-preserving ST Spanning Tree viii LIST OF SYMBOLS ๐‘‰(๐บ) vertex set of ๐บ ๐ธ(๐บ) edge set of ๐บ ๐›ฟ(๐บ) minimum vertex degree of ๐บ โˆ†(๐บ) maximum vertex degree of ๐บ ๐บ[๐‘‹] subgraph of ๐บ induced by ๐‘‹ ๐บ๐‘ complement of ๐บ ๐‘‘๐บ (๐‘ข, ๐‘ฃ) distance of ๐‘ข and ๐‘ฃ in ๐บ ๐‘ƒ๐‘› path of order ๐‘› ๐ถ๐‘› cycle of order ๐‘› ๐‘†๐‘› star graph of order ๐‘› ๐พ๐‘› complete graph of order n ๐‘Š๐›ผ,๐›ฝ (๐บ) generalized weighted total distance of ๐บ ๐บ๐ด\๐ต mutaion of graph ๐บ regarding ๐ด and ๐ต deg ๐บ (๐‘ฃ) vertex ๐‘ฃโ€™s degree in ๐บ ๐‘ƒ๐‘˜ (๐ด) set of ๐‘˜-subsets of ๐ด ๐‘ƒ๐บ (๐‘ข, ๐‘ฃ) path between ๐‘ข and ๐‘ฃ in ๐บ diam(๐บ) diameter of ๐บ โ‰ค isometric subgraph ๐ท๐‘ก (๐บ) total distance of ๐บ ๐ท(๐บ) average distance of ๐บ ๐‘Š(๐บ) Wiener index of ๐บ ๐‘Šร— (๐บ) cross total distance of ๐บ ๐‘Š+ (๐บ) plus total distance of ๐บ ๐‘๐บ (๐‘ฃ) neighborhood of ๐‘ฃ ๐‘๐บ [v] closed neighborhood of ๐‘ฃ ix โ„โ€ฒ gradient of invariant โ„ ๐‘“๐บโ€ฒ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) discrete derivative of vertex ๐‘Ž toward neighbor ๐‘ฅ regarding graph ๐บ. โˆซ๐‘ƒ ๐‘“๐บโ€ฒ ๐‘‘๐บ discrete integral of derivative through path ๐‘ƒ in graph ๐บ ๐‘‡๐‘ฃ๐‘ข component of ๐‘‡ โˆ’ ๐‘ข๐‘ฃ having the vertex ๐‘ฃ for a tree ๐‘‡ ๐‘˜ ๐‘‡๐‘ฅ๐‘ฆ pseudotree made from tree ๐‘‡ with inset edge ๐‘ฅ๐‘ฆ with cycle length ๐‘˜ ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ a vector related to pseudotree ๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ๐‘ฅ๐‘ฆ๐‘พ a matrix related to pseudotree ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ๐‘ญ๐‘˜ a matrix related to pseudotree ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ๐‘ซ๐‘˜ a matrix related to pseudotree ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ๐‘๐บ๐‘ฃ (๐‘ข) relative neighborhood of ๐‘ข compared to ๐‘ฃ in ๐บ โŠš Hadamard matrix product [๐‘Ž โˆง ๐‘ฝ] appending ๐‘Ž as the first entry of a vector ๐‘‰ ๐‘ฝ[๐‘–: ๐‘—] split of vector ๐‘ฝ from index ๐‘– to ๐‘— ๐‘ฝ[๐‘–: ] split of vector ๐‘ฝ from index ๐‘– to end. ๐‘ฝ[: ๐‘–] split of vector ๐‘ฝ from first to index ๐‘– ๐‘ฝ[๐‘–] ๐‘–th entry of vector ๐‘ฝ ๐‘จ[๐‘–: ๐‘—, ๐‘š: ๐‘›] Split of matrix ๐‘จ row from ๐‘– to ๐‘— column ๐‘š to ๐‘› x CHAPTER 1: DEFINITIONS AND NOTATIONS 1.1 Basic Definitions Virtual networks are essential to our daily lives, and graphs are the most used mathematical object for modeling them. Some networks are rapidly changing and maintaining them is a matter of time. Graph theory definitions help to model a network. Definitions and notations that are minimal, indicative, and uniform; help researchers communicate more effectively and address problems faster. This section provides the rest of the sections' general definitions, notations, and terminology. We cover concepts such as distance, graph mutation, graph gradient, and graph invariants. Then we define the swap edge of spanning trees, switch edge of trees, inset edge of graphs, and distance- preserving graphs, as well as the problems we will work on in the following chapters. There will be two more technical concepts, discrete integral and discrete derivative, for weighted graphs, which this thesis defines for the first time. However, we postponed their definitions and the relevant results until the following chapter. They serve as a natural gradient descent on graphs, allowing us to avoid some intermediate tools such as ANN, significantly reducing the time and space complexities of the problems. As the main resources: For chapters 2 and 4 see [18]. Chapter 3 and 5 see [19] and [20], respectively. And chapter 6 is from [21] and [22]. For a set ๐ด, ๐‘ƒ(๐ด) is the power set of ๐ด and ๐‘ƒ๐‘˜ (๐ด) denotes the set of all ๐‘˜-subsets of ๐ด, 0 โ‰ค ๐‘˜ โ‰ค |๐ด|. A graph ๐บ is an ordered pair with the notation ๐บ = (๐‘‰(๐บ), ๐ธ(๐บ)), where ๐‘‰(๐บ) is a set known as the vertex set of ๐บ, and ๐ธ(๐บ) is known as the edge set of ๐บ, a set generated by a relation on ๐‘‰(๐บ) elements. An element of ๐‘‰(๐บ) or ๐ธ(๐บ) is called a vertex or an edge, 1 respectively. A graph ๐บ = (๐‘‰(๐บ), ๐ธ(๐บ)) is a simple graph if ๐ธ(๐บ) โІ ๐‘ƒ2 (๐‘‰(๐บ)). If ๐‘ฅ, ๐‘ฆ โˆˆ ๐‘‰(๐บ) and {๐‘ฅ, ๐‘ฆ} is an edge of ๐บ, we use ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ) instead of {๐‘ฅ, ๐‘ฆ} โˆˆ ๐ธ(๐บ). Moreover, we say ๐‘ฅ and ๐‘ฆ are adjacent if ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ). The complement of a simple graph ๐บ = (๐‘‰(๐บ), ๐ธ(๐บ)) is denoted and defined as follows: ๐บ ๐‘ = (๐‘‰(๐บ), ๐‘ƒ2 (๐‘‰(๐บ)) โˆ’ ๐ธ(๐บ)) The order of a graph is the cardinality of the vertex set, and its edge set's cardinality is called the graph's size. A graph ๐ป is called a subgraph of a graph ๐บ and will be denoted by ๐ป โІ ๐บ if ๐‘‰(๐ป) โІ ๐‘‰(๐บ) and ๐ธ(๐ป) โІ ๐ธ(๐บ). We assign real numbers using some functions to vertices or edges of a graph to make a simple graph vertex-weighted, edge-weighted, or vertex and edge weighted (weighted). We say a graph ๐บ is (๐‘“๐บ , ๐‘ค๐บ )-weighted if it is a weighted graph with a real-valued vertex weight function ๐‘“๐บ and a real-valued edge weight function ๐‘ค๐บ . (โˆ’, ๐‘ค๐บ )-weighted or (๐‘“๐บ , โˆ’)- weighted indicates vertices or edges of ๐บ are not weighted, respectively. If the edges or vertices are not assigned a weight, the weights are assumed to be one. For example, (๐‘“๐บ = 1, ๐‘ค๐บ )-weighted or (๐‘“๐บ , ๐‘ค๐บ = 1)-weighted in notation is equivalent to (โˆ’, ๐‘ค๐บ )-weighted or (๐‘“๐บ , โˆ’)-weighted, respectively. Also, (๐‘“๐บ > 0, ๐‘ค๐บ > 0)-weighted says the relevant weight functions are positive; the graph is positively weighted, etc. Using this notation for consistency in this note, a non-weighted (simple) graph ๐บ is (๐‘“๐บ = 1, ๐‘ค๐บ = 1)-weighted or (โˆ’, โˆ’)-weighted, that is, all weights are equal to 1. In graph ๐บ, a sequence of vertices ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› = ๐‘ƒ๐บ (๐‘ฃ1 , ๐‘ฃ๐‘› ), is a path between ๐‘ฃ1 , ๐‘ฃ๐‘› โˆˆ ๐‘‰(๐บ), if ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 โˆˆ ๐ธ(๐บ), 0 < ๐‘– < ๐‘›. Then, two vertices are connected if there is a path between them. Otherwise, they are disconnected. Similarly, a graph is called connected if at least one path exists between every pair of vertices and is called disconnected; otherwise. A maximal subset of pairwise connected vertices is called a component. Moreover, a graph is ๐‘˜-edge connected if it remains connected if any ๐‘Ÿ < ๐‘˜ number of edges are removed 2 from the graph, ๐‘˜ โˆˆ โ„•. An edge is called a cut edge if removing the edge makes the graph disconnected. In this thesis, unless it is clear from the content, a graph is assumed to be connected. The length of a path ๐‘ƒ๐บ (๐‘ฃ1 , ๐‘ฃ๐‘› ) = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› in a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ is ๐‘›โˆ’1 ๐‘ค๐บ (๐‘ƒ๐บ (๐‘ฃ1 , ๐‘ฃ๐‘› )) = โˆ‘ ๐‘ค๐บ (๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ). ๐‘–=1 The distance between two connected vertices is the length of the paths, with the minimum length between them. And it is infinite if they are disconnected. Moreover, the distance of a vertex with itself is zero. For a graph ๐บ and ๐‘ข, ๐‘ฃ โˆˆ ๐‘‰(๐บ), ๐‘‘๐บ (๐‘ข, ๐‘ฃ) denotes the distance between ๐‘ข and ๐‘ฃ. Note that the defined distance makes a metric space over the set of vertices of a graph if and only if the edge weights are positive. The diameter of a graph ๐บ is defined as follows: diam(๐บ) = max{ ๐‘‘๐บ (๐‘ข, ๐‘ฃ) | {๐‘ข, ๐‘ฃ} โІ ๐‘‰(๐บ) }. Accordingly diam(๐บ) = โˆž if ๐บ is disconnected. The subgraph ๐ป of a graph ๐บ is isometric if the distances in ๐ป remain unchanged, that is ๐‘‘๐ป (๐‘ข, ๐‘ฃ) = ๐‘‘๐บ (๐‘ข, ๐‘ฃ), โˆ€ {๐‘ข, ๐‘ฃ} โІ ๐‘‰(๐ป). If so, then we write ๐ป โ‰ค ๐บ. A sequence ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› ๐‘ฃ1 is called a cycle in a graph ๐บ, if ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is a path and ๐‘ฃ1 ๐‘ฃ๐‘› โˆˆ ๐ธ(๐บ), and its length equals the sum of the weight of the edges on the cycle. The total distance of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ is defined and denoted as follows: ๐ท๐‘ก (๐บ) = โˆ‘ ๐‘‘๐บ (๐‘ข, ๐‘ฃ). {๐‘ข,๐‘ฃ}โІ๐‘‰(๐บ) 3 The Wiener index [1] of a connected simple graph ๐บ, ๐‘Š(๐บ), is equal to ๐ท๐‘ก (๐บ), and the Average distance [2,3] of a connected (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ on ๐‘› vertices is as follows: ๐ท๐‘ก (๐บ) ๐‘› โˆ’1 ๐ท(๐บ) = = ( ) โˆ‘ ๐‘‘๐บ (๐‘ข, ๐‘ฃ). (๐‘›2) 2 {๐‘ข,๐‘ฃ}โІ๐‘‰(๐บ) Definition 1.1: The cross total distance and the plus total distance of a (๐‘“๐บ , ๐‘ค๐บ )- weighted graph ๐บ are defined as follows, respectively: ๐‘Šร— (๐บ) = โˆ‘ [๐‘“๐บ (๐‘ข) ร— ๐‘“๐บ (๐‘ฃ)]๐‘‘๐บ (๐‘ข, ๐‘ฃ), {๐‘ข,๐‘ฃ}โІ๐‘‰(๐บ) ๐‘Š+ (๐บ) = โˆ‘ [๐‘“๐บ (๐‘ข) + ๐‘“๐บ (๐‘ฃ)]๐‘‘๐บ (๐‘ข, ๐‘ฃ). โ–ฒ {๐‘ข,๐‘ฃ}โІ๐‘‰(๐บ) Using the above definitions, ๐‘Š๐›ผ,๐›ฝ (๐บ) = ๐›ผ ๐‘Šร— (๐บ) + ๐›ฝ ๐‘Šร— (๐บ). For a given set of sources ๐‘† โІ ๐‘‰(๐บ), the routing cost (RC) of ๐‘‡ is equal to ๐‘…๐ถ(๐บ, ๐‘†) = โˆ‘ ๐‘‘๐บ (๐‘ข, ๐‘ฃ). (๐‘Ž,๐‘)โˆˆ๐‘‰(๐บ)ร—๐‘† One can see that ๐‘Š๐›ผ,๐›ฝ generalizes ๐‘Šร— , ๐‘Š+ , ๐‘Š, ๐‘…๐ถ, ๐ท๐‘ก , and ๐ท. We also define the ๐‘˜ ๐‘กโ„Ž power of the total distance of ๐บ as follows ๐‘˜ ๐ท๐‘ก (๐บ) = โˆ‘ ๐‘‘๐บ๐‘˜ (๐‘ข, ๐‘ฃ), ๐‘‘ ๐‘˜ (๐‘ข, ๐‘ฃ) = (๐‘‘(๐‘ข, ๐‘ฃ))๐‘˜ . {๐‘ข,๐‘ฃ}โІ๐‘‰(๐บ) The neighborhood, closed neighborhood, and degree of ๐‘ฃ โˆˆ ๐‘‰(๐บ) are denoted and defined as follows, respectively. ๐‘๐บ (๐‘ฃ) = {๐‘ข โˆˆ ๐‘‰(๐บ)|๐‘ข๐‘ฃ โˆˆ ๐ธ(๐บ)}, ๐‘๐บ [๐‘ฃ] = ๐‘๐บ (๐‘ฃ) โˆช {๐‘ฃ}, deg ๐บ (๐‘ฃ) = |๐‘๐บ (๐‘ฃ)|. 4 Using, let ๐›ฟ(๐บ) = min{deg G (๐‘ฃ) | ๐‘ฃ โˆˆ ๐‘‰(๐บ)} and โˆ†(๐บ) = max{deg G (๐‘ฃ) | ๐‘ฃ โˆˆ ๐‘‰(๐บ)}. Also, ๐บ is called ๐‘Ÿ-regular if deg ๐บ (๐‘ฃ) = ๐‘Ÿ, for every ๐‘ฃ โˆˆ ๐‘‰(๐บ), 0 โ‰ค ๐‘Ÿ โ‰ค |๐‘‰(๐บ)|. The distance matrix [4] of a graph ๐บ with ๐‘‰(๐บ) = {๐‘ฃ๐‘– }๐‘›๐‘–=1 denoted with ๐ท๐บ , is an ๐‘› ร— ๐‘› matrix with the ๐‘–๐‘—th entry equal to ๐‘‘๐บ (๐‘ฃ๐‘– , ๐‘ฃ๐‘— ). Thus, 2. ๐ท๐‘ก (๐บ) = โ€–๐ท๐บ โ€– = โˆ‘ ๐‘‘๐‘–๐‘— . Graphs ๐บ and ๐ป are isomorphic if there is a bijective, ๐œ™ โˆถ ๐‘‰(๐บ) โ†” ๐‘‰(๐ป) that preserves the adjacency, that is, if ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ) then ๐œ™(๐‘ฅ)๐œ™(๐‘ฆ) โˆˆ ๐ธ(๐ป). Definition 1.2: A graph invariant is a map from all graphs to a set of arbitrary objects (properties, numbers, etc.) that remains unchanged up to isomorphism between the graphs. In other words, the map โ„: ๐’ข โŸถ ๐’ช from ๐’ข the set of all graphs, to ๐’ช the set of objects, is a graph invariant, if for the isometric graphs ๐บ, ๐ป โˆˆ ๐’ข we have โ„(๐บ) = โ„(๐ป). โ–ฒ A perfect graph invariant โ„ is one in which if ๐บ, ๐ป โˆˆ ๐’ข are not isomorphic, then โ„(๐บ) โ‰  โ„(๐ป). There is no known perfect graph invariant with a polynomial verification complexity. Being Connected is a property base graph invariant. The average distance and Wiener index are numerical graph invariants. The automorphisms group of graphs [5] is an algebraic graph invariant. Also, ๐‘Š๐›ผ,๐›ฝ , ๐‘Šร— , ๐‘Š+ , ๐‘…๐ถ, ๐‘‡๐ท are distance-based numerical graph invariants. A tree is a connected graph that does not have a cycle. It is known that ๐‘‡ is a tree if and only if |๐ธ(๐‘‡)| = |๐‘‰(๐‘‡)| โˆ’ 1 and ๐‘‡ is connected. A vertex with degree one is called a leaf. Here ๐‘ƒ๐‘› and ๐‘†๐‘› denote ๐‘›-vertex trees with two and ๐‘› โˆ’ 1 leaves, respectively. And ๐พ๐‘› Denotes a complete graph on ๐‘› vertices, a graph that all vertices are adjacent. Figure 5 1.1 presents a ๐พ5 , a ๐‘ƒ5 , and a ๐‘†8 from left to right, respectively. Figure 1.1 ๐พ5 , a ๐‘ƒ5 , and a ๐‘†8 A spanning tree (ST) of a graph ๐บ is a tree ๐‘‡ such that ๐‘‡ โІ ๐บ and ๐‘‰(๐‘‡) = ๐‘‰(๐บ). Also, ๐บ[๐‘†] denotes the induced subgraph of ๐บ by ๐‘† โІ ๐‘‰(๐บ), where ๐บ[๐‘†] = ( ๐‘†, {๐‘ข๐‘ฃ โˆˆ ๐ธ(๐บ) | ๐‘ข, ๐‘ฃ โˆˆ ๐‘†} ) = (๐‘‰(๐บ[๐‘†]), ๐ธ(๐บ[๐‘†])). Definition 1.3: A graph mutation is a change in the edge set of a graph. โ–ฒ Note that a graph mutation does not change the vertex set of a graph. If ๐บ is a graph, we may add a set of edges ๐ด to ๐ธ(๐บ) and remove a set of edges ๐ต from ๐ธ(๐บ). If so, we present the related mutation by ๐ด\๐ต and the mutated graph with ๐บ๐ด\๐ต that is ๐บ๐ด\๐ต = (๐‘‰(๐บ), ๐ธ(๐บ) + ๐ด โˆ’ ๐ต). In a mutation ๐ด\๐ต we may specify the scopes of ๐ด and ๐ต. However, generally, the scope of ๐ต is a subset of ๐ธ(๐บ) โˆช โˆ…, and the scope of A is a subset of ๐ธ(๐บ ๐‘ โˆช ๐บ) โˆช โˆ…. The added edge(s) are called inset edge(s), and the removed edge(s) are called extract edge(s). In ๐บ๐ด\๐ต if ๐ต is empty for simplicity, we may use ๐บ๐ด instead of ๐บ๐ด\โˆ… . Definition 1.4: Suppose ๐บ๐ด\๐ต is a mutated graph, and โ„ is a numerical graph invariant. We define the gradient of โ„(๐บ) as follows: โ„โ€ฒ (๐บA\๐ต ) = โ„(๐บ๐ด\๐ต ) โˆ’ โ„(๐บ) . โ–ฒ 6 1.2 Problems Statement By definition, graph invariants present a fixed description of a graph's nature. Specifically, using a proper numerical graph invariant, we can have a frame from the change of graph nature after a mutation. We will use the numerical distance-based graph invariants defined in the past section. The average distance and Wiener index are some of the most studied graph invariants, from molecular chemistry to social networks. Paraffin boiling point can be estimated by the Wiener index of their atomic graph [1]. The average distance in a metabolic network can be used to assess mass transfer efficiency [6]. We will primarily focus on four problems related to graph mutation and distance- based gradients, as detailed in the sections below. Graph gradients and related definitions simplify our expressions and explanations. Most of our algorithms in the following chapters for the problems are dynamic and very efficient. Moreover, the time complexity of our algorithms for the problems depends on the exact topology of the input graphs and often meets the minimal complexities. Since we bring detailed proofs, we do not need experimental aid to prove our problem complexities. However, the algorithm for the last relatively complicated problem is implemented on the pg platform in python. 1.2.1 Best Swap Edge of Optimal Spanning Trees Suppose ๐‘‡ is an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ and ๐‘† โІ ๐‘‰(๐บ) is a set of sources. Finding a minimum routing cost spanning tree (MRCT) is an ๐‘๐‘ƒ-Hard problem if |๐‘†| > 1 and for |๐‘†| = 1 is a polynomial time problem [7]. Therefore, when |๐‘†| > 1, finding a new MRCT once an MRCT link fails is costly. If an MRCT link fails, we will have two components. Researchers propose replacing the broken link with an existing network link that re-connects the components and minimizes the ๐‘…๐ถ [8,9]. The replacement edge that minimizes the ๐‘…๐ถ is called a best swap edge (BSE) of the failed edge, w.r.t ๐‘…๐ถ. A BSE w.r.t ๐‘…๐ถ is indeed a mutation of ๐‘‡ that minimizes the gradient of ๐‘…๐ถ. We generalize BSEs 7 w.r.t ๐‘…๐ถ. Definition 1.5: Suppose ๐‘‡ is an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ and โ„ is a numerical graph invariant. If an edge ๐‘’ โˆˆ ๐ธ(๐‘‡) is removed and the two components of ๐‘‡ โˆ’ ๐‘’ reconnected with a new edge ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) in a way that โ„(๐‘‡ โˆ’ ๐‘’ + ๐œ–) is minimized, then ๐œ– is a best swap edge (BSE) of ๐œ– w.r.t โ„. In our notation ๐œ– is a BSE of ๐‘’ w.r.t โ„ if โ„โ€ฒ(๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘› โ„โ€ฒ(๐‘‡๐‘ \๐‘’ ). โ–ฒ ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) By definition, โ„โ€ฒ(๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘› โ„โ€ฒ(๐‘‡๐‘ \๐‘’ ) โ†” โ„(๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘› โ„(๐‘‡๐‘ \๐‘’ ). ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) Thus, we can use the above point for our invariants interchangeably. Problem 1: Let ๐‘‡ be an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ and ๐›ผ, ๐›ฝ โˆˆ โ„. For each โ€ฒ ๐‘’ โˆˆ ๐ธ(๐‘‡), find a BSE, ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) w.r.t ๐‘Š๐›ผ,๐›ฝ and compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ). In another form: For each ๐‘’ โˆˆ ๐ธ(๐‘‡) โ€ฒ โ€ฒ find ๐œ– such that ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ) ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) โ€ฒ and compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ). We may call the problem all best swap edge w.r.t ๐‘Š๐›ผ,๐›ฝ (ABSEW). โ–ฒ To clarify, if ๐‘’ is a cut edge of ๐บ, ABSEW should return โˆž as the value of ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ) and an arbitrary ๐‘  โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡), as a BSE of ๐‘’. As mentioned, ๐‘Š๐›ผ,๐›ฝ ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) is a generalization for all defined distance-based invariants. We may also discuss another version of problem 1 where ๐‘Š๐›ผ,๐›ฝ is replaced with ๐‘˜๐ท๐‘ก . There are some efficient algorithms that solve a particular version of problem 1 in some limited situations [8,9]. Assume ๐บ is a graph and ๐‘† is a set of sources. The mentioned 8 algorithms solve problem 1 w.r.t ๐‘…๐ถ, a specific case of ๐‘Š๐›ผ,๐›ฝ , when ๐บ is positively edge- weighted 2-edge-connected and only for |๐‘†| = ๐‘‚(1) or |๐‘‰(๐บ)|. Where also do not calculate the relevant ๐‘…๐ถโ€ฒ๐‘ . We solve problem 1 with no limit. Precisely, unlike the mentioned solutions, edge weights can be any real numbers. The vertices will be weighted, and ๐‘…๐ถ is generalized to ๐‘Š๐›ผ,๐›ฝ . In other words, |๐‘†| will have no limit and can be any number from 1 to |๐‘‰(๐บ)|. The โ€ฒ scope of the input graphs is any connected graph. And ๐‘Š๐›ผ,๐›ฝ of BSEs are calculated. Despite those, thanks to some fundamental concepts and related tools created in the next chapter, our solution for problem 1 beats all existing solutions for variations of problem 1. See chapter 3 for details. 1.2.2 Best Switch Edge of Trees Suppose ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree. If ๐‘’ โˆˆ ๐ธ(๐‘‡) is removed, then ๐‘‡ โˆ’ ๐‘’ has two components. We are interested to re-connect the components of ๐‘‡ โˆ’ ๐‘’ with an edge ๐œ– with weight ๐‘ค, (๐œ– โˆˆ ๐ธ(๐‘‡ ๐‘ )) so that for a given ๐›ผ, ๐›ฝ โˆˆ โ„, ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) is minimized. As you see, this is a specific version of BSE problem, where, for example, ๐บ = ๐พ๐‘› and all ๐œ– โˆˆ ๐ธ(๐‘‡ ๐‘ ) = ๐ธ(๐บ)\๐ธ(๐‘‡) are equally weighted. Definition 1.6: Suppose ๐‘‡ is a (๐‘“๐บ , ๐‘ค๐บ )-weighted tree, and โ„ is a graph invariant. If an edge ๐‘’ โˆˆ ๐ธ(๐‘‡) is deleted a new edge ๐œ– โˆˆ ๐ธ(๐‘‡ ๐‘ ) with weight, ๐‘ค is added to ๐‘‡ โˆ’ e such that โ„(๐‘‡๐œ–\๐‘’ ) is minimum, then ๐œ– is a best switch (BS) of ๐œ– w.r.t โ„. And the related mutation ๐œ–\๐‘’ or ๐‘‡๐œ–\๐‘’ is referred to as a switch. In notation, ๐œ– with weight ๐‘ค is a BS of ๐‘’ w.r.t โ„ if โ„โ€ฒ(๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘›๐‘ โ„โ€ฒ(๐‘‡๐‘ \๐‘’ ). โ–ฒ ๐‘ โˆˆ๐ธ(๐‘‡ ) Problem 2: Let ๐‘‡ be a (๐‘“๐บ > 0, ๐‘ค๐บ > 0)-weighted tree. For given ๐‘’ โˆˆ ๐ธ(๐‘‡), ๐‘ค > 0, ๐›ผ, ๐›ฝ โ‰ฅ 0 with ๐›ผ + ๐›ฝ > 0 find a BS, ๐œ–, w.r.t ๐‘Š๐›ผ,๐›ฝ and compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ), where ๐‘ค = ๐‘ค๐‘‡๐œ–\๐‘’ (๐œ–). In notation, 9 Get ๐‘’ โˆˆ ๐ธ(๐‘‡) ๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0 (๐‘ค > 0, ๐›ผ, ๐›ฝ โ‰ฅ 0, and ๐›ผ + ๐›ฝ > 0) โ€ฒ โ€ฒ Find ๐œ– such that ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘›๐‘ ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ), ๐‘ค = ๐‘ค๐‘‡๐œ–\๐‘’ (๐œ–). โ–ฒ ๐‘ โˆˆ๐ธ(๐‘‡ ) As a natural problem on trees, it is expected that there should be some efficient solutions for some versions of the above problem. Using the top tree method [10,11,12], solutions for specific versions of problem 2 with fixed parameters exist. We solve problem 2 for every possible input thanks to discrete integral and derivative. We can also update the parameters during the algorithm with no more average complexity than the best solutions. See chapter 4 for detail. 1.2.3 Distance Preserving Graphs and ๐œน An ๐‘›-vertex graph ๐บ is distance-preserving (dp) if, for any integer ๐‘˜, 1 โ‰ค ๐‘˜ โ‰ค ๐‘›, ๐บ has at least one isometric subgraph of order ๐‘˜[13 ]. And ๐บ is sequentially distance- preserving (sdp) if there exists an ordering (๐‘ฃ1 , ๐‘ฃ2 , โ€ฆ , ๐‘ฃ๐‘› ) of ๐‘‰(๐บ) such that ๐บ\(๐‘ฃ1 , ๐‘ฃ2 , โ€ฆ , ๐‘ฃ๐‘– ) is isometric for each ๐‘–, 1 โ‰ค ๐‘– โ‰ค ๐‘› [13]. If any connected induced subgraph of ๐บ is isometric, then ๐บ is called distance-hereditary (dh)[15]. Clearly, the dp property has the most relaxed condition among dh, sdp, and dp. That help with more application in a dynamic network. Mutating a graph toward dh property for an arbitrarily given graph might be computationally expensive in case of possibility. That is because the dh graphs are very particular. In the case of dp, it can be much easier regarding some results like the one below. 2 Proposition 1.1 [14]: Let ๐บ be an ๐‘›-vertex graph with ๐›ฟ(๐บ) โ‰ฅ 3 ๐‘› โˆ’ 1. Then ๐บ is dp. โ–  However, proposition 1.1 bound is not necessary for being a dp graph, but it is simple to verify. We want to determine whether the above bound can be lowered. That reduces the required number of mutations that convert a graph to a dp graph. In this way, the first step is the following result. 10 ๐‘› Proposition 1.2 ([13,14]): For any integers ๐‘› โ‰ฅ 5, and 2 โ‰ค ๐‘Ÿ < , where ๐‘Ÿ is even, 2 there exists an ๐‘Ÿโ€regular graph on ๐‘› vertices without any isometric subgraph of order ๐‘› โˆ’ 1. โ–  On the other hand, there is a precise conjecture in [14] in response to the above result that we will work on. It is a perfect min-degree criterion that confirms a graph is dp. ๐‘› Problem 3: Let ๐บ be an ๐‘›โ€vertex graph with ๐›ฟ(๐บ) > 2 . Then ๐บ is dp. โ–ฒ 1.2.4 Inset Edge of Trees and Wiener Index If ๐บ is a graph and the inset edge(s) ๐ด โІ ๐‘‰(๐บ) are added to ๐บ, then we have the mutation shown with ๐บ๐ด\โˆ… = ๐บ๐ด . Predicting ๐‘Ÿ, inset edges, which minimize the average distance of a simple graph, is an ๐‘๐‘ƒ-Hard problem [2]. And it is a polynomial-time problem when ๐‘Ÿ = 1. Suppose ๐‘‡ is a simple tree. Adding an edge to ๐‘‡ creates a unicyclic graph, also known as pseudotree. We want to calculate and sort the average distance of all psedutrees out of ๐‘‡. That is, calculate {๐ท(๐‘‡๐‘’ )}๐‘’โˆˆ๐ธ(๐‘‡ ๐‘) and sort it. It allows predicting the link that lowers the average distance of the tree close to what we want. Note that ๐ทโ€ฒ (๐‘‡๐‘’ ) = ๐ท(๐‘‡๐‘’ ) โˆ’ ๐ท(๐‘‡). The main problem around is the following. Problem 4: For a tree ๐‘‡ compute and sort {๐ทโ€ฒ(๐‘‡๐‘’ )}๐‘’โˆˆ๐ธ(๐‘‡ ๐‘) . โ–ฒ We achieve some results on pseudotrees. Then we solve the above problem dynamically in a complex recursive process. We establish some precise matrix tools and strictly avoid extra calculations. In response, we will see that the solution is surprisingly minimal on average, improving some outcomes regarding time complexities in [16]. We also work to find the minimum in the set {๐ทโ€ฒ(๐‘‡๐‘’ )}๐‘’โˆˆ๐ธ(๐‘‡ ๐‘) . There is a heuristic approach for that where ๐‘‡ is replaced with a connected graph [17]. But steel, our exact algorithm is considerably faster for the case of trees. We implement the solution for problem 4. 11 REFERENCES [1] H. Wiener, Structural determination of the paraffin boiling points, J. Am. Chem. Soc., 69 (1947), 17-20. [2] A. Meyerson, B. Tagiku, Minimizing Average Shortest Path Distances via Shortcut Edge Addition, Approximation, randomization, and combinatorial optimization, Algorithms and techniques. 12th international workshop, APPROX 2009, and 13th international workshop, RANDOM 2009, Berkeley, CA, USA, (August 2009). Proceedings (pp.272- 285) [3] D. Bienstock, E. Gyรถri, Average distance in graphs with removed elements, J. of graph theory, 12 (1988), 375-390. [4] Robert W. Floyd, Algorithm 97: Shortest Path, Communications of the ACM 5 345 (June 1962). [5] Norman Biggs, Algebraic Graph Theory, Cambridge Mathematical Libr ary (2nd ed.), Cambridge University Press, (1993), Definition 2.1, p. 7. [6] A. Drger, M. Kronfeld, M. J. Ziller, J. Supper, H. Planatscher, J.B. Magnus, M. Oldiges, O. Kohlbacher, A. Zell, Modeling metabolic networks in C. glutamicum: a comparison of rate laws in combination with various parameter optimization strategies", BMC Syst. Biol., 3 (2009). [7] B. Y. Wu, Approximation algorithms for the optimal p-source communication spanning tree, Discrete App. Math., 143 (2004), 31-42. [8] Davide Biloฬ€1, Feliciano Colella, Luciano Gualaฬ€, Stefano Leucci, Guido Proietti, An Improved Algorithm for Computing All the Best Swap Edges of a Tree Spanner, Algorithmica, 82 (2020), 279-299. [9] B. Y. Wu, C. -Y. Hsiao, Chao, K.-M.: The swap edges of a multiple-sources routing tree, Algorithmica, 50 (2008), 299-311. [10] S. Alstrup, J. Holm, K. de Lichtenberg, M. Thorup, Maintaining information in fully dynamic trees with top trees, ACM Trans. Algorithm, 1 (2005), 243-264. [11] S. Alstrup, J. Holm, M. Thorup, Maintaining center and median in dynamic trees, in: Proc. of the 8th Scandinavian Workshop on Algorithm Theory, (2000), 46-56. 12 [12] Hung-Lung Wang, Maintaining centdians in a fully dynamic forest with top trees, Discrete App. Math., 181 (2015), 310-315. [13] R. Nussbaum, Abdol-Hossein Esfahanian, Preliminary results on distanceโ€preserving graphs, Congressus Numerantium, 211 (2012), 141-149. [14] R. Nussbaum, Distanceโ€Preserving Graphs, Ph.D. Thesis, Diss. Michigan State University, (2014). [15] Hans-Jรผrgen Bandelt, Henry Martyn Mulder, Distance-hereditary graphs, J. Combin. Theory Ser. B, 41 (1986), 182-208 [16] Dennis Ross, Edge impact in graphs and social network matrix completion, Diss. Michigan State University, (2014). [17] Nikos Parotsidis, Evaggelia Pitoura, Panayiotis Tsaparas, Selecting Shortcuts for a Smaller World, Proceedings of the 2015 SIAM International Conference on Data Mining, (2015), 28-36. [18] M. H. Khalifeh, Abdol-Hossein, Discrete Integral and Discrete Derivative on Graphs and Switch problems of Trees, Mathematics, Advances in Graph Theory: Algorithms and Applications, 11 (2023), 1678. [19] M. H. Khalifeh, Emad Zahedi, On a conjecture about the existence of isometric subgraphs, J. Graph Theory, 94 (2020), 299-302. [20] M. H. Khalifeh, Abdol-Hossein Esfahanian, A Faster Algorithm for Finding Best Swap Edges of multiple-source Routing Tree, Netwotks, under review [21] M. H. Khalifeh, Abdol-Hossein Esfahanian, Some results about the inset edge and average distance of trees, Disc. Appl. Math., 325 (2023), 186-199. [22] M. H. Khalifeh, Abdol-Hossein Esfahanian, A Fast Algorithm for Sorting Inset Edges Effect On The Average Distance Of A Tree, submitted 13 CHAPTER 2: DISCRET CALCULUS This brief section contains key notions that will be used in the two following chapters. It helps to lower the time and space complexities of the relevant algorithms significantly. Consider ๐บ to be a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph, ๐ด, ๐ต โІ ๐‘‰(๐บ), and ๐‘ฃ โˆˆ ๐‘‰(๐บ). We define ๐‘“๐บ (๐ด) = โˆ‘ ๐‘“๐บ (๐‘ฅ), ๐œŽ๐บ (๐‘ฃ) = โˆ‘ ๐‘‘๐บ (๐‘ฃ, ๐‘ฅ) , โ„Ž๐บ (๐‘ฃ) = โˆ‘ ๐‘“๐บ (๐‘ฅ)๐‘‘๐บ (๐‘ฃ, ๐‘ฅ), ๐‘ฅโˆˆ๐ด ๐‘ฅโˆˆ๐‘‰(๐บ) ๐‘ฅโˆˆ๐‘‰(๐บ) ๐‘‘๐บ (๐ด, ๐ต) = โˆ‘ โˆ‘ ๐‘‘๐บ (๐‘Ž, ๐‘). ๐‘Žโˆˆ๐ด๐‘โˆˆ๐ต In addition, for the given subgraphs ๐ป and ๐พ of ๐บ let ๐‘‘๐บ (๐ป, ๐พ) = โˆ‘ โˆ‘ ๐‘‘๐บ (๐‘ข, ๐‘ฃ), ๐‘“๐บ (๐ป) = โˆ‘ ๐‘“๐บ (๐‘Ž). ๐‘ข โˆˆ ๐‘‰(๐ป) ๐‘ฃ โˆˆ ๐‘‰(๐พ) ๐‘Žโˆˆ๐‘‰(๐ป) Definition 2.1: For a tree ๐‘‡ and ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), ๐‘‡ โˆ’ {๐‘ข๐‘ฃ} has two components. We name the components ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข with ๐‘ข โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฃ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). As an extension for the later ๐‘ฆ notation to subtrees, if ๐‘ฅ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ), [๐‘‡๐‘ข๐‘ฃ ] ๐‘ฅ and [๐‘‡๐‘ข๐‘ฃ ] ๐‘ฆ๐‘ฅ denotes the components of ๐‘‡๐‘ข๐‘ฃ โˆ’ {๐‘ฅ๐‘ฆ} and so on. Also, set ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) = |๐‘‰(๐‘‡๐‘ข๐‘ฃ )| and ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) = |๐‘‰(๐‘‡๐‘ฃ๐‘ข )|. โ–ฒ Using the above notations, ๐‘‰(๐‘‡) = ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) โˆช ๐‘‰(๐‘‡๐‘ฃ๐‘ข ) and ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) + ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) = |๐‘‰(๐‘‡)|. In plain language ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) and ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) are the number of vertices in ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข , respectively. Also, ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) and ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) are the total weight of vertices in ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข , respectively. 14 2.1 Discrete Derivative Definition 2.2: Suppose ๐บ is a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph. The discrete derivative of a vertex ๐‘Ž โˆˆ ๐‘‰(๐บ) toward a neighbor ๐‘ฅ โˆˆ ๐‘๐บ (๐‘ฃ) is defined and denoted as follows: ๐‘“๐บ (๐‘ฅ) โˆ’ ๐‘“๐บ (๐‘Ž) ๐‘‘๐บ (๐‘ฅ, ๐‘Ž) โ‰  0, ๐‘‘๐บ (๐‘ฅ, ๐‘Ž) ๐‘“๐บโ€ฒ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = (2.1) { ๐‘“๐บ (๐‘ฅ) โˆ’ ๐‘“๐บ (๐‘Ž) ๐‘‘๐บ (๐‘ฅ, ๐‘Ž) = 0. We say ๐‘“๐บโ€ฒ is consistent if ๐‘‘๐บ (๐‘ฅ, ๐‘Ž) = 0 results in ๐‘“๐บโ€ฒ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = 0, ๐‘Ž๐‘ฅ โˆˆ ๐ธ(๐บ). โ–ฒ Figure 2.1 A weighted graph on five vertices 4โˆ’3 1 Using the above image as graph ๐บ, ๐‘“๐บโ€ฒ (a๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = = 3 where ๐‘‘๐บ (๐‘ฅ, a) = 3. And ๐‘“๐บโ€ฒ (๐‘ฅa โƒ—โƒ—โƒ—โƒ— ) = 3 3โˆ’4 1 3 = โˆ’ 3. Lemma 2.3: Assume ๐‘“1 an ๐‘“2 are two vertex weight functions for a graph. If ๐‘“ = ๐›ผ๐‘“1 + ๐›ฝ๐‘“2 , then ๐‘“ โ€ฒ = ๐›ผ๐‘“1โ€ฒ + ๐›ฝ๐‘“2โ€ฒ , where ๐›ผ, ๐›ฝ โˆˆ โ„. Moreover, if ๐‘“1 an ๐‘“2 are consistence, then ๐‘“ also is. โ–  A path ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is called ๐‘“๐บ -decreasing if it is a path and ๐‘“๐บ (๐‘ฃ๐‘–+1 ) < ๐‘“๐บ (๐‘ฃ๐‘– ), 0 < ๐‘– < ๐‘›. An ๐‘“๐บ -increasing path is defined in the same sense. Clearly, if ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is a ๐‘“๐บ - decreasing path and edge weights are positive, then ๐‘“๐บโ€ฒ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ) < 0, 0 < ๐‘– < ๐‘›. โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— 15 Definition 2.4: Suppose ๐บ is a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph. Then, ๐‘ฃ โˆˆ ๐‘‰(๐บ) is called ๐‘“๐บ - Root or ๐‘“๐บ -Roof of ๐บ if ๐‘“๐บ (๐‘ฃ) is minimum or maximum, respectively. Let ๐ด โŠ‚ ๐‘‰(๐บ) is the set of ๐‘“๐บ -Roots (๐‘“๐บ -Roofs) of ๐บ. Then we say ๐บ is ๐‘“๐บ -convex (concave) if and only if for every ๐‘ฃ โˆˆ ๐‘‰(๐บ) there is a decreasing (increasing) path from ๐‘ฃ to some ๐‘Ž โˆˆ ๐ด. โ–ฒ Whenever there is no confusion, we may use Root instead of, ๐‘“๐บ -Roots, etc. Using figure 2.1, the vertex with weight 0 is a Root, and the vertex with weight 4 is a Roof in the depicted graph. To employ discrete derivatives as a tool, we first create some induced weight functions for the vertices using the current weight of the graph of an (๐‘“๐บ , ๐‘ค๐บ )-weighted graph, ๐บ. The first one is as follows: ๐œŽ๐บ : ๐‘‰(๐บ) โ†’ โ„ S. t. ๐œŽ๐บ (๐‘ฃ) = โˆ‘ ๐‘‘๐บ (๐‘ฃ, ๐‘ฅ) , ๐‘ฃ โˆˆ ๐‘‰(๐บ) ๐‘ฅโˆˆ๐‘‰(๐บ) Let ๐‘‡ be a (๐œŽ๐‘‡ , ๐‘ค๐‘‡ )-weighted tree (that is, the vertex-weight function is ๐œŽ๐‘‡ ). By definition, if ๐‘Ž๐‘ฅ โˆˆ ๐ธ(๐‘‡) and ๐‘ค๐บ (๐‘Ž๐‘ฅ) = 0, then ๐œŽ๐‘‡โ€ฒ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = 0, otherwise: ๐œŽ๐‘‡ (๐‘ฅ) โˆ’ ๐œŽ๐‘‡ (๐‘Ž) ๐œŽ๐‘‡ (๐‘ฅ) โˆ’ ๐œŽ๐‘‡ (๐‘Ž) ๐œŽ๐‘‡โ€ฒ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = = = ๐‘›๐‘‡ (๐‘‡๐‘Ž๐‘ฅ ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ฅ๐‘Ž ). (2.2) ๐‘‘๐‘‡ (๐‘ฅ, ๐‘Ž) ๐‘ค(๐‘Ž๐‘ฅ) Because ๐œŽ๐‘‡ (๐‘ฅ) โˆ’ ๐œŽ๐‘‡ (๐‘Ž) = ๐‘ค(๐‘Ž๐‘ฅ)[๐‘›๐‘‡ (๐‘‡๐‘Ž๐‘ฅ ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ฅ๐‘Ž )]. (2.3) Another vertex-weight function for ๐บ is induced using the primary weight functions ๐‘“๐บ as follows: โ„Ž๐บ : ๐‘‰(๐บ) โ†’ โ„ S. t. โ„Ž๐บ (๐‘ฃ) = โˆ‘ ๐‘“๐บ (๐‘ฅ)๐‘‘๐บ (๐‘ฃ, ๐‘ฅ) , ๐‘ฃโˆˆ๐บ ๐‘ฅโˆˆ๐‘‰(๐บ) To help with the computation of โ„Žโ€ฒ๐‘‡ s for a (โ„Ž๐‘‡ , ๐‘ค๐‘‡ )-weighted tree ๐‘‡ let ๐‘Ž โˆˆ ๐‘‰(๐‘‡) and ๐‘ฅ be an ๐‘Žโ€™s neighbor. Thus, 16 โ„Ž๐‘‡ (๐‘Ž) = โˆ‘ ๐‘“๐‘‡ (๐‘ฃ)๐‘‘ ๐‘‡ (๐‘Ž, ๐‘ฃ) + โˆ‘ ๐‘“๐‘‡ (๐‘ฃ)[๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฃ) + ๐‘ค(๐‘Ž๐‘ฅ)], ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘Ž๐‘ฅ ) ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘ฅ๐‘Ž ) โ„Ž๐‘‡ (๐‘ฅ) = โˆ‘ ๐‘“๐‘‡ (๐‘ฃ)[๐‘‘๐‘‡ (๐‘Ž, ๐‘ฃ) + ๐‘ค(๐‘Ž๐‘ฅ)] + โˆ‘ ๐‘“๐‘‡ (๐‘ฃ)๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฃ). ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘Ž๐‘ฅ ) ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘ฅ๐‘Ž ) Using the above equations โ„Ž๐‘‡ (๐‘ฅ) โˆ’ โ„Ž๐‘‡ (๐‘Ž) = ๐‘ค(๐‘ข๐‘ฃ)[๐‘“๐‘‡ (๐‘‡๐‘Ž๐‘ฅ ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฅ๐‘Ž )]. (2.4) Therefore, if ๐‘ค๐‘‡ (๐‘Ž๐‘ฅ) = 0, then โ„Žโ€ฒ๐‘‡ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = 0, otherwise: โ„Ž๐‘‡ (๐‘ฅ) โˆ’ โ„Ž๐‘‡ (๐‘Ž) ๐‘ค(๐‘Ž๐‘ฅ)[๐‘“๐‘‡ (๐‘‡๐‘Ž๐‘ฅ ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฅ๐‘Ž )] โ„Žโ€ฒ๐‘‡ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = = = ๐‘“๐‘‡ (๐‘‡๐‘Ž๐‘ฅ ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฅ๐‘Ž ). (2.5) ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘Ž) ๐‘ค(๐‘Ž๐‘ฅ) According to equations 2.3 and 2.4; โ„Žโ€ฒ๐‘‡ and ๐œŽ๐‘‡โ€ฒ are consistent for any tree ๐‘‡. Based on the facts stated above, we get the following results. Let ๐‘๐‘‡ = {(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) and ๐น๐‘‡ = {(๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) . Using equations 2.2, 2.5, ๐น๐‘‡ , and ๐‘๐‘‡ , one can compute ๐œŽ๐‘‡โ€ฒ and โ„Žโ€ฒ๐‘‡ easily. If ๐‘“๐‘‡ (๐‘ฃ) = 1 for every ๐‘ฃ โˆˆ ๐‘‰(๐‘‡), then (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )) = ((๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )) for every ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡). The following algorithm extracts ๐น๐‘‡ for a tree ๐‘‡, start with the edges adjacent to a leaf and then delete the leaves at each step until the edge set is empty. It is linear regarding the number of vertices and uses the fact that for every ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) + ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) = ๐‘“๐‘‡ (๐‘‡), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) = ๐‘“๐‘‡ (๐‘ฃ) + โˆ‘๐‘ฅโˆˆ๐‘๐‘‡ (๐‘ฃ)\๐‘ข ๐‘“๐‘‡ (๐‘‡๐‘ฅ๐‘ฃ ). Algorithm 2.5: Input: Adjacency list of an ๐‘›-vertex, nontrivial (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree ๐‘‡ and ๐‘“๐‘‡ (๐‘‡) Output: ๐น๐‘‡ = {(๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) Initiate with ๐‘† = {๐‘Ž โˆˆ ๐‘‰(๐‘‡) | deg(๐‘Ž) = 1} 17 ๐–๐ก๐ข๐ฅ๐ž (๐ธ(๐‘‡) โ‰  ๐œ™) ๐ฟ๐‘’๐‘Ž๐‘ฃ๐‘’๐‘  โ† ๐‘† ๐‘†=๐œ™ ๐…๐จ๐ซ ๐‘ฃ โˆˆ ๐‘™๐‘’๐‘Ž๐‘ฃ๐‘’๐‘  ๐‘ข โ† ๐‘(๐‘ฃ) (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )) โ† (๐‘“๐‘‡ (๐‘‡) โˆ’ ๐‘“๐‘‡ (๐‘ฃ), ๐‘“๐‘‡ (๐‘ฃ)) ๐‘“๐‘‡ (๐‘ข)+= ๐‘“๐‘‡ (๐‘ฃ) ๐ข๐Ÿ deg(๐‘ข) โˆ’ 1 = 1. #Will be a leaf ๐‘† = ๐‘† โˆช {๐‘ข} ๐‘‡ = ๐‘‡ โˆ’ {๐‘ฃ} #Remove ๐‘ฃ from adj list โ–  Corollary 2.6: For an ๐‘›-vertex tree ๐‘‡, the sets, ๐‘๐‘‡ and, ๐น๐‘‡ can be computed in ๐‘‚(๐‘›)- time. โ–  Assume ๐บ is a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph with the adjacency list ๐ฟ. Sort ๐‘๐บ (๐‘Ž) according to the values of ๐‘“๐บโ€ฒ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ), ๐‘ฅ โˆˆ ๐‘๐‘‡ (๐‘Ž), and update ๐ฟ accordingly for each ๐‘Ž โˆˆ ๐‘‰(๐บ). The updated ๐ฟ is then called the ๐‘“๐บโ€ฒ -adjacency list (๐‘“๐บโ€ฒ -๐ฟ) of ๐บ. The sorting is set to ascending order by default. By corollary 2.6 we have the following. Corollary 2.7: Let ๐‘‡ be a (๐‘“๐‘‡ = ๐›ผ๐œŽ๐‘‡ + ๐›ฝโ„Ž๐‘‡ , ๐‘ค๐‘‡ )-weighted tree, ๐›ผ, ๐›ฝ โˆˆ โ„, with ๐‘› vertices and an adjacency list, ๐ฟ. Then, the ๐‘“๐‘‡โ€ฒ -๐ฟ of ๐‘‡ can be formed in ๐‘‚(โˆ‘๐‘ฃโˆˆ๐‘‰(๐‘‡) deg (๐‘ฃ)log deg(๐‘ฃ))-time which is ๐‘‚(๐‘›)-time on average. โ–  The following result gives us an important fact about the weighted trees. Lemma 2.8: Suppose ๐‘ƒ = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› , ๐‘› > 2, is a path in a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree ๐‘‡. If ๐‘ค๐‘‡ > 0 and ๐œŽ๐‘‡โ€ฒ (๐‘ฃ 1 ๐‘ฃ2 ) โ‰ฅ 0, then ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is, ๐œŽ๐‘‡ -increasing. If ๐‘“๐‘‡ > 0, ๐‘ค๐‘‡ > 0, and โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— โ„Žโ€ฒ๐‘‡ (๐‘ฃ 1 ๐‘ฃ2 ) โ‰ฅ 0, then ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘›+1 is, โ„Ž ๐‘‡ -increasing. If ๐‘”๐‘‡ = ๐›ผ๐œŽ๐‘‡ + ๐›ฝโ„Ž ๐‘‡ , (for ๐›ผ, ๐›ฝ โˆˆ โ„ , ๐›ผ + ๐›ฝ โ‰  โ‰ฅ0 โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— 0) ๐‘“๐‘‡ > 0, ๐‘ค๐‘‡ > 0, and ๐‘”๐‘‡โ€ฒ (๐‘ฃ 1 ๐‘ฃ2 ) โ‰ฅ 0, then ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is, ๐‘”๐‘‡ -increasing. โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— Proof: Assume ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree and ๐‘ฅ๐‘ฆ๐‘ง is a path in ๐‘‡. Without loss of generality, we prove the lemma for ๐‘ฅ๐‘ฆ๐‘ง. We know that ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) โˆช ๐‘‰(๐‘‡๐‘ฃ๐‘ข ) = ๐‘‰(๐‘‡) and ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) โˆฉ 18 ๐‘‰(๐‘‡๐‘ฃ๐‘ข ) = โˆ… for any ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡). Thus, for some ๐ด โŠ‚ ๐‘‰(๐‘‡), ๐‘ฆ ๐‘‰(๐‘‡๐‘ฆ๐‘ง ) = ๐‘‰(๐‘‡๐‘ฅ ) โˆช {๐‘ฆ} โˆช ๐ด, (2.6) And ๐‘ฆ ๐‘‰(๐‘‡๐‘ง ) = ๐‘‰(๐‘‡๐‘ฆ๐‘ฅ ) โˆ’ {๐‘ฆ} โˆ’ ๐ด. (2.7) Therefore, ๐‘ฆ ๐‘ฆ ๐‘‰(๐‘‡๐‘ฅ ) โŠ‚ ๐‘‰(๐‘‡๐‘ฆ๐‘ง ) and ๐‘‰(๐‘‡๐‘ฆ๐‘ฅ ) โŠƒ ๐‘‰(๐‘‡๐‘ง ). (2.8) We use equations 2.2 and 2.5 for computing ๐œŽ๐‘‡โ€ฒ and โ„Žโ€ฒ๐‘‡ . Then by the assumption ๐‘ฆ ๐‘ฆ โƒ—โƒ—โƒ—โƒ— ) = ๐‘›๐‘‡ (๐‘‡๐‘ฅ ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ) โ‰ฅ 0. Thus by Eq. 2.6 ๐œŽ๐‘‡โ€ฒ (๐‘ฆ๐‘ง ๐œŽ๐‘‡โ€ฒ (๐‘ฅ๐‘ฆ โƒ—โƒ—โƒ—โƒ— ) = ๐‘›๐‘‡ (๐‘‡๐‘ฆ๐‘ง ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ง ) > 0. Since ๐‘ค๐‘‡ > 0, ๐‘ค(๐‘ฆ๐‘ง)๐œŽ๐‘‡โ€ฒ (๐‘ฆ๐‘ง โƒ—โƒ—โƒ—โƒ— ) > 0. That is, ๐œŽ๐‘‡ (๐‘ง) > ๐œŽ๐‘‡ (๐‘ฆ) which completes the proof for ๐œŽ๐‘‡ case. ๐‘ฆ Similarly, assume โ„Žโ€ฒ๐‘‡ (๐‘ฅ๐‘ฆ โƒ—โƒ—โƒ—โƒ— ) = ๐‘“๐‘‡ (๐‘‡๐‘ฅ ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ) โ‰ฅ 0. If ๐‘“๐‘‡ > 0, by Eq. 2.6 โ„Žโ€ฒ๐‘‡ (๐‘ฆ๐‘ง โƒ—โƒ—โƒ—โƒ— ) = ๐‘“๐‘‡ (๐‘‡๐‘ฆ๐‘ง ) โˆ’ ๐‘ฆ ๐‘“๐‘‡ (๐‘‡๐‘ง ) > 0. If, in addition ๐‘ค๐‘‡ > 0, then ๐‘ค(๐‘ฆ๐‘ง)โ„Žโ€ฒ๐‘‡ (๐‘ฆ๐‘ง โƒ—โƒ—โƒ—โƒ— ) > 0. Thus, by definition 2.2, โ„Ž๐‘‡ (๐‘ง) > โ„Ž๐‘‡ (๐‘ฆ). That completes the proof for โ„Ž๐‘‡ case. The proof for the ๐‘”๐‘‡โ€ฒ case is like โ„Žโ€ฒ๐‘‡ case. This completes the proof. โ–  Using lemma 2.8, we have the following result about the convexity of a tree. Theorem 2.9: Any positively edge-weighted tree is ๐œŽ-convex, and any positively weighted tree is (๐›ผ๐œŽ + ๐›ฝโ„Ž)-convex, for ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0. Proof: Let us have a positively edge-weighted tree with at least three vertices. Assume a vertex, ๐‘ฃ1 , is not a ๐œŽ-Root and ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is the shortest possible path (in terms of the number of edges) between ๐‘ฃ1 and a ๐œŽ-Root, ๐‘ฃ๐‘› . Assume toward a contradiction that ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is not decreasing. Thus, suppose ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 is the first edge from ๐‘ฃ1 toward ๐‘ฃ๐‘› , such that ๐œŽ(๐‘ฃ๐‘– ) โ‰ค ๐œŽ(๐‘ฃ๐‘–+1 ). Since the edge weights are positive, ๐œŽ โ€ฒ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ) โ‰ฅ 0. Then, by โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— lemma 2.8, the path ๐‘ฃ๐‘–+1 ๐‘ฃ๐‘–+2 โ€ฆ ๐‘ฃ๐‘› is increasing. That is, ๐œŽ(๐‘ฃ๐‘– ) โ‰ค ๐œŽ(๐‘ฃ๐‘› ) and ๐‘– < ๐‘›. If ๐œŽ(๐‘ฃ๐‘– ) = ๐œŽ(๐‘ฃ๐‘› ), ๐‘ฃ๐‘– also is a ๐œŽ- Root and ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘– is shorter than ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› while having the same specification, which is a contradiction with ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› being the shortest. And if, 19 ๐œŽ(๐‘ฃ๐‘– ) < ๐œŽ(๐‘ฃ๐‘› ), contradicts with, ๐‘ฃ๐‘› being a ๐œŽ-Root. Therefore, ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is decreasing. Since ๐‘ฃ1 was arbitrary, the tree is ๐œŽ-convex. For the proof of ๐›ผ๐œŽ + ๐›ฝโ„Ž case, use the same strategy as for ๐œŽ, along with the positivity of the verticesโ€™ weight. โ–  Corollary 2.10: Assume that ๐‘” = ๐›ผ๐œŽ + ๐›ฝโ„Ž, ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0 . Then, a positively weighted tree has at most two ๐‘”-Roots. If ๐‘ฅ and ๐‘ฆ are two ๐‘”-Roots of a tree, then they are adjacent, and ๐‘”โ€ฒ (๐‘ฅ๐‘ฆ โƒ—โƒ—โƒ—โƒ— ) = 0. Moreover, if ๐‘ is, a treeโ€™s ๐‘”-Root and ๐‘ฃ is a non-Root neighbor โƒ—โƒ—โƒ—โƒ— ) = ๐‘”โ€ฒ (๐‘ฆ๐‘ฅ of ๐‘, then ๐‘”โ€ฒ (๐‘๐‘ฃ โƒ—โƒ—โƒ—โƒ— ) > 0, and ๐‘”โ€ฒ (๐‘ฃ๐‘ โƒ—โƒ—โƒ—โƒ— ) < 0. Usefully, if ๐‘ƒ = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘š is a decreasing path between ๐‘ฃ1 and a ๐‘”-Root, ๐‘ฃ๐‘š , then ๐‘”โ€ฒ(๐‘ฃ ๐‘– ๐‘Ž ) < 0 if and only if ๐‘Ž = ๐‘ฃ๐‘–+1 , ๐‘– < ๐‘š. In addition, โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ƒ is the longest ๐‘”-decreasing path starting from ๐‘ฃ1 . Finally, a leaf is not a (๐›ผ๐œŽ + ๐›ฝโ„Ž)- Root of a positively weighted tree with more than 2 vertices. โ–  By corollary 2.10, we have the following. For proof, see the appendix of this chapter. Lemma 2.11: Assume ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ > 0)-weighted tree, and we have ๐œŽ๐‘‡โ€ฒ -๐ฟ. Then the path between any pair ๐‘Ž, ๐‘ โˆˆ ๐‘‰(๐‘‡), ๐‘ƒ๐‘‡ (๐‘Ž, ๐‘), can be computed in the minimal time of ๐‘‚(|๐‘ƒ๐‘‡ (๐‘Ž, ๐‘)|). โ–  Note that |๐‘ƒ๐‘‡ (๐‘Ž, ๐‘)| refers to the number of edges on ๐‘ƒ๐‘‡ (๐‘Ž, ๐‘). 2.2 Discrete Integral Definition 2.12: Suppose ๐บ is a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph. Regarding ๐‘“๐บโ€ฒ and ๐‘‘๐บ (distance function) we define and denote the discrete integral of ๐‘“๐บโ€ฒ along a path ๐‘ƒ = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› from ๐‘ฃ1 to ๐‘ฃ๐‘› as follows: ๐‘›โˆ’1 โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = โˆ‘ ๐‘“๐บโ€ฒ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ). ๐‘‘๐บ (๐‘ฃ๐‘– , ๐‘ฃ๐‘–+1 ) . โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— โ–ฒ ๐‘ƒ ๐‘–=1 If ๐‘Ž, ๐‘ โˆˆ ๐‘‰(๐บ) and ๐‘ƒ๐บ (๐‘Ž, ๐‘) is an arbitrary path between ๐‘Ž and ๐‘, we denote โˆซ๐‘ƒ๐บ(๐‘Ž,๐‘) ๐‘“๐บโ€ฒ ๐‘‘๐บ as follows ๐‘ โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ ๐‘Ž 20 By definitions 2.2 and 2.12, we have: Theorem 2.13: Suppose ๐บ is a connected (๐‘“๐บ , ๐‘ค๐บ )-weighted graph and ๐‘Ž, ๐‘ โˆˆ ๐‘‰(๐บ). If ๐‘“๐บโ€ฒ is consistent, then for any path from ๐‘Ž to ๐‘ ๐‘ โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = ๐‘“๐บ (๐‘) โˆ’ ๐‘“๐บ (๐‘Ž). โ–  ๐‘Ž Using figure 2.1 as graph ๐บ with the given weights and the above result vs. definition 2.12, one can see that, ๐‘ฆ โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ ๐‘ฅ ๐‘ƒ=๐‘ฅ๐‘Ž๐‘ฆ ๐‘ƒ=๐‘ฅ๐‘Ž๐‘๐‘ฆ ๐‘ƒ=๐‘ฅ๐‘Ž๐‘๐‘๐‘ฆ ๐‘ƒ=๐‘ฅ๐‘๐‘๐‘ฆ ๐‘ƒ=๐‘ฅ๐‘๐‘Ž๐‘ฆ =โˆซ ๐‘“๐บโ€ฒ ๐‘‘๐บ = โˆ’2 ๐‘ƒ=๐‘ฅ๐‘๐‘Ž๐‘๐‘ฆ 21 APPENDIX Proof of lemma 2.12: Without loss of generality, assume ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ = 1)- weighted tree with at least three vertices, and we have ๐œŽ๐‘‡โ€ฒ -๐ฟ. Then, by theorem 2.9, ๐‘‡ is ๐œŽ๐‘‡ -convex. So, there is a decreasing path, ๐‘ƒ๐‘‡ (๐‘Ž1 , ๐‘Ž๐‘Ÿ ) = ๐‘Ž1 ๐‘Ž2 โ€ฆ ๐‘Ž๐‘Ÿ , between any ๐‘Ž1 โˆˆ ๐‘‰(๐‘‡) and a ๐œŽ๐‘‡ - Root of ๐‘‡, say ๐‘Ž๐‘Ÿ . By corollary 2.10, ๐œŽ๐‘‡โ€ฒ (๐‘Ž โƒ—โƒ—โƒ—โƒ—โƒ—๐‘– ๐‘ ) < 0 if and only if ๐‘  = ๐‘Ž๐‘–+1 and in addition ๐‘ƒ๐‘‡ (๐‘Ž1 , ๐‘Ž๐‘Ÿ ) is the longest possible decreasing path starting from ๐‘Ž1 . We know that the neighbors of a vertex in a ๐œŽ๐‘‡โ€ฒ -๐ฟ are sorted w.r.t. the values of ๐œŽ๐‘‡โ€ฒ . Therefore, if ๐‘ is the first neighbor of ๐‘Ž๐‘– in a ๐œŽ๐‘‡โ€ฒ -๐ฟ and ๐œŽ๐‘‡โ€ฒ (๐‘Ž โƒ—โƒ—โƒ—โƒ—โƒ—๐‘– ๐‘ ) < 0, then ๐‘ = ๐‘Ž๐‘–+1 , otherwise, ๐‘Ž๐‘– = ๐‘Ž๐‘Ÿ . Let ๐‘ฅ1 , ๐‘ฆ1 โˆˆ ๐‘‰(๐‘‡) and ๐‘ƒ๐‘ฅ = ๐‘ฅ1 ๐‘ฅ2 โ€ฆ ๐‘ฅ๐‘š and ๐‘ƒ๐‘ฆ = ๐‘ฆ1 ๐‘ฆ2 โ€ฆ ๐‘ฆ๐‘› be the paths connecting ๐‘ฅ1 and ๐‘ฆ1 and some ๐œŽ๐‘‡ -Roots, ๐‘ฅ๐‘š and ๐‘ฆ๐‘› . So, getting ๐‘ฅ1 , ๐‘ฆ1 , and ๐œŽ๐‘‡โ€ฒ -๐ฟ we can proceed toward ๐‘ฅ๐‘š and ๐‘ฆ๐‘› , vertex by vertex, with the cost of only one derivative per progress. To find ๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 ) start with ๐‘ฅ1 and ๐‘ฆ1 and proceed with one vertex on ๐‘ƒ๐‘ฅ , then proceed with one vertex on ๐‘ƒ๐‘ฆ , then one on ๐‘ƒ๐‘ฅ and then one on ๐‘ƒ๐‘ฆ and so on. But break the process once the first common vertex is obtained. Also, if we reach a ๐œŽ๐‘‡ - Root on one of ๐‘ƒ๐‘ฅ or ๐‘ƒ๐‘ฆ , we stop there and continue on the other until we either get a common vertex or a ๐œŽ๐‘‡ -Root is obtained. If we get a common vertex, let the vertex be ๐‘ฅ๐‘– = ๐‘ฆ๐‘— , 1 โ‰ค ๐‘– โ‰ค ๐‘š, 1 โ‰ค ๐‘— โ‰ค ๐‘›. So, ๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 ) = ๐‘ฅ1 โ€ฆ ๐‘ฅ๐‘– ๐‘ฆ๐‘—โˆ’1 โ€ฆ ๐‘ฆ1 . Clearly, |๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 )| โ‰ค 2max{๐‘–, ๐‘—} โ‰ค 2|๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 )|. That is, we used no more than 2|๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 )| derivatives to get the common vertex ๐‘ฅ๐‘– = ๐‘ฆ๐‘— . Thus, we got ๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 ) in ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 )|)-time. On the other hand, if ๐‘ƒ๐‘ฅ and ๐‘ƒ๐‘ฆ do not intersect, by corollary 2.10, the two ๐œŽ๐‘‡ -Roots, ๐‘ฅ๐‘š and ๐‘ฆ๐‘› , are adjacent and ๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 ) = ๐‘ฅ1 ๐‘ฅ2 โ€ฆ ๐‘ฅ๐‘š ๐‘ฆ๐‘› โ€ฆ ๐‘ฆ2 ๐‘ฆ1 which has been obtained with less than ๐‘š + ๐‘› + |๐‘š โˆ’ ๐‘›| derivatives. This completes the proof. โ–  Algorithm 2.14 for a resolution of the above proof. Algorithm 2.14: Input: A tree ๐‘‡ and ๐œŽ๐‘‡โ€ฒ -๐ฟ for ๐‘ค๐‘‡ = 1 (edge weights are all 1) Output: Takes ๐‘ฅ1 , ๐‘ฆ1 โˆˆ ๐‘‰(๐‘‡) and returns ๐‘ƒ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 ) Initiate ๐‘ƒ๐‘ฅ = ๐‘ฅ1 , ๐‘ƒ๐‘ฆ = ๐‘ฆ1 , ๐‘ฅ๐‘– = ๐‘ฅ1 , ๐‘ฆ๐‘— = ๐‘ฆ1, ๐‘†๐‘ก๐‘œ๐‘๐‘‹ = 1, ๐‘†๐‘ก๐‘œ๐‘๐‘Œ = 1 22 ๐‘พ๐’‰๐’Š๐’๐’† (๐‘†๐‘ก๐‘œ๐‘๐‘‹ โ‰  0 ๐จ๐ซ ๐‘†๐‘ก๐‘œ๐‘๐‘Œ โ‰  0) { ๐’Š๐’‡ ๐‘†๐‘ก๐‘œ๐‘๐‘‹ โ‰  0{ ๐’Š๐’‡ ๐œŽ๐‘‡โ€ฒ (๐‘ฅ ๐‘– ๐‘ฃ ) < 0, โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— # ๐‘ฃ is the first neighbor in the list of ๐‘ฅ๐‘– in ๐œŽ๐‘‡โ€ฒ -L {๐‘ฅ๐‘–+1 โ† ๐‘ฃ ๐‘ƒ๐‘ฅ = ๐‘ƒ๐‘ฅ + ๐‘ฅ๐‘–+1 ๐‘ฅ๐‘– โ† ๐‘ฅ๐‘–+1 ๐’Š๐’‡ ๐‘™๐‘Ž๐‘๐‘๐‘™๐‘’(๐‘ฅ๐‘– ) == ๐‘ฆ { # that is, ๐‘ƒ๐‘ฅ intersects with ๐‘ƒ๐‘ฆ ๐‘“๐‘–๐‘Ÿ๐‘ ๐‘ก_๐‘ โ„Ž๐‘Ž๐‘Ÿ๐‘’ = ๐‘ฅ๐‘– # from ๐‘ƒ๐‘ฅ ๐‘๐‘Ÿ๐‘’๐‘Ž๐‘˜ } ๐‘™๐‘Ž๐‘๐‘™๐‘’(๐‘ฅ๐‘– ) = ๐‘ฅ } } ๐’†๐’๐’”๐’† ๐‘†๐‘ก๐‘œ๐‘๐‘‹ = 0 # that is, we reach a ๐œŽ๐‘‡ -Root ๐’Š๐’‡ ๐‘†๐‘ก๐‘œ๐‘๐‘Œ โ‰  0{ ๐’Š๐’‡ ๐œŽ๐‘‡โ€ฒ (๐‘ฆ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘— ๐‘ฃ ) < 0, # ๐‘ฃ is the first neighbor in the list of ๐‘ฆ๐‘– in ๐œŽ๐‘‡โ€ฒ -L { ๐‘ฆ๐‘—+1 โ† ๐‘ฃ ๐‘ƒ๐‘ฆ = ๐‘ƒ๐‘ฆ + ๐‘ฆ๐‘—+1 ๐‘ฆ๐‘— โ† ๐‘ฆ๐‘—+1 ๐’Š๐’‡ ๐‘™๐‘Ž๐‘๐‘๐‘™๐‘’(๐‘ฆ๐‘—+1 ) == ๐‘ฅ { # that is ๐‘ƒ๐‘ฆ intersects with ๐‘ƒ๐‘ฅ ๐‘“๐‘–๐‘Ÿ๐‘ ๐‘ก_๐‘ โ„Ž๐‘Ž๐‘Ÿ๐‘’ = ๐‘ฆ๐‘— # from ๐‘ƒ๐‘ฆ ๐‘๐‘Ÿ๐‘’๐‘Ž๐‘˜ } ๐‘™๐‘Ž๐‘๐‘™๐‘’(๐‘ฆ๐‘— ) = ๐‘ฆ } } ๐’†๐’๐’”๐’† ๐‘†๐‘ก๐‘œ๐‘๐‘Œ = 0 } # that is, we reach a ๐œŽ๐‘‡ -Root 23 ๐’Š๐’‡ ๐‘“๐‘–๐‘Ÿ๐‘ ๐‘ก_๐‘ โ„Ž๐‘Ž๐‘Ÿ๐‘’ = ๐‘ฅ๐‘– from ๐‘ƒ๐‘ฅ ๐’“๐’†๐’•๐’–๐’“๐’ ๐‘ƒ๐‘ฅ + ๐‘ฆ๐‘—โˆ’1 โ€ฆ ๐‘ฆ1 # ๐‘ƒ๐‘ฅ intersects with ๐‘ƒ๐‘ฆ ๐’Š๐’‡ ๐‘“๐‘–๐‘Ÿ๐‘ ๐‘ก_๐‘ โ„Ž๐‘Ž๐‘Ÿ๐‘’ = ๐‘ฆ๐‘— from ๐‘ƒ๐‘ฆ ๐’“๐’†๐’•๐’–๐’“๐’ ๐‘ฅ1 โ€ฆ ๐‘ฅ๐‘–โˆ’1+ ๐‘Ÿ๐‘’๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘’ ๐‘œ๐‘“ ๐‘ƒ๐‘ฆ # ๐‘ƒ๐‘ฆ intersects with ๐‘ƒ๐‘ฅ ๐’“๐’†๐’•๐’–๐’“๐’ ๐‘ƒ๐‘ฅ + ๐‘Ÿ๐‘’๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘’ ๐‘œ๐‘“ ๐‘ƒ๐‘ฆ # no common vertex โ–  24 CHAPTER 3: BEST SWAP EDGE OF OPTIMAL SPANNING TREES 3.1 Introduction A network's survivability is its ability to recover communication if a network link fails [12]. Techniques for addressing network survivability generally involve ST of the network [2,3,7,10,15,16]. Given a network modeled as a graph ๐บ, the routing cost (RC) of an ST of ๐บ when a subset of nodes, say ๐‘†, are used as sources is the total distances in the tree from each source to all nodes in the network [20]. Finding a minimum routing cost spanning tree (MRCT) is an ๐‘๐‘ƒ-Hard problem if |๐‘†| > 1 [21]. When |๐‘†| = 1, the problem can be solved in polynomial time [21]. For more details and a survey on MRCT, see [20,22,24]. Thus, for |๐‘†| > 1, finding a new MRCT once an MRCT link fails is costly. If an MRCT link fails, we will have two components. As a quick heuristic fix for the time- sensitive networks, it is proposed that the broken link be replaced with an existing network link that reconnects the components and minimizes the ๐‘…๐ถ [5,23]. The replacement edge that minimizes the ๐‘…๐ถ was called a BSE of the failed edge w.r.t ๐‘…๐ถ in chapter 1 and, indeed, forms a mutation. In [5,23], some algorithms are provided to find a BSE for each edge of an ST regarding ๐‘…๐ถ (ABSER). Suppose ๐บ is a positively edge-weighted and 2-edge-connected graph with ๐‘š edges and ๐‘› vertices. Then, there is an ๐‘‚(๐‘š. 2๐‘‚(๐›ผ(2๐‘š,2๐‘š)) . log ๐Ÿ ๐‘› )-time algorithm for ABSER, ๐‘˜ ๐‘™๐‘œ๐‘”๐›ผ(2๐‘š,2๐‘š)) where |๐‘†| = ๐‘‚(1) or |๐‘†| = ๐‘›, and ๐‘‚(๐‘š. ๐‘˜. 2๐‘‚(๐›ผ(2๐‘š,2๐‘š) . log ๐Ÿ ๐‘› )-time otherwise [5]. (The notation ๐›ผ(๐‘›, ๐‘›) denotes the inverse of the Ackermann function [1]). For ABSER, there are also ๐‘‚(๐‘š. log ๐‘› + ๐‘›2 ) and ๐‘‚(๐‘š๐‘›) time algorithms where |๐‘†| = 2 and |๐‘†| > 2, respectively [23]. All these solutions require that the graph be positively edge weighted. By allowing the weight function to be arbitrary, we extend the ABSER problem and 25 provide a computationally more efficient solution than the current techniques. Our solution takes on average ๐‘‚((๐‘š โˆ’ ๐‘›). log ๐‘›)-time and at best ๐‘‚(๐‘š โˆ’ ๐‘›)-time, with edge weights that can be real ((+โˆž, โˆ’โˆž)) and 0 < |๐‘†| โ‰ค ๐‘› (no restriction on |๐‘†|). Moreover, our algorithm works for some generalizations of ๐‘…๐ถ as well, where the graphs are also vertex weighted. See table 3.1 and the last section for more details. See [4,8,9,11,13,17] for more information on BSE and ST problems. We indeed want to solve the following, introduced as problem 1 in chapter 1. For each ๐‘’ โˆˆ ๐ธ(๐‘‡) find one ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) such that ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ) and compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ). ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) The problem was called โ€œall best swap edges w.r.t ๐‘Š๐›ผ,๐›ฝ โ€ (ABSEW). Using the same language, ABSER is defined as follows, where ๐‘…๐ถ(๐‘‡, ๐‘†) = โˆ‘(๐‘Ž,๐‘)โˆˆ๐‘‰(๐‘‡)ร—๐‘† ๐‘‘๐บ (๐‘ข, ๐‘ฃ) is the RC of ๐‘‡ for some given sources ๐‘† โІ ๐‘‰(๐‘‡). For each ๐‘’ โˆˆ ๐ธ(๐‘‡) find one ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) such that ๐‘…๐ถ(๐‘‡๐œ–\๐‘’ , ๐‘†) = ๐‘š๐‘–๐‘› ๐‘…๐ถ(๐‘‡๐‘ \๐‘’ , ๐‘†). ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) We devise an algorithm for ABSEW with an average time of ๐‘‚((๐‘š โˆ’ ๐‘›). log ๐‘›), a best time of ๐‘‚(๐‘š โˆ’ ๐‘›), and a preprocessing time of ๐‘‚(๐‘›), where there are ๐‘š edges and ๐‘› vertices. The algorithm takes up no more than ๐‘‚(๐‘š)-space and works for any connected weighted graph with real edge and vertex weight functions. For the cut edges, see the explanation after the ABSEW definition at the end of this section. By showing that ABSER is a subset of ABSEW, our algorithm outperforms ABSERโ€™s existing algorithms with no restrictions on the number of sources(|๐‘†|), graph type, and edge weights. ABSEW 26 also computes the ๐‘…๐ถ of ๐‘› minimal trees of BSEs, whereas ABSER does not. The table below compares the algorithms for ABSER. Table 3.1 ABSER algorithms: Complexities Comparison Edges Prep Source Edge Time Complexity for ABSER Graph Scope ๐‘› Vertices Time Number Weights [5]โ€™s ๐‘‚(๐‘š. 2๐‘‚(๐›ผ(2๐‘š,2๐‘š)) . log ๐Ÿ ๐‘› ) ๐‘‚(๐‘š) |๐‘†| = ๐‘‚(1) (0,+โˆž) 2-edge connected Algorithm [5]โ€™s ๐‘‚(๐‘š. 2๐‘‚(๐›ผ(2๐‘š,2๐‘š)) . log ๐Ÿ ๐‘› ) ๐‘‚(๐‘š) |๐‘†| = ๐‘› (0,+โˆž) 2-edge connected Algorithm [5]โ€™s ๐‘‚(๐‘š. ๐‘˜. 2๐‘‚(๐›ผ(2๐‘š,2๐‘š) ๐‘˜ ๐‘™๐‘œ๐‘”๐›ผ(2๐‘š,2๐‘š)) . log ๐Ÿ ๐‘› ) ๐‘‚(๐‘š) |๐‘†| = ๐‘˜ (0,+โˆž) 2-edge connected Algorithm [23]โ€™s ๐‘‚(๐‘š๐‘›) ๐‘‚(๐‘›2 ) |๐‘†| > 2 (0,+โˆž) 2-edge connected Algorithm [23]โ€™s ๐‘‚(๐‘š. log ๐‘› + ๐‘›2 ) ๐‘‚(๐‘›2 ) |๐‘†| = 2 (0,+โˆž) 2-edge connected Algorithm Our ABSEW ๐‘‚(๐‘š โˆ’ ๐‘›) (Best) ๐‘‚(๐‘›) 0 < |๐‘†| โ‰ค ๐‘› (-โˆž,+โˆž) Connected Algorithm ๐‘‚((๐‘š โˆ’ ๐‘›). log ๐‘›) (Av.) Problem 1 (ABSEW): Let ๐‘‡ be an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ and ๐›ผ, ๐›ฝ โˆˆ โ€ฒ โ„. For each ๐‘’ โˆˆ ๐ธ(๐‘‡), find a BSE, ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) w.r.t ๐‘Š๐›ผ,๐›ฝ and compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ). For each ๐‘’ โˆˆ ๐ธ(๐‘‡) โ€ฒ โ€ฒ find ๐œ– such that ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) = ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ) ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) โ€ฒ and compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ). We call the problem all best swap edge w.r.t ๐‘Š๐›ผ,๐›ฝ (ABSEW). โ–ฒ Note that if ๐‘’ โˆˆ ๐ธ(๐‘‡) is a cut edge of ๐บ, then ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ) = โˆž. Thus, any ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) ๐œ– โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) can be a BSE of ๐‘’. Given that ABSEW should return โˆž as the value of ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ) and an arbitrary ๐‘  โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡), as a BSE of ๐‘’. ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) 27 3.2 Gradient of Swap Edges In this section, we will use chapter 2 results to develop an algorithm for ABSEW. The first one says how to calculate the gradient of ๐‘Šร— regarding a sawp edge mutation. Lemma 3.1: Assume that ๐‘‡ is an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ with ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ). If ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ), then ๐‘ฅ ๐‘ฆ ๐‘Šร—โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข ) (โˆซ โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ ) + ๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ ) (โˆซ โ„Žโ€ฒ๐‘‡๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข ) ๐‘ข ๐‘ฃ +๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข )๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ )[๐‘ค๐บ (๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค๐บ (๐‘ข๐‘ฃ)]. Proof: Assume we have the lemma assumptions. Then we can rewrite ๐‘Šร— (๐‘‡) as follows ๐‘Šร— (๐‘‡) = ๐‘Šร— (๐‘‡๐‘ข๐‘ฃ ) + ๐‘Šร— (๐‘‡๐‘ฃ๐‘ข ) + โˆ‘ โˆ‘ [๐‘“๐บ (๐‘Ž)๐‘“๐บ (๐‘)][๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘Ž) + ๐‘ค๐บ (๐‘ฅ๐‘ฆ) + ๐‘‘ ๐‘‡ (๐‘, ๐‘ฆ)] ๐‘Žโˆˆ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) ๐‘โˆˆ๐‘‰(๐‘‡๐‘ฃ๐‘ข ) = ๐‘Šร— (๐‘‡๐‘ข๐‘ฃ ) + ๐‘Šร— (๐‘‡๐‘ฃ๐‘ข ) + ๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข )โ„Ž๐‘‡๐‘ข๐‘ฃ (๐‘ฅ) + ๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ )โ„Ž๐‘‡๐‘ฃ๐‘ข (๐‘ฆ) + ๐‘ค๐บ (๐‘ฅ๐‘ฆ)๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ )๐‘“(๐‘‡๐‘ฃ๐‘ข ). Using the trick that ๐‘Šร— (๐‘‡๐‘ข๐‘ฃ\๐‘ข๐‘ฃ ) = ๐‘Šร— (๐‘‡) and the above formula ๐‘Šร—โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Šร— (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) โˆ’ ๐‘Šร— (๐‘‡) = ๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข ) (โ„Ž ๐‘‡๐‘ข๐‘ฃ (๐‘ฅ ) โˆ’ โ„Ž ๐‘‡๐‘ข๐‘ฃ (๐‘ข)) + ๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ ) (โ„Ž ๐‘‡๐‘ฃ๐‘ข (๐‘ฆ) โˆ’ โ„Ž ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ)) + ๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข )(๐‘ค๐บ (๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค๐บ (๐‘ข๐‘ฃ)). In chapter 2, we saw that โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ and โ„Žโ€ฒ๐‘‡๐‘ฃ๐‘ข are consistent. So we can use theorem 2.13 in the above equation, that is ๐‘ฅ ๐‘ฆ ๐‘Šร—โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข ) (โˆซ โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ ๐‘‘๐‘‡๐‘ข๐‘ฃ ) + ๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ ) (โˆซ โ„Žโ€ฒ๐‘‡๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข ) ๐‘ข ๐‘ฃ + ๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข )๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ )[๐‘ค๐บ (๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค๐บ (๐‘ข๐‘ฃ)]. โ–  We obtain the following lemma using a method like the proof of lemma 3.1. 28 Lemma 3.2: Assume ๐‘‡ is an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ, ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ). If ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ), then ๐‘ฅ ๐‘ฆ ๐‘ฅ ๐‘Š+โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘›๐‘‡ (๐‘‡๐‘ฃ ) (โˆซ โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ ๐‘‘๐‘‡๐‘ข๐‘ฃ ) ๐‘ข + ๐‘›๐‘‡ (๐‘‡๐‘ข ) (โˆซ โ„Žโ€ฒ๐‘‡๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข ) ๐‘ฃ + ๐‘“๐บ (๐‘‡๐‘ฃ ) (โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ ) ๐‘ข ๐‘ข ๐‘ฃ ๐‘ข ๐‘ฆ + ๐‘“๐บ (๐‘‡๐‘ข ) (โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข ) ๐‘ฃ + [๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐‘“๐บ (๐‘‡๐‘ข๐‘ฃ ) ๐‘ฃ + ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐บ (๐‘‡๐‘ฃ๐‘ข )][๐‘ค๐บ (๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค๐บ (๐‘ข๐‘ฃ)]. โ–  ๐‘ฆ Lemma 3.3: Let ๐‘‡ be a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡) with ๐‘‡ โˆ’ {๐‘ฅ๐‘ฆ} = ๐‘‡๐‘ฅ โˆช ๐‘‡๐‘ฆ๐‘ฅ . If we have {(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) , we can calculate ๐œŽ๐‘‡โ€ฒ ๐‘ฆ and โ„Žโ€ฒ๐‘‡ ๐‘ฆ ๐‘ฅ ๐‘ฅ ๐‘ฆ on the path from ๐‘ฅ toward any vertex of ๐‘‡๐‘ฅ . A similar argument applies to the paths from ๐‘ฆ toward any vertex of ๐‘‡๐‘ฆ๐‘ฅ . ๐‘ฆ Proof: Suppose ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡) with ๐‘‡ โˆ’ {๐‘ฅ๐‘ฆ} = ๐‘‡๐‘ฅ โˆช ๐‘‡๐‘ฆ๐‘ฅ . ๐‘ฆ Also, suppose ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is a path in ๐‘‡๐‘ฅ where ๐‘ฃ1 = ๐‘ฅ. Using equations 2.2 and 2.5 and {(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) we could extract ๐œŽ๐‘‡โ€ฒ and โ„Žโ€ฒ๐‘‡ through the edges of ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› . However, we require to get ๐œŽ๐‘‡โ€ฒ ๐‘ฆ and โ„Žโ€ฒ๐‘‡ ๐‘ฆ through that path. To do so, one ๐‘ฅ ๐‘ฅ can check for the edges on ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› that: ๐‘ฆ ๐‘ฃ ๐‘ฆ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘› ๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–+1 ๐‘– ), ๐‘› ๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–๐‘–+1 )) = (๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 )โˆ’๐‘›๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )), 0 < ๐‘– < ๐‘›, (3.1) ๐‘ฅ ๐‘ฅ ๐‘ฆ ๐‘ฃ ๐‘ฆ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘“๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–+1 ๐‘– ), ๐‘“ ๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–๐‘–+1 )) = (๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )) , 0 < ๐‘– < ๐‘›. (3.2) ๐‘ฅ ๐‘ฅ If ๐‘ค๐‘‡ (๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ) = 0, then by equations 2.1, 2.3, and 2.4 ๐œŽ๐‘‡โ€ฒ ๐‘ฆ (๐‘ฃ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— โ€ฒ ๐‘– ๐‘ฃ๐‘–+1 ) = โ„Ž ๐‘‡ ๐‘ฆ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ) = 0, โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ ๐‘ฅ 0 < ๐‘– < ๐‘›. Otherwise, by equations 2.1, 2.2, 2.5, 3.1, and 3.2, ๐‘ฃ ๐‘ฃ ๐œŽ๐‘‡โ€ฒ ๐‘ฆ (๐‘ฃ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘–+1 ๐‘ฅ ๐‘– ๐‘– ๐‘ฃ๐‘–+1 ) = ๐‘› ๐‘‡ (๐‘‡๐‘ฃ๐‘– ) โˆ’ ๐‘› ๐‘‡ (๐‘‡๐‘ฆ ) โˆ’ ๐‘› ๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ) = ๐œŽ๐‘‡ (๐‘ฃ โ€ฒ ๐‘ฅ ๐‘– ๐‘ฃ๐‘–+1 ) โˆ’ ๐‘› ๐‘‡ (๐‘‡๐‘ฆ ), 0 < ๐‘– < ๐‘›, (3.3) โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ ๐‘ฃ ๐‘ฃ โ„Žโ€ฒ๐‘‡๐‘ฆ (๐‘ฃ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘–+1 ๐‘ฅ ๐‘– ๐‘– ๐‘ฃ๐‘–+1 ) = ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘– ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ) = โ„Ž ๐‘‡ (๐‘ฃ โ€ฒ ๐‘ฅ ๐‘– ๐‘ฃ๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ ), 0 < ๐‘– < ๐‘›. (3.4) โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ 29 That is, we can calculate ๐œŽ๐‘‡โ€ฒ ๐‘ฆ and โ„Žโ€ฒ๐‘‡ ๐‘ฆ using ๐‘ฅ ๐‘ฅ {(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) . Similarly, we can achieve symmetric arguments and equations regarding ๐‘ฆ and ๐‘‡๐‘ฆ๐‘ฅ . โ–  Lemma 3.3 has a relevant corollary. Corollary 3.4: Let ๐‘‡ be a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree, ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ), and ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). Then ๐‘ฅ ๐‘ฅ ๐‘ฆ ๐‘ฆ ๐‘ฆ โˆซ โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ ๐‘‘๐‘‡๐‘ข๐‘ฃ =โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ โˆ’ ๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฅ). ๐‘“๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ), โˆซ โ„Žโ€ฒ๐‘‡๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ โˆ’ ๐‘‘ ๐‘‡ (๐‘ฃ, ๐‘ฆ). ๐‘“๐‘‡ (๐‘‡๐‘ฅ ), ๐‘ข ๐‘ข ๐‘ฃ ๐‘ฃ And, ๐‘ฅ ๐‘ฅ ๐‘ฆ ๐‘ฆ ๐‘ฆ โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ =โˆซ ๐œŽ๐‘‡โ€ฒ ๐‘‘๐‘‡ โˆ’ ๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฅ). ๐‘›๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ), โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข = โˆซ ๐œŽ๐‘‡โ€ฒ ๐‘‘๐‘‡ โˆ’ ๐‘‘ ๐‘‡ (๐‘ฃ, ๐‘ฆ). ๐‘›๐‘‡ (๐‘‡๐‘ฅ ). ๐‘ข ๐‘ข ๐‘ฃ ๐‘ฃ Proof: Assume ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree and ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) with ๐‘‡ โˆ’ {๐‘ข๐‘ฃ} = ๐‘‡๐‘ข๐‘ฃ โˆช ๐‘‡๐‘ฃ๐‘ข . If ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ), ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ), and ๐‘ƒ ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ) = ๐‘ข1 ๐‘ข2 โ€ฆ ๐‘ข๐‘› (so ๐‘ข1 = ๐‘ข and ๐‘ข๐‘› = ๐‘ฅ), then by the definition of integral, lemma 3.3 Eq. 3.4, consistency of โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ , and the fact that ๐‘‘ ๐‘‡๐‘ฃ๐‘ข = ๐‘‘ ๐‘‡ on ๐‘‡๐‘ข๐‘ฃ : ๐‘ฅ ๐‘›โˆ’1 ๐‘›โˆ’1 โˆซ โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ = โˆ‘ โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ (๐‘ข ๐‘– ๐‘ข๐‘–+1 ). ๐‘‘ ๐‘‡๐‘ข๐‘ฃ (๐‘ข๐‘– , ๐‘ข๐‘–+1 ) = โˆ‘ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— (โ„Žโ€ฒ๐‘‡ (๐‘ข ๐‘ฅ ๐‘– ๐‘ข๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ )). ๐‘‘ ๐‘‡ (๐‘ข๐‘– , ๐‘ข๐‘–+1 ) โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ข ๐‘–=1 ๐‘–=1 ๐‘ฅ ๐‘›โˆ’1 = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ) โˆ‘ ๐‘‘ ๐‘‡ (๐‘ข๐‘– , ๐‘ข๐‘–+1 ). ๐‘ข ๐‘–=1 By definition of distance on ๐‘‡, โˆ‘๐‘›โˆ’1 ๐‘–=1 ๐‘‘ ๐‘‡ (๐‘ข๐‘– , ๐‘ข๐‘–+1 ) = ๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฅ). Therefore, ๐‘ฅ ๐‘ฅ โˆซ โ„Žโ€ฒ๐‘‡๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ โˆ’ ๐‘‘๐‘‡ (๐‘ข, ๐‘ฅ). ๐‘“๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ). ๐‘ข ๐‘ข We proved the first equation. The proof of the other equations is identical. โ–  30 Definition 3.5: Suppose ๐บ is an ๐‘›-vertex graph with an ST, ๐‘‡. Then let ๐ถ(๐‘‡๐‘ข๐‘ฃ , ๐‘‡๐‘ฃ๐‘ข ) = { ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ)\{๐‘ข๐‘ฃ} | ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฆ โˆˆ ๐‘‰( ๐‘‡๐‘ฃ๐‘ข )} . โ–ฒ In addition, label the edges of ๐‘‡ arbitrarily from 1 to ๐‘› โˆ’ 1, and let ๐‘™(๐‘’) denote the label of ๐‘’ โˆˆ ๐ธ(๐‘‡), 1 โ‰ค ๐‘™(๐‘’) โ‰ค ๐‘› โˆ’ 1. Now initiate a data structure of length ๐‘› โˆ’ 1 named, ๐ธ๐ฟ๐‘‡ , as follows: ๐ธ๐ฟ๐‘‡ = { (โˆ…\๐‘’, โˆž) | ๐‘’ โˆˆ ๐ธ(๐‘‡) } . With access to the ๐ธ๐ฟ๐‘‡ values as follows: (We used current values as an example) ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘’)] = (โˆ…\๐‘’, โˆž), ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘’)][2] = โˆž, ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘’)][1] = โˆ…\๐‘’. โ–ฒ We may update the values of ๐ธ๐ฟ๐‘‡ during our algorithm for ABSEW. Theorem 3.6: Let ๐‘‡ be an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ. Assume we have a path ๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  ) = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘  in ๐‘‡ with ๐‘ฃ1 ๐‘ฃ๐‘  โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) and each ๐‘’ โˆˆ ๐ธ(๐‘‡) has an attached label, ๐‘™(๐‘’). Using ๐‘ค๐บ (๐‘ฃ1 ๐‘ฃ๐‘  ), and {(๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) )}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) that is element-wise ๐‘ โˆ’1 linked to the edges; we can extract {(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 , ๐‘™(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ), ๐‘Šร—โ€ฒ (๐‘‡๐‘ฃ1๐‘ฃ๐‘  \๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ))}๐‘–=1 in ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  )|)-time. Proof: Let us have the theoremโ€™s assumption. By equations 2.1 and 2.5, and the consistency of โ„Žโ€ฒ๐‘‡ , โ„Žโ€ฒ๐‘‡ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = ๐‘“(๐‘‡๐‘Ž๐‘ฅ ) โˆ’ ๐‘“(๐‘‡๐‘ฅ๐‘Ž ) or 0, ๐‘Ž๐‘ฅ โˆˆ ๐ธ(๐‘‡). And using the discrete integral definition ๐‘ฃ๐‘–+1 ๐‘ฃ๐‘– โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ + โ„Žโ€ฒ๐‘‡ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ). ๐‘‘ ๐‘‡ (๐‘ฃ๐‘– , ๐‘ฃ๐‘–+1 ), โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— 0 < ๐‘– < ๐‘ . (3.5) ๐‘ฃ1 ๐‘ฃ1 Furthermore, as a result of definition 2.12 and theorem 2.13 for a tree, we have the following general rules: ๐‘ฃ๐‘ ๐‘ฃ๐‘Ž โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ = โˆ’ โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ , 1 โ‰ค ๐‘Ž โ‰ค ๐‘ โ‰ค ๐‘ , (3.6) ๐‘ฃ๐‘Ž ๐‘ฃ๐‘ and 31 ๐‘ฃ๐‘ ๐‘ฃ๐‘ ๐‘ฃ๐‘ โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ + โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ , 1 โ‰ค ๐‘Ž โ‰ค ๐‘ โ‰ค ๐‘ โ‰ค ๐‘ . (3.7) ๐‘ฃ๐‘Ž ๐‘ฃ๐‘ ๐‘ฃ๐‘Ž Based on equations 3.5 and 3.7 and the discrete integral definition, the following ๐‘ฃ simple loop computes ๐ผ๐‘– = โˆซ๐‘ฃ ๐‘– โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ and ๐ท๐‘– = ๐‘‘ ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘– ) for all 1 โ‰ค ๐‘– โ‰ค ๐‘ . 1 ๐‘ฃ1 ๐ˆ๐ง๐ข๐ญ๐ข๐š๐ญ๐ž: ๐ผ1 = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ , ๐ท1 = ๐‘‘(๐‘ฃ1 , ๐‘ฃ1 ), ๐‘ฐ = {๐ผ1 }, ๐‘ซ = {๐ท1 } ๐‘ฃ1 ๐…๐จ๐ซ ๐‘ฃ๐‘— ๐‘ฃ๐‘—+1 on ๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  ) from ๐‘ฃ1 ๐‘ฃ2 ๐ญ๐จ ๐‘ฃ๐‘ โˆ’1 ๐‘ฃ๐‘  with the given order ๐‘–=๐‘— ๐‘ฃ๐‘–+1 โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ = ๐ผ๐‘– + โ„Žโ€ฒ๐‘‡ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ). ๐‘‘ ๐‘‡ (๐‘ฃ๐‘– , ๐‘ฃ๐‘–+1 ) โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— and ๐‘‘ ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘–+1 ) = ๐ท๐‘– + ๐‘ค(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ) ๐‘ฃ1 ๐‘ฃ๐‘–+1 ๐ผ๐‘–+1 โ† โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ and ๐ท๐‘–+1 โ† ๐‘‘ ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘–+1 ) ๐‘ฃ1 ๐‘ฐ = ๐‘ฐ โˆช {๐ผ๐‘–+1 } and ๐‘ซ = ๐‘ซ โˆช {๐ท๐‘–+1 } ๐ž๐ง๐ โ–ฒ With the given data from the theorem, the above loopโ€™s time complexity is ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  )|). Now using ๐‘ฐ, ๐‘ซ, Equations 3.6 and 3.7, and corollary 3.4 very precisely ๐‘ฃ1 ๐‘ฃ๐‘  ๐‘ฃ๐‘  ๐‘ฃ๐‘–+1 โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ = โˆ’๐ผ๐‘– and โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ โˆ’ โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘ ๐‘‡ = ๐ผ๐‘  โˆ’ ๐ผ๐‘–+1 , (3.8) ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ๐‘ฃ1 ๐‘ฃ1 ๐‘ฃ1 ๐‘ฃ1 ๐‘ฃ ๐‘ฃ โˆซ โ„Žโ€ฒ๐‘‡ ๐‘ฃ๐‘–+1 ๐‘‘ ๐‘‡ ๐‘ฃ๐‘–+1 = โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ โˆ’ ๐‘‘ ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘– ). ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ) = โˆ’๐ผ๐‘– + ๐ท๐‘– . ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ), (3.9) ๐‘ฃ๐‘– ๐‘ฃ๐‘– ๐‘ฃ๐‘– ๐‘ฃ๐‘– ๐‘ฃ๐‘  ๐‘ฃ๐‘  ๐‘ฃ โˆซ โ„Žโ€ฒ๐‘‡ ๐‘ฃ๐‘– ๐‘‘ ๐‘ฃ ๐‘‡๐‘ฃ ๐‘– =โˆซ โ„Žโ€ฒ๐‘‡ ๐‘‘๐‘‡ โˆ’ ๐‘‘ ๐‘‡ (๐‘ฃ๐‘–+1 , ๐‘ฃ๐‘  ). ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) ๐‘ฃ๐‘–+1 ๐‘ฃ ๐‘–+1 ๐‘–+1 ๐‘ฃ๐‘–+1 ๐‘ฃ = ๐ผ๐‘  โˆ’ ๐ผ๐‘–+1 โˆ’ (๐ท๐‘  โˆ’ ๐ท๐‘–+1 ). ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ). (3.10) where ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 โˆˆ ๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  ), 0 โ‰ค ๐‘– โ‰ค ๐‘ . Moreover, ๐‘ฃ1 ๐‘ฃ๐‘  โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) and ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘  being a ๐‘ฃ ๐‘ฃ path in ๐‘‡ implies that ๐‘ฃ1 โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘–๐‘–+1 ) and ๐‘ฃ๐‘  โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘–+1 ๐‘– ), 0 โ‰ค ๐‘– โ‰ค ๐‘ . Thus, by lemma 3.1 32 ๐‘ฃ1 ๐‘ฃ๐‘  ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ๐‘Šร—โ€ฒ (๐‘‡๐‘ฃ1๐‘ฃ๐‘  \๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 )= ๐‘“(๐‘‡๐‘ฃ๐‘–+1 ) (โˆซ โ„Žโ€ฒ๐‘‡ ๐‘ฃ๐‘–+1 ๐‘‘ ๐‘‡ ๐‘ฃ๐‘–+1 ) + ๐‘“(๐‘‡๐‘ฃ๐‘– ) (โˆซ โ„Žโ€ฒ๐‘‡ ๐‘ฃ๐‘– ๐‘‘ ๐‘‡ ๐‘ฃ๐‘– ) ๐‘ฃ๐‘– ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ๐‘ฃ๐‘–+1 ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ๐‘ฃ ๐‘ฃ +๐‘“(๐‘‡๐‘ฃ๐‘–๐‘–+1 )๐‘“(๐‘‡๐‘ฃ๐‘–+1 ๐‘– )(๐‘ค(๐‘ฃ1 ๐‘ฃ๐‘  ) โˆ’ ๐‘ค(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 )), 0 โ‰ค ๐‘– โ‰ค ๐‘ . (3.11) Thus, in ๐‘‚(๐‘  = |๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  )|)-time, we can compute what the theorem claims. In an algorithmic view, the proof can be seen as follows. Accordingly, its total time complexity is clearly ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  )|). Initiate ๐‘Š = โˆ…, ๐‘ฐ, ๐‘ซ, ๐‘ค(๐‘ฃ1 ๐‘ฃ๐‘  ) #in ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  )|) ๐…๐จ๐ซ ๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 โˆˆ ๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  ) (๐‘“๐‘– , ๐‘“๐‘–+1 ) โ† Get (๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ฃ๐‘–๐‘–+1 ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ฃ๐‘–+1 ๐‘– )) # Is given ๐‘™(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ) โ† Get ๐‘™(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ) # Is given ๐‘ค โ† Get ๐‘ค๐บ (๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ) # Edge weight ๐‘ฃ ๐‘ฃ ๐ผ โ† โˆซ๐‘ฃ ๐‘– โ„Žโ€ฒ๐‘‡ ๐‘ฃ๐‘–+1 ๐‘‘๐‘‡ ๐‘ฃ๐‘–+1 = โˆ’๐ผ๐‘– + ๐ท๐‘– ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ) #By Eq. 3.9 and ๐ผ, ๐ท 1 ๐‘ฃ๐‘– ๐‘ฃ๐‘– ๐‘ฃ ๐‘ฃ ๐ผ ๐‘ โ† โˆซ๐‘ฃ ๐‘  โ„Žโ€ฒ๐‘‡ ๐‘ฃ๐‘– ๐‘‘๐‘‡ ๐‘ฃ๐‘– = ๐ผ๐‘  โˆ’ ๐ผ๐‘–+1 โˆ’ (๐ท๐‘  โˆ’ ๐ท๐‘–+1 )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) #By Eq. 3.10 and ๐ผ, ๐ท ๐‘–+1 ๐‘ฃ๐‘–+1 ๐‘ฃ๐‘–+1 ๐‘Šร—โ€ฒ (๐‘‡๐‘ฃ1๐‘ฃ๐‘  \๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ) = ๐‘“๐‘–+1 ร— ๐ผ + ๐‘“๐‘– ร— ๐ผ ๐‘ + ๐‘“๐‘– ร— ๐‘“๐‘–+1 ร— (๐‘ค(๐‘ฃ1 ๐‘ฃ๐‘  ) โˆ’ ๐‘ค) #By Eq. 3.11 ๐‘Š = ๐‘Š โˆช (๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 , ๐‘™(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ), ๐‘Šร—โ€ฒ (๐‘‡๐‘ฃ1๐‘ฃ๐‘  \๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 )) ๐ž๐ง๐ โ–  The following resultโ€™s proof is quite similar to the theorem 3.6 proof. Corollary 3.7: Let ๐‘‡ be a ๐‘†๐‘‡ of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ. Assume we have a path ๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  ) = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘  in ๐‘‡ with ๐‘ฃ1 ๐‘ฃ๐‘  โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) and each ๐‘’ โˆˆ ๐ธ(๐‘‡) has an attached label, ๐‘™(๐‘’). Using ๐‘ค๐บ (๐‘ฃ1 ๐‘ฃ๐‘  ) and {(๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), (๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) That is, elements-wise linked to the relevant edges; we can extract ๐‘ โˆ’1 {(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 , ๐‘™(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ), ๐‘Š+โ€ฒ (๐‘‡๐‘ฃ1๐‘ฃ๐‘  \๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ))}๐‘–=1 , in ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  )|)-time. โ–  By definition 1.1 and 1.4 โ€ฒ ๐‘Š๐›ผ,๐›ฝ (๐บ๐ด\๐ต ) = ๐‘Š๐›ผ,๐›ฝ (๐บ๐ด\๐ต ) โˆ’ ๐‘Š๐›ผ,๐›ฝ (๐บ) = ๐›ผ๐‘Šร—โ€ฒ (๐บ๐ด\๐ต ) + ๐›ฝ๐‘Š+โ€ฒ (๐บ๐ด\๐ต ), ๐›ผ, ๐›ฝ โˆˆ โ„. 33 Thus, by theorem 3.6 and Corollary 3.7, we have the following. Corollary 3.8: Let ๐‘‡ be a ๐‘†๐‘‡ of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ. Assume we have a path ๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  ) = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘  in ๐‘‡ with ๐‘ฃ1 ๐‘ฃ๐‘  โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡) and each ๐‘’ โˆˆ ๐ธ(๐‘‡) has an attached label, ๐‘™(๐‘’). Using ๐‘ค๐บ (๐‘ฃ1 ๐‘ฃ๐‘  ) and {(๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), (๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) that is, elements-wise linked to the relevant edges; we can extract โ€ฒ ๐‘ โˆ’1 {(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 , ๐‘™(๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ), ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฃ1๐‘ฃ๐‘  \๐‘ฃ๐‘– ๐‘ฃ๐‘–+1 ))}๐‘–=1 , in ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฃ1 , ๐‘ฃ๐‘  )|)-time. โ–  3.3 All BSE Algorithm So far, the results have been based on the definitions of integral and derivative. The following consequence uses past results to solve ABSEW in a technical way. Proposition 3.9: Assume ๐‘‡ is an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ with ๐‘š edges and ๐‘› vertices. Apart from ๐‘‚(๐‘›)-time preprocessing, ABSEW w.r.t. ๐‘Š๐›ผ,๐›ฝ can be solved in an average time of ๐‘‚((๐‘š โˆ’ ๐‘›). log ๐‘›) and the best time of ๐‘‚(๐‘š โˆ’ ๐‘›) within ๐‘‚(๐‘š)-space. Proof: Let ๐‘‡ be an ST of ๐บ. And ๐บ is a graph with arbitrary edge and vertex weights that has ๐‘š edges and ๐‘› vertices. Also, let {๐ถ๐‘ข๐‘ฃ }๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) is a set of initially empty variables. First, we reversely extract ๐ถ(๐‘‡๐‘ข๐‘ฃ , ๐‘‡๐‘ฃ๐‘ข ) for every ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) as follows: A: For each ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡), find all ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) such that ๐‘ฅ๐‘ฆ โˆˆ ๐ถ(๐‘‡๐‘ข๐‘ฃ , ๐‘‡๐‘ฃ๐‘ข ), and add ๐‘ฅ๐‘ฆ to every relevant ๐ถ๐‘ข๐‘ฃ . Clearly, executing A results in ๐ถ๐‘ข๐‘ฃ = ๐ถ(๐‘‡๐‘ข๐‘ฃ , ๐‘‡๐‘ฃ๐‘ข ) for each ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡). One can see that for ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡), ๐‘ฅ๐‘ฆ โˆˆ ๐ถ(๐‘‡๐‘ข๐‘ฃ , ๐‘‡๐‘ฃ๐‘ข ) if and only if ๐‘ข๐‘ฃ โˆˆ ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ). So, we can update A and produce the same result as follows: B: For each ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡), find ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ), then for each ๐‘ข๐‘ฃ โˆˆ ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ) add ๐‘ฅ๐‘ฆ to ๐ถ๐‘ข๐‘ฃ . 34 Now label ๐ธ(๐‘‡) and initiate ๐ธ๐‘™ ๐‘‡ . We extend B as follows: C: For each ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡), find ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ), then for each ๐‘ข๐‘ฃ โˆˆ ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ), get ๐‘™(๐‘ข๐‘ฃ), compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ), add ๐‘ฅ๐‘ฆ to ๐ถ๐‘ข,๐‘ฃ , and if ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) < ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘ข๐‘ฃ)][1] then let ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘ข๐‘ฃ)] โ† (๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ, ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ )). Thus, by completing C for every ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) we have ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘ข๐‘ฃ)] = (๐œ–\๐‘ข๐‘ฃ, ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘ข๐‘ฃ )) with ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘ข๐‘ฃ ) = ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘ข๐‘ฃ ). Furthermore, for ๐‘  โˆˆ (๐ธ(๐บ)\๐ธ(๐‘‡))\๐ถ(๐‘‡๐‘ข๐‘ฃ , ๐‘‡๐‘ฃ๐‘ข ), ๐‘ โˆˆ๐ถ(๐‘‡๐‘ข ,๐‘‡๐‘ฃ ) ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘ข๐‘ฃ ) = โˆž. Therefore, ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘ข๐‘ฃ ) = ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘ข๐‘ฃ ). That is by ๐‘ โˆˆ๐ถ(๐‘‡๐‘ข๐‘ฃ ,๐‘‡๐‘ฃ๐‘ข ) ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) executing B, ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘ข๐‘ฃ)] = (๐œ–\๐‘ข๐‘ฃ, ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘ข๐‘ฃ ), where ๐œ– is a BSE of ๐‘ข๐‘ฃ w.r.t ๐‘Š๐›ผ,๐›ฝ , ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡). By definition, ๐‘Šร—โ€ฒ (๐‘‡๐œ–\e ) = ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\e ) โˆ’ ๐‘Š๐›ผ,๐›ฝ (๐‘‡). So, we can update C as follows while maintaining the same output for ๐ธ๐ฟ๐‘‡ : D: For every ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ)\๐ธ(๐‘‡), find ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ), then for each ๐‘ข๐‘ฃ โˆˆ ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ): get ๐‘™(๐‘ข๐‘ฃ), โ€ฒ โ€ฒ compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ), using ๐‘Š๐›ผ,๐›ฝ (๐‘‡) and ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) compute ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ), and if ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) < ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘ข๐‘ฃ)][1]then let ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘ข๐‘ฃ)] โ† (๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ, ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ )) So, D is a solution to ABSEW. Finally, to devise an efficient ABSEW algorithm, in preprocessing, we label ๐ธ(๐บ), initiate ๐ธ๐ฟ๐‘‡ , compute {(๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) , {(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) , ๐ธ(๐บ)\๐ธ(๐‘‡), and ๐‘Š๐›ผ,๐›ฝ (๐‘‡) using [14]. Then we set up an ABSEW algorithm, using D as follows. (Most lines' complexities are presented to ease computing the total complexities.) ABSEW Algorithm Input: Adjacency lists of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ and an ST, ๐‘‡. (๐‘š, ๐‘›) = (|๐ธ(๐บ)|, |๐‘‰(๐บ)|) Output: ๐ธ๐ฟ๐‘‡ = {โˆ€ ๐‘’ โˆˆ ๐ธ(๐‘‡) a pair (๐œ–\๐‘’, ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ )) with ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ) = min ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ \๐‘’ ) } ๐‘ โˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) 35 Preprocessing----------------------------------------------------------------------------------- Compute {(๐’‡๐‘ป (๐‘ป๐’—๐’– ), ๐’‡๐‘ป (๐‘ป๐’–๐’— ))}๐’–๐’—โˆˆ๐‘ฌ(๐‘ป) linked to the edges #๐‘ถ(๐’):Corollary 2.6 Compute {(๐’๐‘ป (๐‘ป๐’—๐’– ), ๐’๐‘ป (๐‘ป๐’–๐’— ))}๐’–๐’—โˆˆ๐‘ฌ(๐‘ป) linked to the edges #๐‘ถ(๐’):Corollary 2.6 Sort Adj list of ๐‘ป โ† ๐ˆโ€ฒ๐‘ป -L # ๐‘ถ(๐’) : Corollary 2.7 Compute ๐‘พ๐œถ,๐œท (๐‘ป) # ๐‘ถ(๐’) : From [14] Label ๐‘ฌ(๐‘ป) # ๐‘ถ(๐’) Initiate ๐‘ฌ๐‘ณ๐‘ป # ๐‘ถ(๐’) : Definition 3.5 Compute ๐‘ฌ(๐‘ฎ)\๐‘ฌ(๐‘ป) \\ by traversing the ST # ๐‘ถ(๐’) Main (Executing D)--------------------------------------------------------------------------- For ๐’™๐’š โˆˆ ๐‘ฌ(๐‘ฎ)\๐‘ฌ(๐‘ป) #๐‘‚(๐‘š โˆ’ ๐‘›) iteration(s) ๐’˜ โ† ๐’˜(๐’™๐’š) #For use in 2- 1- Find ๐‘จ = ๐‘ท๐‘ป (๐’™, ๐’š) #๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ)|) = ๐‘‚(log ๐‘›)-time on average: Lemma 2.11 & [18] 2- Compute ๐‘ฉ = {( ๐’–๐’—, ๐’(๐’–๐’—), ๐‘พโ€ฒ๐œถ,๐œท (๐‘ป๐’™๐’š\๐’–๐’— ) )| ๐’–๐’— โˆˆ ๐‘ท๐‘ป (๐’™, ๐’š)} #๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ)|) = ๐‘‚(log ๐‘›)-time on average: Corollary 3.8 & [18] For (๐’–๐’—, ๐’(๐’–๐’—), ๐‘พโ€ฒ๐œถ,๐œท (๐‘ป๐’™๐’š\๐’–๐’— )) โˆˆ ๐‘ฉ # ๐‘‚(|๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ)| = |B|)=๐‘‚(log ๐‘›) on average iterations, [18] ๐‘พ๐œถ,๐œท (๐‘ป๐’™๐’š\๐’–๐’— ) = ๐‘พโ€ฒ๐œถ,๐œท (๐‘ป๐’™๐’š\๐’–๐’— ) + ๐‘พ๐œถ,๐œท (๐‘ป) # ๐‘‚(1) If ๐‘พ๐œถ,๐œท (๐‘ป๐’™๐’š\๐’–๐’— ) < ๐‘ฌ๐‘ณ๐‘ป [๐’(๐’–๐’—)][๐Ÿ] # ๐‘‚(1) ๐‘ฌ๐‘ณ๐‘ป [๐’(๐’–๐’—)] โ† (๐’™๐’š\๐’–๐’—, ๐‘พ๐œถ,๐œท (๐‘ป๐’™๐’š\๐’–๐’— )) #keeps min ๐‘พ๐œถ,๐œท (๐‘ป๐’™๐’š\๐’–๐’— ) end end Free ๐‘จ and ๐‘ฉ end 36 As we see, by following the average complexity of each line of the main algorithm, we achieve an average time complexity of ๐‘‚((๐‘š โˆ’ ๐‘›). log ๐‘›). It employs the adjacency lists and the sets ๐ด, ๐ต, and ๐ธ๐‘™ ๐‘‡ , which occupy no more than ๐‘‚(๐‘š)-space. Furthermore, the preprocessing takes ๐‘‚(๐‘›)-time. Finally, if ๐‘‚(โˆ‘๐‘ฅ๐‘ฆโˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) |๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ)| โ„(๐‘š โˆ’ ๐‘›)) = ๐‘‚(1) or ๐‘‚(diam(๐บ)) = ๐‘‚(1) we clearly get algorithmโ€™s best time, ๐‘‚(๐‘š โˆ’ ๐‘›). This completes the proof. โ–  ABSEW algorithm requires ๐‘‚(๐‘š)-space to store the graph's adjacency lists. We just add ๐‘‚(๐‘›)-space to initiate ๐ธ๐ฟ๐‘‡ , which can still be lowered for graphs with cut edges. If ๐‘’ is a cut edge, the ABSEW algorithm reflects this by keeping the initial values in ๐ธ๐ฟ๐‘‡ that is ๐ธ๐ฟ๐‘‡ [๐‘™(๐‘’)] = (โˆ…\๐‘’, โˆž). ABSEW algorithmโ€™s average time for dense graphs or minimal trees such as MRCT approaches its best, ๐‘‚(๐‘š โˆ’ ๐‘›). More precisely, the time complexity of the ABSEW algorithm is exactly ๐‘‚(โˆ‘๐‘ข๐‘ฃโˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) |๐‘ƒ๐‘‡ (๐‘ข, ๐‘ฃ) |) that is taken from its topology. 3.4 Examples and ABSEW Algorithm for ABSER Assume ๐‘‡ is an ST of a (๐‘“๐บ , ๐‘ค๐บ )-weighted graph ๐บ and ๐‘† โІ ๐‘‰(๐บ) is a set of sources. Set ๐‘“๐บ (๐‘ฃ) = 1 for every ๐‘ฃ โˆˆ ๐‘† and ๐‘“๐บ (๐‘ฃ) = 0 for every ๐‘ฃ โˆˆ ๐‘‰(๐บ)\๐‘†. Then, ๐‘Š1,โˆ’1 (๐‘‡) = ๐‘…๐ถ(๐‘‡, ๐‘†). Therefore, ABSER is a particular subset of the ABSEW algorithm. And ABSEW solves ABSER for any connected real edge-weighted graph and any 1 โ‰ค |๐‘†| โ‰ค ๐‘›, where in addition, computes the ๐‘…๐ถ of the trees w.r.t. each BSE. That improves the current results of ABSER algorithms in terms of time and constraints(sources count, edge weight limit, graph type). Studies solve ABSER for 2-edge connected graphs with positive edge weights |๐‘†| ๐‘™๐‘œ๐‘”๐›ผ(2๐‘š,2๐‘š)) [5,23]. In general, the solution in [5] takes ๐‘‚(๐‘š. |๐‘†|. 2๐‘‚(๐›ผ(2๐‘š,2๐‘š) . log ๐Ÿ ๐‘› )-time, with ๐‘‚(๐‘š. 2๐‘‚(๐›ผ(2๐‘š,2๐‘š)) . log ๐Ÿ ๐‘› )-time for |๐‘†| = ๐‘› or ๐‘‚(1). Also, the solution of [23] takes ๐‘‚(๐‘›2 + ๐‘š. log ๐‘›)-time for |๐‘†| = 2, and ๐‘‚(๐‘š๐‘›)-time for |๐‘†| > 2. Table 3.1 compares the most recent algorithms. โ–ฒ 37 โ€ฒ Finally, because we compute ๐‘Š๐›ผ,๐›ฝ s in ABSEW, we guess that our solution has minimal time complexity, which is precisely ๐‘‚[โˆ‘๐‘ข๐‘ฃโˆˆ๐ธ(๐บ)\๐ธ(๐‘‡) |๐‘ƒ๐‘‡ (๐‘ข, ๐‘ฃ)|]. Assume we have an ST as an MRCT or a minimal ๐‘Š๐›ผ,๐›ฝ of a graph. Problem 3.10: Is it possible to find a BSE w.r.t. ๐‘Š๐›ผ,๐›ฝ or RC for a single given failed (๐‘šโˆ’๐‘›)log ๐‘› edge in an ๐‘‚( )-time? โ–ฒ ๐‘› In addition, assume we run ABSEW or ABSER, and we have a set of BSEs. Then Problem 3.11: Is it possible to update BSEs w.r.t. ๐‘Š๐›ผ,๐›ฝ or RC in a polylogarithmic time when a new single edge is added to the original graph? โ–ฒ Problem 3.12: Is it possible to update BSEs w.r.t. ๐‘Š๐›ผ,๐›ฝ or RC in a polylogarithmic time when a single swap happens? โ–ฒ 38 REFERENCES [1] W. Ackermann, Zum Hilbertschen Aufbau der reellen Zahlen., Math. Ann., 99 (1928), 118-133. [2] Christos Alexopoulos, Jay A. Jacobson, State space partition algorithms for stochastic systems with applications to minimum spanning trees, Networks, 35 (2000), 118-138. [3] Julien Baste, Didem Gรถzรผpek, Christophe Paul, Ignasi Sau, Mordechai Shalom, Dimitrios M. Thilikos, Parameterized complexity of finding a spanning tree with minimum reload cost diameter, Networks, 75 (2020), 259-277. [4] Davide Biloฬ€, Feliciano Colella, Luciano Gualaฬ€, Stefano Leucci, Guido Proietti, Effective edge-fault-tolerant single-source spanners via best (or good) swap edges, In Shantanu Das and Seฬbastien Tixeuil, editors, Structural Information and Communication Complexity - 24th International Colloquium, SIROCCO 2017, Porquerolles, France, June 19-22, 2017, Revised Selected Papers, volume 10641 of Lecture Notes in Computer Science, pp 303- 317. Springer, (2017). [5] Davide Biloฬ€, Luciano Gualaฬ€, Guido Proietti, Finding best swap edges minimizing the routing cost of a spanning tree, Algorithmica, 68 (2014), 337-357. [6] Davide Biloฬ€, Luciano Gualaฬ€, Guido Proietti, A faster computation of all the best swap edges of a shortest paths tree, Algorithmica, 73 (2015), 547-570. [7] Sara Bourbour, Dinesh P. Mehta, William C. Navidi, Improved methods to compare distance metrics in networks using uniform random spanning trees, Networks, 75 (2020), 402-413. [8] Shantanu Das, Beat Gfeller, Peter Widmayer, Computing all best swaps for minimum- stretch tree spanners, J. Graph Algorithms Appl., 14 (2010), 287-306. [9] P. Dunklemann, R. C. Entringer, Average distance, minimum degree and spanning trees, J. Graph Theory, 33 (2000), 1-13. [10] Matteo Fischetti, Giuseppe Lancia, Paolo Serafini, Exact algorithms for minimum routing cost trees, Networks, 39 (2002), 161-173. [11] Paola Flocchini, Linda Pagli, Giuseppe Prencipe, Nicola Santoro, Peter Widmayer, Computing all the best swap edges distributively, J. Parallel Distrib. Comput., 68 (2008), 976-983. 39 [12] M. Grotschel, C.L. Monma, and M. Stoer, Design of survivable networks, Handbook, in OR and MS, Vol.7, Elsevier, Amsterdam, (1995), 617-672. [13] Giuseppe F. Italiano, Rajiv Ramaswami, Maintaining spanning trees of small diameter, Algorithmica 22, (1998), 275-304. [14] M. H. Khalifeh, Abdol-Hossein Esfahanian, Discrete Integral and Discrete Derivative on Graphs and Switch problems of Trees, Mathematics, Advances in Graph Theory: Algorithms and Applications, 11 (2023), 1678. [15] Masayuki Kobayashi, Yoshio Okamoto, Submodularity of minimum-cost spanning tree games, Networks, 63 (2014), 231-238. [16] Seth Pettie, Sensitivity analysis of minimum spanning trees in sub-inverse-Ackermann time. In Proc. of the 16th Intl. Symposium on Algorithms and Computation, (2005), 964-973. [17] Aleksej Di Salvo, Guido Proietti, Swapping a failing edge of a shortest paths tree by minimizing the average stretch factor, Theor. Comput. Sci., 383 (2007), 23-33. [18] Z. Shen, The average diameter of general tree structures, Comput. Math. Appl., 36 (1998), 110-130. [19] H. Wiener, Structural determination of Paraffin boiling points, J. Am. Chem. Soc., 69 (1947), 17-20. [20] B.Y. Wu, A polynomial time approximation scheme for the two-source minimum routing cost spanning trees, Journal of Algorithms, 44 (2002), 359-378. [21] B.Y. Wu, Approximation algorithms for the optimal p-source communication spanning tree, Discrete App. Math., 143 (2004), 31-42. [22] B.Y. Wu, K.-M. Chao, Spanning Trees and Optimization Problems, Chapman & Hall / CRC Press, 2004. [23] B. Y. Wu, C. -Y. Hsiao, K.-M Chao, The swap edges of a multiple-sources routing tree, Algorithmica, 50 (2008), 299-311. [24] B.Y. Wu, G. Lancia, V. Bafna, K.-M. Chao, R. Ravi, C.Y. Tang, A polynomial time approximation scheme for minimum routing cost spanning trees, SIAM J. on Computing, 29 (1999), 761-778. 40 CHAPTER 4: BEST SWITCH EDGE OF TREES 4.1 Introduction Unlike Euclidean space, which is equipped with coordinate systems, we cannot stay at a network node and visualize where we are and how to achieve our goal. On the other hand, analyzing a network using local information can lower the cost of tasks [1-6]. A preprocessing may help to establish a network coordinate for local tasks and reach the destination step by step. In this chapter, we work on problem 2 and two more problems based on it []. We use discrete derivative, discrete integral, and convexity notions meaningfully to help with local tasks. Let, ๐‘๐‘‡ = {(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) and ๐น๐‘‡ = {(๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) . Using the notations, the coordinate of ๐‘‡ is shown and defined with ๐‘„๐‘‡ = {๐น๐‘‡ , ๐‘๐‘‡ , ๐‘Šร— (๐‘‡), ๐‘Š+ (๐‘‡)}. Now suppose ๐‘‡ is an ๐‘›-vertex and positively weighted tree with coordinate ๐‘„๐‘‡ . We are interested in solving the following problem. Get ๐‘‡, ๐‘„๐‘‡ , ๐‘’ โˆˆ ๐ธ(๐‘‡) and ๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0 and return ๐‘‡๐œ–\๐‘’ , ๐‘„๐‘‡๐œ–\๐‘’ , ๐œ– and ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ), where ๐œ– is a BS of ๐‘’ w.r.t. ๐‘Š๐›ผ,๐›ฝ and ๐‘ค = ๐‘ค๐‘‡๐œ–\๐‘’ (๐œ–). Clearly, using the output of the problem, if we solve the problem with some complexities, we can keep getting ๐‘’๐‘– and ๐‘ค๐‘–+1 , ๐›ผ๐‘–+1 , ๐›ฝ๐‘–+1 โˆˆ โ„โ‰ฅ0 and solve the problem on ((๐‘‡๐œ–1\๐‘’1 )๐œ–2\๐‘’2 โ€ฆ )๐œ–๐‘– \๐‘’๐‘– with the same complexities on ๐‘‡, ๐‘– > 1. We solve the problem with the worst average time of ๐‘‚(log ๐‘›) and the best average time of ๐‘‚(1). Changing edge weights within the positive range are also supported in ๐‘‚(1)-time per change to update the coordinates ๐‘„๐‘‡๐œ– \๐‘’ at any meaningful step. The problem can be seen as a generalization ๐‘– ๐‘– of [7-9] that has found some applications [10-12,6]. For some relevant optimization 41 problems over spanning trees, see [13-19]. This chapter uses extensive notation for more precise interaction, which may take some time to get used to. But our solutions are natural, utilizing some calculus intuition behind the notations. See remark 4.8. We might be able to partially compare our solution for the above problem with top tree methods [7-9]. See the last section. Generalizing top tree method solves the problem above for some specified edges and fixed ๐›ผ, ๐›ฝ with the same average complexity as our solution. But, by changing ๐›ผ, ๐›ฝ, in the top tree method, one needs to repeat the preprocessing, which is expensive. We also compare the solution with swap edge problem of spanning trees [20,21, chapter 3], which requires a conversion. See the last section for some more details. Problem 2, as mentioned, can be a specific version of ABSEW. Unlike ABSEW, firstly, we want to find a BS for a single given edge, not all edges. Secondly, we want to update the tree with a BS and be able to find a new BS after the update with new parameters and without repeating the preprocessing. Based on the BS definition, we redefine problem 2 in an updated form as follows. Problem 2: Input: 1. ๐‘‡, 2. ๐‘’ โˆˆ ๐ธ(๐‘‡), 3. ๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0 , (๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0 means ๐‘ค > 0, ๐›ผ + ๐›ฝ > 0, and ๐›ผ, ๐›ฝ โ‰ฅ 0). 4. ๐‘„๐‘‡ . Output: 1. ๐œ– โˆˆ ๐ธ(๐‘‡ ๐‘ ), where ๐œ– is a BS of ๐‘’ w.r.t. ๐‘Š๐›ผ,๐›ฝ with ๐‘ค๐‘‡๐œ–\๐‘’ (๐œ–) = ๐‘ค. 2. ๐‘‡๐œ–\๐‘’ , 3. ๐‘„๐‘‡๐œ–\๐‘’ , 4. ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ). 42 As mentioned, according to the output, we can continue the algorithm for a new input without needing fresh preprocessing. That is, we can keep getting ๐‘’๐‘– and ๐‘ค๐‘–+1 , ๐›ผ๐‘–+1 , ๐›ฝ๐‘–+1 โˆˆ โ„โ‰ฅ0 and solve the problem on ((๐‘‡๐œ–1\๐‘’1 )๐œ–2\๐‘’2 โ€ฆ )๐œ–๐‘– \๐‘’๐‘– within the same average time on ๐‘‡, ๐‘– โ‰ฅ 1. As output has fresh input information but a new edge that should be gotten. We also design the following problems for some comparison. They can be solved upon solving problem 2. Problem 4.1: Input: 1. ๐‘‡ with ๐ธ(๐‘‡) = {๐‘’๐‘– }๐‘›๐‘–=1 , 2. ๐‘„๐‘‡ 3. {๐‘ค๐‘– , ๐›ผ๐‘– , ๐›ฝ๐‘– โˆˆ โ„โ‰ฅ0 }๐‘›๐‘–=1. Output: 1. ๐‘Ÿ, 2. ๐œ–๐‘Ÿ โˆˆ ๐ธ(๐‘‡ ๐‘ ), 3. ๐‘‡๐œ–๐‘Ÿ \๐‘’๐‘Ÿ , 4. ๐‘„๐‘‡๐œ–๐‘Ÿ\๐‘’๐‘Ÿ , 5. ๐‘Š๐›ผ๐‘Ÿ ,๐›ฝ๐‘Ÿ (๐‘‡๐œ–๐‘Ÿ \๐‘’๐‘Ÿ ), where ๐‘Š๐›ผ๐‘Ÿ ,๐›ฝ๐‘Ÿ (๐‘‡๐œ–๐‘Ÿ \๐‘’๐‘Ÿ ) = ๐‘š๐‘–๐‘›{๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– (๐‘‡๐œ–๐‘–\๐‘’๐‘– )}๐‘›๐‘–=1 and ๐œ–๐‘– is a BS of ๐‘’๐‘– w.r.t. ๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– with ๐‘ค๐‘– = ๐‘ค๐‘‡๐œ– \๐‘’ (๐œ–๐‘– ). (Overall best switch). ๐‘– ๐‘– Problem 4.2: Input: 1. ๐‘‡ with ๐ธ(๐‘‡) = {๐‘’๐‘– }๐‘›๐‘–=1 , 2. ๐‘„๐‘‡ 3. {๐‘ค๐‘– , ๐›ผ๐‘– , ๐›ฝ๐‘– โˆˆ โ„โ‰ฅ0 }๐‘›๐‘–=1. 43 Output: 1. {(๐œ–๐‘– โˆˆ ๐ธ(๐‘‡ ๐‘ ), ๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– (๐‘‡๐œ–๐‘–\๐‘’๐‘– ))}๐‘›๐‘–=1 , where ๐œ–๐‘– is a BS of ๐‘’๐‘– w.r.t. ๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– with ๐‘ค๐‘– = ๐‘ค๐‘‡๐œ– \๐‘’ (๐œ–๐‘– ). (All best switches (ABS)). ๐‘– ๐‘– 4.2 Main Algorithm for Switch and ๐‘พ๐œถ,๐œท Lemma 4.3: Let ๐‘‡ be a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree, ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡), and ๐‘”๐‘‡ = ๐›ผ๐œŽ๐‘‡ + ๐›ฝโ„Ž๐‘‡ for some ๐›ผ, ๐›ฝ โˆˆ โ„. Using, ๐น๐‘‡ and ๐‘๐‘‡ , we can calculate ๐‘”๐‘‡โ€ฒ ๐‘ฆ on the path from ๐‘ฅ toward any ๐‘ฅ ๐‘ฆ vertex of ๐‘‡๐‘ฅ . A similar argument holds for a path from ๐‘ฆ toward any vertex of ๐‘‡๐‘ฆ๐‘ฅ . ๐‘ฆ Proof: Let ๐‘‡ be a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡) with ๐‘‡ โˆ’ {๐‘ฅ๐‘ฆ} = ๐‘‡๐‘ฅ โˆช ๐‘‡๐‘ฆ๐‘ฅ and ๐‘ฆ ๐‘”๐‘‡ = ๐›ผ๐œŽ๐‘‡ + ๐›ฝโ„Ž๐‘‡ , ๐›ผ, ๐›ฝ โˆˆ โ„. Assume ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is a path in ๐‘‡๐‘ฅ , with ๐‘ฃ1 = ๐‘ฅ. Using equations 2.1, 2.2, 2.5, and {๐‘๐‘‡ , ๐น๐‘‡ } = {(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) we could extract, ๐œŽ๐‘‡โ€ฒ and โ„Žโ€ฒ๐‘‡ , and so ๐‘”๐‘‡โ€ฒ = ๐›ผ๐œŽ๐‘‡โ€ฒ + ๐›ฝโ„Žโ€ฒ๐‘‡ . However, we need to get ๐‘”๐‘‡โ€ฒ ๐‘ฆ through ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› . To ๐‘ฅ do so, one can check for ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› , ๐‘ฆ ๐‘ฃ ๐‘ฆ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘›๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–+1 ๐‘– ), ๐‘› ๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–๐‘–+1 )) = (๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 )โˆ’๐‘›๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )), 0 < ๐‘– < ๐‘›, (4.1) ๐‘ฅ ๐‘ฅ ๐‘ฆ ๐‘ฃ ๐‘ฆ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘“ ๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–+1 ๐‘– ), ๐‘“ ๐‘‡ ๐‘ฆ ([๐‘‡๐‘ฅ ]๐‘ฃ๐‘–๐‘–+1 )) = (๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ๐‘ฅ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )). 0 < ๐‘– < ๐‘›. (4.2) ๐‘ฅ ๐‘ฅ Thus, using equations 2.1, 2.2, and 2.5, along with 4.1 and 4.2: ๐œŽ๐‘‡โ€ฒ ๐‘ฆ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ) = ๐œŽ๐‘‡ (๐‘ฃ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— โ€ฒ ๐‘– ๐‘ฃ๐‘–+1 ) โˆ’ ๐‘› ๐‘‡ (๐‘‡๐‘ฆ ), โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ โ„Žโ€ฒ๐‘‡ ๐‘ฆ (๐‘ฃ โ€ฒ ๐‘– ๐‘ฃ๐‘–+1 ) = โ„Ž ๐‘‡ (๐‘ฃ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ ๐‘– ๐‘ฃ๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฆ ). โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ ๐‘ฅ That is, using ๐น๐‘‡ and ๐‘๐‘‡ , we can compute ๐‘”๐‘‡โ€ฒ ๐‘ฆ๐‘ฅ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ) as follows: โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘”๐‘‡โ€ฒ ๐‘ฆ (๐‘ฃ ๐‘– ๐‘ฃ๐‘–+1 ) = ๐›ผ๐œŽ๐‘‡ (๐‘ฃ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— โ€ฒ โ€ฒ ๐‘– ๐‘ฃ๐‘–+1 ) + ๐›ฝโ„Ž ๐‘‡ (๐‘ฃ โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ ๐‘– ๐‘ฃ๐‘–+1 ) โˆ’ ๐›ผ๐‘› ๐‘‡ (๐‘‡๐‘ฆ ) โˆ’ ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ฆ ). โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ฅ ๐‘ฅ Symmetrically, the argument holds for the ๐‘‡๐‘ฆ๐‘ฅ and ๐‘ฆ case. โ–  44 The following lemma gives a clue between a BS of ๐‘ข๐‘ฃ โˆˆ ๐‘‰(๐‘‡) w.r.t ๐‘Š๐›ผ,๐›ฝ and the ๐‘- Roots and ๐‘ž-Roots of ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข . That is, often, finding a BS is equivalent to finding some Roots. Lemma 4.4: Suppose ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree with ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ). If ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ), then ๐‘ฅ ๐‘ฆ โ€ฒ ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = โˆซ ๐‘โ€ฒ๐‘‘ ๐‘‡๐‘ข๐‘ฃ + โˆซ ๐‘žโ€ฒ๐‘‘ ๐‘‡๐‘ฃ๐‘ข + ๐น๐‘๐›ผ,๐›ฝ (๐‘ข๐‘ฃ)[๐‘ค๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค๐‘‡ (๐‘ข๐‘ฃ)], ๐‘ข ๐‘ฃ where, ๐น๐‘๐›ผ,๐›ฝ (๐‘ข๐‘ฃ) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))], ๐›ผ, ๐›ฝ โˆˆ ๐‘…, And ๐‘(๐‘Ž) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )]โ„Ž๐‘‡๐‘ข๐‘ฃ (๐‘Ž) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘Ž), ๐‘Ž โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ), ๐‘ž(๐‘) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )]โ„Ž๐‘‡๐‘ฃ๐‘ข (๐‘) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘), ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). Proof: Assume ๐‘‡ is a tree. If we remove ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) and connect, ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข with ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ), where ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ), then ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ข๐‘ฃ ) + ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฃ๐‘ข ) + โˆ‘ โˆ‘ [๐›ผ๐‘“๐‘‡ (๐‘Ž)๐‘“๐‘‡ (๐‘) + ๐›ฝ(๐‘“๐‘‡ (๐‘Ž) + ๐‘“๐‘‡ (๐‘))][๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘Ž) + ๐‘ค๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘ฅ๐‘ฆ) ๐‘Žโˆˆ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) ๐‘โˆˆ๐‘‰(๐‘‡๐‘ฃ๐‘ข ) + ๐‘‘ ๐‘‡ (๐‘, ๐‘ฆ)] = ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ข๐‘ฃ ) + ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฃ๐‘ข ) + [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )]โ„Ž๐‘‡๐‘ข๐‘ฃ (๐‘ฅ) + [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )]โ„Ž๐‘‡๐‘ฃ๐‘ข (๐‘ฆ) + ๐›ฝ[๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ฅ) + ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฆ) +๐‘ค๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘ฅ๐‘ฆ)[๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ))](4.3) Using the fact that ๐‘Šร— (๐‘‡๐‘ข๐‘ฃ\๐‘ข๐‘ฃ ) = ๐‘Šร— (๐‘‡) and the above formula, 45 โ€ฒ ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) โˆ’ ๐‘Š๐›ผ,๐›ฝ (๐‘‡) = [๐‘(๐‘ฅ) โˆ’ ๐‘(๐‘ข)] + [๐‘ž(๐‘ฆ) โˆ’ ๐‘ž(๐‘ฃ)] + ๐น๐‘๐›ผ,๐›ฝ (๐‘ข๐‘ฃ)[๐‘ค๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค๐‘‡ (๐‘ข๐‘ฃ)]. where ๐น๐‘๐›ผ,๐›ฝ (๐‘ข๐‘ฃ) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ(๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ))] and ๐‘(๐‘Ž) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )]โ„Ž๐‘‡๐‘ข๐‘ฃ (๐‘Ž) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘Ž), ๐‘Ž โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ), ๐‘ž(๐‘) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )]โ„Ž๐‘‡๐‘ฃ๐‘ข (๐‘) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘), ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). Since ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข are connected and ๐‘ and ๐‘ž by lemma 2.3 and equations 2.3 and 2.4 are consistence; then by theorem 2.13 we have: โ€ฒ ๐‘ฅ ๐‘ฆ ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = โˆซ๐‘ข ๐‘โ€ฒ๐‘‘๐‘‡๐‘ข๐‘ฃ + โˆซ๐‘ฃ ๐‘žโ€ฒ๐‘‘ ๐‘‡๐‘ฃ๐‘ข + ๐น๐‘๐›ผ,๐›ฝ (๐‘ข๐‘ฃ)[๐‘ค๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค๐‘‡ (๐‘ข๐‘ฃ)] โ–  Lemma 4.5: Suppose ๐‘‡ is a positively weighted tree with at least three vertices and ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡). If ๐‘Ž and ๐‘ are a ๐‘-Root of ๐‘‡๐‘ข๐‘ฃ and a ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข , respectively, then a BS of ๐‘ข๐‘ฃ w.r.t ๐‘Š๐›ผ,๐›ฝ is ๐‘ฅ๐‘ฆ with ๐‘ฅ โˆˆ ๐‘๐‘‡ [๐‘Ž] and ๐‘ฆ โˆˆ ๐‘๐‘‡ [๐‘]. More precisely, let the following be vertex weight functions for the relevant vertices: ๐‘(๐‘) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )]โ„Ž๐‘‡๐‘ข๐‘ฃ (๐‘) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘), ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ), ๐‘ž(๐‘) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )]โ„Ž๐‘‡๐‘ฃ๐‘ข (๐‘) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘), ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). Then a choice of ๐‘ฅ๐‘ฆ as a BS of ๐‘ข๐‘ฃ w.r.t ๐‘Š๐›ผ,๐›ฝ is as follows: A: If (๐‘ข, ๐‘ฃ) = (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ), (๐‘ฅ, ๐‘ฆ) = (๐‘ข, ๐‘ง) where ๐‘ž(๐‘ง) = ๐‘š๐‘–๐‘› ๐‘ž(๐‘), or ๐‘โˆˆ๐‘๐‘‡๐‘ข (๐‘ฃ) ๐‘ฃ (๐‘ฅ, ๐‘ฆ) = (๐‘ง, ๐‘ฃ) where ๐‘(๐‘ง) = ๐‘š๐‘–๐‘› ๐‘(๐‘ ). ๐‘โˆˆ๐‘๐‘‡๐‘ฃ (๐‘ข) ๐‘ข If ๐‘ž โ€ฒ (๐‘ฃ๐‘ง โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ข๐‘ง), 1 gives a choice for ๐‘ฅ๐‘ฆ; otherwise, 2. โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ฃ๐‘ง) < ๐‘โ€ฒ (๐‘ข๐‘ง B: If (๐‘ข, ๐‘ฃ) โ‰  (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ), then (๐‘ฅ, ๐‘ฆ) = (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ). Moreover, ๐น๐‘‡ = ๐น๐‘‡ ๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ and ๐‘๐‘‡ = ๐‘๐‘‡ ๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ except for the edges on ๐‘ƒ๐‘‡ (๐‘ข, ๐‘ฅ) and ๐‘ƒ๐‘‡ (๐‘ฃ, ๐‘ฆ). More precisely, if ๐‘ƒ ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ) = ๐‘ข1 ๐‘ข2 โ€ฆ ๐‘ข๐‘š is the path between ๐‘ข = ๐‘ข1 and ๐‘ฅ = ๐‘ข๐‘š , 46 ๐‘ข ๐‘ข ๐‘ข ๐‘ข (๐‘› ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–๐‘–+1 ), ๐‘– ๐‘› ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–+1 )) = (๐‘›๐‘‡ (๐‘‡๐‘ข๐‘–๐‘–+1 ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), ๐‘– ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘–+1 ) + ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), ๐‘ข ๐‘ข ๐‘ข ๐‘ข (๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–๐‘–+1 ), ๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–+1 ๐‘– )) = (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘–๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘–+1 ๐‘– ) + ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), 0 < ๐‘– < ๐‘š. And, if ๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ) = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› is a path between ๐‘ฃ = ๐‘ฃ1 and ๐‘ฆ = ๐‘ฃ๐‘› , ๐‘ฃ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘›๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ), ๐‘›๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )) = (๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ) + ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )), ๐‘ฃ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ), ๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )) = (๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ) + ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )), 0 < ๐‘– < ๐‘›. Proof: Assume we have the lemma assumptions. By Eq. 4.3, ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ ๐‘ก\๐‘ข๐‘ฃ ) = ๐‘(๐‘ ) + ๐‘ž(๐‘ก) + ๐‘Ÿ, ๐‘  โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ก โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). (4.4) where ๐‘Ÿ is independent of the choice of s and ๐‘ก. And the values of ๐‘(๐‘ ) and ๐‘ž(๐‘ก) are independent of each other. By definition, if ๐‘Ž โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ) minimize Eq. 4.4 and ๐‘Ž๐‘ โ‰  ๐‘ข๐‘ฃ, then ๐‘Ž๐‘ is a BS of ๐‘ข๐‘ฃ. One sees that by minimizing Eq. 4.4 inclusively, we do not exclude ๐‘ข๐‘ฃ as a choice for ๐‘Ž๐‘, since: ๐‘š๐‘–๐‘› ๐‘(๐‘ ) + ๐‘š๐‘–๐‘›๐‘ข ๐‘ž(๐‘ก) + ๐‘Ÿ = ๐‘š๐‘–๐‘› ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ ๐‘ก\๐‘ข๐‘ฃ ). (4.5) ๐‘ โˆˆ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) ๐‘กโˆˆ๐‘‰(๐‘‡๐‘ฃ ) ๐‘ ๐‘กโˆˆ๐ธ(๐‘‡ ๐‘ )โˆช{๐‘ข๐‘ฃ} Accordingly, (๐‘Ž, ๐‘)minimizes Eq. 4.4 if and only if (๐‘(๐‘Ž), ๐‘ž(๐‘)) = ( ๐‘š๐‘–๐‘›๐‘ฃ ๐‘(๐‘ ), ๐‘š๐‘–๐‘›๐‘ข ๐‘ž(๐‘ก)). That is, (๐‘Ž, ๐‘) = (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ). ๐‘ โˆˆ๐‘‰(๐‘‡๐‘ข ) ๐‘กโˆˆ๐‘‰(๐‘‡๐‘ฃ ) If case A happens ``which is (๐‘ข, ๐‘ฃ) = (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ) and also (๐‘ฅ, ๐‘ฆ) = (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ), then we might have ๐‘ฅ๐‘ฆ = ๐‘ข๐‘ฃ. To exclude ๐‘ข๐‘ฃ in the minimization of Eq. 4.4, we avoid the case that ๐‘ข and ๐‘ฃ appear concurrently by letting (๐‘(๐‘ฅ), ๐‘ž(๐‘ฆ)) is equal to either ( ๐‘š๐‘–๐‘› ๐‘(๐‘ ), ๐‘š๐‘–๐‘›๐‘ข ๐‘ž(๐‘ก)) or ( ๐‘š๐‘–๐‘›๐‘ฃ ๐‘(๐‘ ), ๐‘š๐‘–๐‘› ๐‘ž(๐‘ก)). ๐‘ โˆˆ๐‘‰(๐‘‡๐‘ข๐‘ฃ )\๐‘ข ๐‘กโˆˆ๐‘‰(๐‘‡๐‘ฃ ) ๐‘ โˆˆ๐‘‰(๐‘‡๐‘ข ) ๐‘กโˆˆ๐‘‰(๐‘‡๐‘ฃ๐‘ข ) \๐‘ฃ By theorem 2.9 and the assumptions ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข are convex. That is, ๐‘š๐‘–๐‘› ๐‘(๐‘ ) = ๐‘š๐‘–๐‘› ๐‘(๐‘ ) and ๐‘š๐‘–๐‘› ๐‘ž(๐‘ก) = ๐‘š๐‘–๐‘› ๐‘ž(๐‘ก). ๐‘ โˆˆ๐‘‰(๐‘‡๐‘ข๐‘ฃ )\๐‘ข ๐‘ โˆˆ๐‘๐‘‡๐‘ฃ (๐‘ข) ๐‘กโˆˆ๐‘‰(๐‘‡๐‘ฃ๐‘ข )\๐‘ฃ ๐‘กโˆˆ๐‘๐‘‡๐‘ข (๐‘ฃ) ๐‘ข ๐‘ฃ 47 As a result, either 1-(๐‘ฅ, ๐‘ฆ) = (๐‘ข, ๐‘ง) where ๐‘ž(๐‘ง) = ๐‘š๐‘–๐‘› ๐‘ž(๐‘), or ๐‘โˆˆ๐‘๐‘‡๐‘ฃ (๐‘ข) ๐‘ข 2-(๐‘ฅ, ๐‘ฆ) = (๐‘ง, ๐‘ฃ) where ๐‘(๐‘ง) = ๐‘š๐‘–๐‘› ๐‘(๐‘Ž). ๐‘Žโˆˆ๐‘๐‘‡๐‘ฃ (๐‘ข) ๐‘ข โ€ฒ ๐‘ข=๐‘ฅ ๐‘ฆ ๐‘ฆ By lemma 4.4, in case 1-,๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) โˆ’ ๐‘Ÿ = โˆซ๐‘ข ๐‘โ€ฒ๐‘‘๐‘‡๐‘ข๐‘ฃ + โˆซ๐‘ฃ ๐‘žโ€ฒ๐‘‘ ๐‘‡๐‘ฃ๐‘ข = โˆซ๐‘ฃ ๐‘žโ€ฒ๐‘‘๐‘‡๐‘ฃ๐‘ข = โ€ฒ โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ฃ๐‘ง) and in case 2- ๐‘Š๐›ผ,๐›ฝ ๐‘ž โ€ฒ (๐‘ฃ๐‘ง (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) โˆ’ ๐‘Ÿ = ๐‘โ€ฒ (๐‘ข๐‘งโƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ข๐‘ง). Thus, if ๐‘โ€ฒ (๐‘ข๐‘ง โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ข๐‘ง) > โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ฃ๐‘ง), then 1 gives the choice of (๐‘ฅ, ๐‘ฆ). If ๐‘โ€ฒ (๐‘ข๐‘ง ๐‘ž โ€ฒ (๐‘ฃ๐‘ง โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ข๐‘ง) < ๐‘ž โ€ฒ (๐‘ฃ๐‘ง โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ฃ๐‘ง), then (๐‘ฅ, ๐‘ฆ) comes from 2. Otherwise, either 1 or 2 is the choice. Now assume (๐‘ข, ๐‘ฃ) โ‰  (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ). If (๐‘Ž, ๐‘) = (๐‘-Root of ๐‘‡๐‘ข๐‘ฃ , ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข ), then (๐‘ข, ๐‘ฃ) โ‰  (๐‘Ž, ๐‘). Moreover, (๐‘Ž, ๐‘) minimizes ๐‘Š๐›ผ,๐›ฝ in Eq. 4.4. So (๐‘ฅ, ๐‘ฆ) = (๐‘Ž, ๐‘) is a right choice. This completes the proof of B. To form ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ we remove ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) and re-connect the components of ๐‘‡ โˆ’ ๐‘ข using ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฆ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ), ๐‘ข๐‘ฃ โ‰  ๐‘ฅ๐‘ฆ. Thus, ๐น๐‘‡ โ‰  ๐น๐‘‡ ๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ and ๐‘๐‘‡ โ‰  ๐‘๐‘‡ ๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ in general. Precisely, (๐‘›๐‘‡ (๐‘‡๐‘Ž๐‘ ), ๐‘›๐‘‡ (๐‘‡๐‘๐‘Ž )) โ‰  (๐‘›๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘Ž๐‘ ), ๐‘› ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘๐‘Ž )) or (๐‘“๐‘‡ (๐‘‡๐‘Ž๐‘ ), ๐‘“๐‘‡ (๐‘‡๐‘๐‘Ž )) โ‰  (๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘Ž๐‘ ), ๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘๐‘Ž )) happens if ๐‘Ž๐‘ โˆˆ ๐‘ƒ๐‘‡ (๐‘ข, ๐‘ฅ) or ๐‘Ž๐‘ โˆˆ ๐‘ƒ๐‘‡ (๐‘ฃ, ๐‘ฆ). By definition 2.1 ๐‘“๐‘‡ (๐‘‡๐‘Ž๐‘ ) + ๐‘“๐‘‡ (๐‘‡๐‘๐‘Ž ) = ๐‘“๐‘‡ (๐‘‡) and ๐‘›๐‘‡ (๐‘‡๐‘Ž๐‘ ) + ๐‘›๐‘‡ (๐‘‡๐‘๐‘Ž ) = |๐‘‰(๐‘‡)|. And, by lemma 4.3 equations 4.1 and 4.2, if ๐‘ƒ ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ) = ๐‘ข1 ๐‘ข2 โ€ฆ ๐‘ข๐‘š is the path between ๐‘ข = ๐‘ข1 and ๐‘ฅ = ๐‘ข๐‘š , ๐‘ข ๐‘ข ๐‘ข ๐‘ข (๐‘› ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–๐‘–+1 ), ๐‘– ๐‘› ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–+1 )) = (๐‘›๐‘‡ (๐‘‡๐‘ข๐‘–๐‘–+1 ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), ๐‘– ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘–+1 ) + ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), ๐‘ข ๐‘ข ๐‘ข ๐‘ข (๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–๐‘–+1 ), ๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ข๐‘–+1 ๐‘– )) = (๐‘“๐‘‡ (๐‘‡๐‘ข๐‘–๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘–+1 ๐‘– ) + ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )), 0 < ๐‘– < ๐‘š. And symmetrically, for ๐‘ƒ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ) = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘› with ๐‘ฃ = ๐‘ฃ1 and ๐‘ฆ = ๐‘ฃ๐‘› , ๐‘ฃ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘›๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ), ๐‘› ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )) = (๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ) + ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )), ๐‘ฃ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ), ๐‘“๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ (๐‘‡๐‘ฃ๐‘–+1๐‘– )) = (๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ) + ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )), 0 < ๐‘– < ๐‘›. โ–  Lemma 4.6: For a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree ๐‘‡, ๐‘Šร— (๐‘‡) = โˆ‘ [๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )]๐‘ค๐‘‡ (๐‘ข๐‘ฃ), ๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) 48 and, ๐‘Š+ (๐‘‡) = โˆ‘ [๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )]๐‘ค๐‘‡ (๐‘ข๐‘ฃ). ๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) Proof: We prove the first equation using the double-counting principle. Assume ๐‘‡โ€ฒ is a copy of ๐‘‡ with the edge weights set to 0 at the start. Let ๐‘ข, ๐‘ฃ โˆˆ ๐‘‰(๐‘‡) and ๐‘ƒ๐‘‡ (๐‘ข, ๐‘ฃ) is the path between ๐‘ข and ๐‘ฃ. For every ๐‘Ž๐‘ โˆˆ ๐‘ƒ๐‘‡ (๐‘ข, ๐‘ฃ) add the number ๐‘ค(๐‘ข๐‘ฃ)๐‘“๐‘‡ (๐‘Ž)๐‘“๐‘‡ (๐‘) to the corresponding edge of ๐‘Ž๐‘ in ๐‘‡โ€ฒ. Then โˆ‘๐‘ข๐‘ฃโˆˆ๐‘ƒ๐‘‡ (๐‘ข,๐‘ฃ) ๐‘ค ๐‘‡ โ€ฒ (๐‘ข๐‘ฃ) = [๐‘“๐‘‡ (๐‘ข) ๐‘“๐‘‡ (๐‘ฃ)]๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ). Thus, suppose we repeat the above process for every pair ๐‘ข, ๐‘ฃ โˆˆ ๐‘‰(๐‘‡). If so, then โˆ‘ ๐‘ค ๐‘‡ โ€ฒ (๐‘ข๐‘ฃ) = โˆ‘ [๐‘“๐‘‡ (๐‘ข) ร— ๐‘“๐‘‡ (๐‘ฃ)]๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) = ๐‘Šร— (๐‘‡). {๐‘ข,๐‘ฃ}โІ๐‘‰(๐‘‡) ๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡ โ€ฒ ) And on the other hand, one can see that ๐‘ค ๐‘‡ โ€ฒ (๐‘ข๐‘ฃ) = ๐‘ค๐‘‡ (๐‘ข๐‘ฃ) ๐‘‡ [๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )] for ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡โ€ฒ). Thus, ๐‘Šร— (๐‘‡) = โˆ‘๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡ โ€ฒ ) ๐‘ค ๐‘‡ โ€ฒ (๐‘ข๐‘ฃ) = โˆ‘๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) ๐‘ค๐‘‡ (๐‘ข๐‘ฃ)[๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )]. This proves the formula of ๐‘Šร— (๐‘‡). The proof for the ๐‘Š+ case is quite similar. โ–  Corollary 4.7: Assume ๐‘‡ is a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted ๐‘›-vertex tree. We can compute ๐‘Šร— (๐‘‡) and ๐‘Š+ (๐‘‡) in ๐‘‚(๐‘›)-time. Moreover, if by changing the weight of ๐‘Ž๐‘ โˆˆ ๐ธ(๐‘‡) to ๐‘ค, we get a tree ๐‘‡โ€ฒ, then ๐‘Šร— (๐‘‡โ€ฒ) = ๐‘Šร— (๐‘‡) + (๐‘คโˆ’๐‘ค๐‘‡ (๐‘Ž๐‘))๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), ๐‘Šร— (๐‘‡โ€ฒ) = ๐‘Šร— (๐‘‡) + (๐‘คโˆ’๐‘ค๐‘‡ (๐‘Ž๐‘))[๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )]. โ–  Remark 4.8: Here, we give a simple intuition behind an algorithm for problem 1 when the tree ๐‘‡ is positively weighted. Using lemma 4.5, finding a BS for ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), we need to have the ๐‘-Roots and ๐‘ž-Roots of ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข , respectively. By definition ๐‘ข โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and ๐‘ฃ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). By corollary 2.10, the longest decreasing path from ๐‘ข ends up with a ๐‘- Root of ๐‘‡๐‘ข๐‘ฃ say ๐‘ฅ, and similarly, the longest decreasing path from ๐‘ฃ ends up to a ๐‘ž-Root of ๐‘‡๐‘ฃ๐‘ข say ๐‘ฆ. Moreover, by corollary 2.10, those paths are the only decreasing paths in 49 their respective components. So, one can easily take some derivatives to reach from ๐‘ข to ๐‘ฅ or from ๐‘ฃ to ๐‘ฆ since the paths are decreasing and unique. Then by lemma 4.5, a BS of ๐‘ข๐‘ฃ is one of the following cases as detailed in the lemma. 1. ๐‘ฅ๐‘ฆ, 2. an edge between ๐‘ฅ and a vertex of ๐‘๐‘‡ (๐‘ฆ), 3. an edge between ๐‘ฆ and a vertex of ๐‘๐‘‡ (๐‘ฅ). Lemma 4.5 details how to choose among the above limited cases using derivatives. As we find the unique and decreasing path between ๐‘ข and ๐‘ฅ and also ๐‘ฃ and ๐‘ฆ, one can update ๐‘„๐‘‡ as in lemma 4.5. Having those paths also eases calculating ๐‘Šร— , ๐‘Š+ , and ๐‘Š๐›ผ,๐›ฝ from lemma 4.4. The following proposition details the mentioned intuition with proof of time complexity. โ–ฒ Proposition 4.9: Let ๐‘‡ be an ๐‘›-vertex positively weighted tree with a Coordinate๐‘„๐‘‡ . If we get ๐‘’ โˆˆ ๐ธ(๐‘‡) and ๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0, then we can compute, ๐œ–, ๐‘‡๐œ–\๐‘’ , ๐‘„๐‘‡๐œ–\๐‘’ , and ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ), with the worst average time of ๐‘‚(log ๐‘›) and the best average time of ๐‘‚(1), where ๐œ– is a BS of ๐‘’ w.r.t ๐‘Š๐›ผ,๐›ฝ and ๐‘ค๐‘‡๐œ–\๐‘’ (๐œ–) = ๐‘ค. Updating, ๐‘„๐‘‡ after edge weight change is supported in ๐‘‚(1)-time per change. Proof: Assume we have an ๐‘›-vertex positively weighted tree ๐‘‡, ๐‘„๐‘‡ = {๐น๐‘‡ , ๐‘๐‘‡ , ๐‘Šร— (๐‘‡), ๐‘Š+ (๐‘‡)} and ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐บ), ๐‘› > 2. Let ๐‘ and ๐‘ž be some induced vertex weight functions for ๐‘‡๐‘ข๐‘ฃ an ๐‘‡๐‘ฃ๐‘ข as follows, ๐‘๐›ผ,๐›ฝ (๐‘) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )]โ„Ž๐‘‡๐‘ข๐‘ฃ (๐‘) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข )๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘), ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ), ๐‘ž๐›ผ,๐›ฝ (๐‘) = [๐›ผ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) + ๐›ฝ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )]โ„Ž๐‘‡๐‘ฃ๐‘ข (๐‘) + ๐›ฝ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ )๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘), ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ฃ๐‘ข ). Then with the results, we have the following: 50 1-Computing a ๐’‘โ€ฒ or ๐’’โ€ฒ in ๐‘ถ(๐Ÿ)-time. Using ๐น๐‘‡ , ๐‘๐‘‡ , lemma 4.3, and definition 2.2, computing ๐‘โ€ฒ(๐‘Ÿ๐‘  โƒ—โƒ—โƒ— ) costs ๐‘‚(1)-time for any ๐‘Ÿ๐‘  โˆˆ ๐‘ƒ ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ) where ๐‘ฅ โˆˆ ๐‘‰(๐‘‡๐‘ข๐‘ฃ ) and we know the direction. A similar argument holds for computing ๐‘ž โ€ฒ on ๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ). 2-Checking whether a vertex is a Root in ๐‘ถ(๐Ÿ)-time on average. By corollary 2.10, if ๐‘โ€ฒ(๐‘ข๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) < 0 for only one ๐‘ฅ โˆˆ ๐‘๐‘‡๐‘ข๐‘ฃ (๐‘ข), then ๐‘ข is not a ๐‘-Root. The following can verify whether a vertex is ๐‘ or ๐‘ž-Root or not. (Let ๐‘“ = ๐‘ or ๐‘ž) # Takes a vertex and a ๐‘“ and says it is a ๐‘“-Root or not ๐‘ฐ๐‘บ_๐‘น๐’๐’๐’•(๐‘Ž , ๐‘“) ๐‘ญ๐’๐’“ ๐‘  โˆˆ ๐‘(๐‘Ž) ๐’Š๐’‡ ๐‘“ โ€ฒ (๐‘Ž๐‘  โƒ—โƒ—โƒ—โƒ— ) < 0 ๐’“๐’†๐’•๐’–๐’“๐’ ๐น๐‘Ž๐‘™๐‘ ๐‘’ ๐’“๐’†๐’•๐’–๐’“๐’ ๐‘‡๐‘Ÿ๐‘ข๐‘’ The average degree in a tree is ๐‘‚(1). Thus, ๐‘ฐ๐‘บ_๐‘น๐’๐’๐’• run time is ๐‘‚(1) on average. 3-Finding a neighbor with a minimum ๐’‘ or ๐’’ in ๐‘ถ(๐Ÿ)-time on average. If ๐‘  โˆˆ ๐‘ ๐‘‡๐‘ข๐‘ฃ (๐‘Ž), then by definition 2.2, ๐‘(๐‘ ) = ๐‘โ€ฒ(๐‘Ž๐‘  โƒ—โƒ—โƒ—โƒ— )๐‘ค(๐‘Ž๐‘ ) + ๐‘(๐‘Ž). By 1- computing ๐‘(๐‘ ) takes ๐‘‚(1)-time. Moreover, ๐‘‚(|๐‘๐‘‡ (๐‘Ž)|) = ๐‘‚(1) on average. Thus, finding ๐‘ฅ with ๐‘(๐‘ฅ) = ๐‘š๐‘–๐‘› ๐‘(๐‘ ) takes ๐‘‚(1)-time on average. Computing min ๐‘ž neighbor follows the same ๐‘ โˆˆ๐‘๐‘‡๐‘ฃ (๐‘Ž) ๐‘ข rules. One implements the mentioned idea as follows. 51 #Takes a vertex, ๐‘Ž, finds ๐‘ฅ โˆˆ ๐‘(๐‘Ž) with min ๐‘“ and returns ๐‘ฅ and ๐‘Ž๐‘ฅ (๐‘“ = ๐‘ or ๐‘ž) ๐‘ญ๐‘ต๐‘ซ_๐’Ž๐’Š๐’( ๐‘Ž, ๐‘“) ๐‘š๐‘–๐‘› = โˆž ๐‘ญ๐’๐’“ ๐‘  โˆˆ ๐‘(๐‘Ž) ๐‘“(๐‘ ) = ๐‘“โ€ฒ(๐‘Ž๐‘  โƒ—โƒ—โƒ—โƒ— )๐‘ค(๐‘Ž๐‘ ) + ๐‘“(๐‘Ž) ๐’Š๐’‡ ๐‘“(๐‘ ) < ๐‘š๐‘–๐‘› ๐‘š๐‘–๐‘› = ๐‘“(๐‘ ) ๐‘ฅโ†๐‘  ๐’“๐’†๐’•๐’–๐’“๐’ ๐‘ฅ , ๐‘Ž๐‘ฅ 4-Finding, ๐‘ท๐‘ป๐’—๐’– (๐’–, ๐’™) or ๐‘ท๐‘ป๐’–๐’— (๐’—, ๐’š) in ๐‘ถ(๐ฅ๐จ๐  ๐’) on average, where ๐’™ and ๐’š are ๐’‘ or๐’’-Root. By theorem 2.9, ๐‘‡๐‘ข๐‘ฃ is ๐‘-convex. Assume that ๐‘ƒ = ๐‘ข1 ๐‘ข2 โ€ฆ ๐‘ข๐‘š is the decreasing path between ๐‘ข = ๐‘ข1 and a ๐‘-Root, ๐‘ข๐‘š . By corollary 2.10, ๐‘ƒ is the longest decreasing path beginning with ๐‘ข, and ๐‘โ€ฒ(๐‘ข ๐‘– ๐‘Ž ) < 0 if and only if ๐‘Ž = ๐‘ข๐‘–+1 , ๐‘Ž โˆˆ ๐‘(๐‘ฃ๐‘– ), 0 < ๐‘– < ๐‘š. So, โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— starting with ๐‘– = 1, we can find ๐‘ข๐‘–+1 when we have ๐‘ข๐‘– and compute ๐‘ƒ as follows. # Takes a vertex, ๐‘Ž, and returns ๐‘ and ๐‘ƒ(๐‘Ž, ๐‘) where ๐‘ is a ๐‘“-Root (๐‘“ = ๐‘ or ๐‘ž) ๐‘น๐’๐’๐’•_๐‘ท๐’‚๐’•๐’‰(๐‘Ž, ๐‘“) ๐‘ƒ(๐‘Ž, ๐‘) = ๐‘Ž1 = ๐‘Ž ๐‘ณ๐’‚๐’ƒ๐’๐’† ๐‘ญ๐’๐’“ ๐‘Ž๐‘–+1 โˆˆ ๐‘(๐‘Ž๐‘– )\๐‘Ž๐‘–โˆ’1 ๐’Š๐’‡ ๐‘“ โ€ฒ (๐‘Ž ๐‘– ๐‘Ž๐‘–+1 ) < 0. โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘ƒ(๐‘Ž, ๐‘) = ๐‘ƒ(๐‘Ž, ๐‘) โˆช ๐‘Ž๐‘–+1 ๐‘Ž๐‘– โ† ๐‘Ž๐‘–+1 ๐‘ฉ๐’“๐’†๐’‚๐’Œ ๐’‚๐’๐’… ๐‘ฎ๐’๐’•๐’ ๐‘ณ๐’‚๐’ƒ๐’๐’† ๐’“๐’†๐’•๐’–๐’“๐’ ๐‘Ž, ๐‘ƒ(๐‘Ž, ๐‘) 52 For finding ๐‘ข๐‘–+1 from ๐‘ข๐‘– , we can exclude ๐‘ข๐‘–โˆ’1 and jump to ๐‘ข๐‘–+1 as the process ๐‘น๐’๐’๐’•_๐‘ท๐’‚๐’•๐’‰ does. That reduces the average complexity. Moreover, when we are on the vertex ๐‘ข๐‘– , ๐‘– < ๐‘š, one takes at most |๐‘(๐‘ข๐‘– )| derivatives to find ๐‘ข๐‘–+1, since we know, ๐‘ข๐‘–+1 is the only vertex with negative derivatives toward it. So, ๐‘น๐’๐’๐’•_๐‘ท๐’‚๐’•๐’‰(๐‘ข, ๐‘) returns, ๐‘ƒ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ) by taking some derivatives, at most, as many as the total degree of the vertices on ๐‘ƒ ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ), where ๐‘ฅ is a ๐‘-Root. By [20], the path length in a tree is ๐‘‚(log ๐‘›) on average, where it can be ๐‘‚(1) as well. In addition, the average degree in a tree is ๐‘‚(1), and taking each derivative requires ๐‘‚(1)-time. Moreover, ๐‘ฅ is a ๐‘-Root (has min ๐‘) and ๐‘‡๐‘ข๐‘ฃ < ๐‘‡. Thus, the worst average run time of ๐‘น๐’๐’๐’•_๐‘ท๐’‚๐’•๐’‰(๐‘ข, ๐‘) is ๐‘‚(log ๐‘›) and the best average time is ๐‘‚(1). Similarly, ๐‘น๐’๐’๐’•_๐‘ท๐’‚๐’•๐’‰(๐‘ฃ, ๐‘ž) has the same run time to return ๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ) where ๐‘ฆ is a ๐‘ž-Root. ๐’™ ๐’š 5-Computing โˆซ๐’– ๐’‘โ€ฒ๐’…๐‘ป๐’—๐’– and โˆซ๐’— ๐’’โ€ฒ๐’…๐‘ป๐’–๐’— in ๐‘ถ(|๐‘ท(๐’–, ๐’™)|)-time and ๐‘ถ(|๐‘ท(๐’—, ๐’š)|)-time, respectively. By definition 2.12, theorem 2.13, and 1-, if we have a path, ๐‘ƒ = ๐‘Ž1 ๐‘Ž2 โ€ฆ ๐‘Ž๐‘š , we can compute the integral of ๐‘ƒ in ๐‘‚(๐‘š)-time as follows. # Takes a path ๐‘ƒ and ๐‘“ and returns โˆซ๐‘ƒ ๐‘“โ€ฒ (๐‘“ = ๐‘ or ๐‘ž) ๐‘ฐ๐’๐’•๐’†๐’ˆ (๐‘ƒ = ๐‘Ž1 ๐‘Ž2 โ€ฆ ๐‘Ž๐‘š , ๐‘“) ๐‘Ž โˆซ๐‘Ž1 ๐‘“ โ€ฒ ๐‘‘ = 0 ๐‘š ๐‘ญ๐’๐’“ 0 < ๐‘– < ๐‘š ๐‘Ž โˆซ๐‘Ž1 ๐‘“ โ€ฒ ๐‘‘ += ๐‘“โ€ฒ(๐‘Ž ๐‘š ๐‘– ๐‘Ž๐‘–+1 ). ๐‘ค(๐‘Ž๐‘– ๐‘Ž๐‘–+1 ) โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ—โƒ— ๐‘Ž ๐’“๐’†๐’•๐’–๐’“๐’ โˆซ๐‘Ž ๐‘š ๐‘“ โ€ฒ ๐‘‘ 1 6-Updating ๐‘ญ๐‘ป to ๐‘ญ๐‘ป๐’™๐’š\๐’–๐’— and ๐‘ต๐‘ป to ๐‘ต๐‘ป๐’™๐’š\๐’–๐’— in ๐‘ถ(|๐‘ท(๐’–, ๐’™)|)+๐‘ถ(|๐‘ท(๐’—, ๐’š)|) time. By lemma 4.5, ๐‘ผ๐’‘_๐‘ญ๐‘ต(๐‘ƒ(๐‘ข, ๐‘ฅ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), ๐‘›๐‘ข๐‘‡ (๐‘ฃ)) and ๐‘ผ๐’‘_๐‘ญ๐‘ต(๐‘ƒ(๐‘ฃ, ๐‘ฆ), ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘ฃ๐‘‡ (๐‘ข)) updates ๐‘ญ๐‘ป to ๐‘ญ๐‘ป๐’™๐’š\๐’–๐’— and ๐‘ต๐‘ป to ๐‘ต๐‘ป๐’™๐’š\๐’–๐’— , where ๐‘ผ๐’‘_๐‘ญ๐‘ต is a process as follows. 53 # Takes a path and updates ๐น๐‘‡ and ๐‘๐‘‡ accordingly ๐‘ผ๐’‘_๐‘ญ๐‘ต(๐‘ƒ = ๐‘ฃ1 ๐‘ฃ2 โ€ฆ ๐‘ฃ๐‘š , ๐น, ๐‘) ๐‘ญ๐’๐’“ 0 < ๐‘– < ๐‘š ๐‘ฃ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–+1๐‘– )) โ† (๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐‘, ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘–+1๐‘– ) + ๐‘) ๐‘ฃ ๐‘ฃ ๐‘ฃ ๐‘ฃ (๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– )) โ† (๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–๐‘–+1 ) โˆ’ ๐น, ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘–+1 ๐‘– ) + ๐น) Using the devised procedures in 1- to 6-, we can implement lemma 4.4 and 4.5, which finds us ๐œ–, ๐‘‡๐œ–\๐‘’ , ๐‘„๐‘‡๐œ–\๐‘’ , and ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐œ–\๐‘’ ), for the input ๐‘’ โˆˆ ๐ธ(๐‘‡) and ๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0 , where ๐œ– is a BS of ๐‘’ w.r.t ๐‘Š๐›ผ,๐›ฝ and ๐‘ค๐‘‡๐œ–\๐‘’ (๐œ–) = ๐‘ค. The full detail is presented with the following algorithm: BS algorithm. Each line's average time complexity bound is shown from the results BS Algorithm Input: 1. Adj list of a (๐‘“๐‘‡ , ๐‘ค๐‘‡ )-weighted tree ๐‘‡, 2. ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), 3. ๐‘„๐‘‡ , 4. ๐‘ค, ๐›ผ, ๐›ฝ โˆˆ โ„+ Output: 1. ๐‘ฅ๐‘ฆ, where ๐‘ฅ๐‘ฆ is a BS of ๐‘ข๐‘ฃ w.r.t. ๐‘Š๐›ผ,๐›ฝ and ๐‘ค๐‘‡ (๐‘ฅ๐‘ฆ) = ๐‘ค 2. ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ , 3. ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ), 4. ๐‘„๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ , Preprocessing--------------------------------------------------------------------------------------- Compute ๐‘„๐‘‡ = {๐น๐‘‡ , ๐‘๐‘‡ , ๐‘Šร— (๐‘‡), ๐‘Š+ (๐‘‡)} #๐‘‚(๐‘›) corollary 2.6 & lemma 4.6 54 ----------Finding ๐‘ฅ, ๐‘ฆ, ๐‘ƒ(๐‘ข, ๐‘ฅ) and ๐‘ƒ(๐‘ฃ, ๐‘ฆ) where ๐‘ฅ๐‘ฆ is a BS of ๐‘ข๐‘ฃ; (lemma 4.5 )--------- ๐’Š๐’‡ ๐‘ฐ๐‘บ_๐‘น๐’๐’๐’•(๐‘ข, ๐‘) ๐‘Ž๐‘›๐‘‘ ๐‘ฐ๐‘บ_๐‘น๐’๐’๐’•(๐‘ฃ, ๐‘ž) #๐‘‚(1) { ๐‘Ž , ๐‘ข๐‘Ž โ† ๐‘ญ๐‘ต๐‘ซ_๐’Ž๐’Š๐’(๐‘ข, ๐‘) #๐‘‚(1) ๐‘ , ๐‘ฃ๐‘ โ† ๐‘ญ๐‘ต๐‘ซ_๐’Ž๐’Š๐’(๐‘ฃ, ๐‘ž) #๐‘‚(1) โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ฃ๐‘) < ๐‘โ€ฒ (๐‘ข๐‘Ž ๐’Š๐’‡ ๐‘ž โ€ฒ (๐‘ฃ๐‘ โƒ—โƒ—โƒ—โƒ— )๐‘ค๐‘‡ (๐‘ข๐‘Ž) #๐‘‚(1) {๐‘ฅ, ๐‘ƒ(๐‘ข, ๐‘ฅ) โ† ๐‘ข, ๐‘ข ๐‘ฆ, ๐‘ƒ(๐‘ฃ, ๐‘ฆ) โ† ๐‘, ๐‘ฃ๐‘} ๐’†๐’๐’”๐’† {๐‘ฅ, ๐‘ƒ(๐‘ข, ๐‘ฅ) โ† ๐‘Ž, ๐‘ข๐‘Ž ๐‘ฆ, ๐‘ƒ(๐‘ฃ, ๐‘ฆ) โ† ๐‘ฃ, ๐‘ฃ} } ๐’†๐’๐’”๐’† {๐‘ฅ, ๐‘ƒ(๐‘ข, ๐‘ฅ) โ† ๐‘น๐’๐’๐’•_๐‘ท๐’‚๐’•๐’‰(๐‘ข, ๐‘) # ๐‘‚(log ๐‘›) on ave ๐‘ฆ, ๐‘ƒ(๐‘ฃ, ๐‘ฆ) โ† ๐‘น๐’๐’๐’•_๐‘ท๐’‚๐’•๐’‰(๐‘ฃ, ๐‘ž)} # ๐‘‚(log ๐‘›) on ave ----------------Computing ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ )-------( lemma 4.4 )-------------------------------- โ€ฒ ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘ฐ๐’๐’•๐’†๐’ˆ(๐‘ƒ(๐‘ข, ๐‘ฅ), ๐‘๐›ผ,๐›ฝ ) + ๐‘ฐ๐’๐’•๐’†๐’ˆ(๐‘ƒ(๐‘ฃ, ๐‘ฆ), ๐‘ž๐›ผ,๐›ฝ ) + ๐น๐‘๐›ผ,๐›ฝ (๐‘ข๐‘ฃ)[๐‘ค โˆ’ ๐‘ค๐‘‡ (๐‘ข๐‘ฃ)] #๐‘‚(|๐‘ƒ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ)|) + ๐‘‚(|๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ)|) ๐‘Š๐›ผ,๐›ฝ (๐‘‡) = ๐›ผ๐‘Šร— (๐‘‡) + ๐›ฝ๐‘Š+ (๐‘‡) #๐‘‚(1) โ€ฒ ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Š๐›ผ,๐›ฝ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ )+๐‘Š๐›ผ,๐›ฝ (๐‘‡) #๐‘‚(1) -------- ๐‘„๐‘‡ โ† ๐‘„๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ---------updating ๐‘„๐‘‡ --------( lemma 4.5 )---------------------------------- ๐‘ผ๐’‘_๐‘ญ๐‘ต(๐‘ƒ(๐‘ข, ๐‘ฅ), ๐‘“๐‘‡ (๐‘‡๐‘ฃ๐‘ข ), ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )) โˆง ๐‘ผ๐’‘_๐‘ญ๐‘ต(๐‘ƒ(๐‘ฃ, ๐‘ฆ), ๐‘“๐‘‡ (๐‘‡๐‘ข๐‘ฃ ), ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )) # ๐‘‚(|๐‘ƒ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ)| + |๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ)|) โ€ฒ ๐‘Š1,0 (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Šร—โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘ฐ๐’๐’•๐’†๐’ˆ(๐‘ƒ(๐‘ข, ๐‘ฅ), ๐‘1,0 ) + ๐‘ฐ๐’๐’•๐’†๐’ˆ(๐‘ƒ(๐‘ฃ, ๐‘ฆ), ๐‘ž1,0 ) + ๐น๐‘1,0 (๐‘ข๐‘ฃ)[๐‘ค โˆ’ ๐‘ค๐‘‡ (๐‘ข๐‘ฃ)] # ๐‘‚(|๐‘ƒ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ)| + |๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ)|) 55 โ€ฒ ๐‘Š0,1 (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Š+โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘ฐ๐’๐’•๐’†๐’ˆ(๐‘ƒ(๐‘ข, ๐‘ฅ), ๐‘0,1 ) + ๐‘ฐ๐’๐’•๐’†๐’ˆ(๐‘ƒ(๐‘ฃ, ๐‘ฆ), ๐‘ž0,1 ) + ๐น๐‘0,1 (๐‘ข๐‘ฃ)[๐‘ค โˆ’ ๐‘ค๐‘‡ (๐‘ข๐‘ฃ)] # ๐‘‚(|๐‘ƒ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ)| + |๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ)|) ๐‘Šร— (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Šร—โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ )โˆ’๐‘Šร— (๐‘‡) #๐‘‚(1) ๐‘Š+ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = ๐‘Š+โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ )โˆ’๐‘Š+ (๐‘‡) #๐‘‚(1) ---------๐‘‡ โ† ๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ --------------- ๐‘‡ โ† ๐‘‡ + ๐‘ฅ๐‘ฆ โˆ’ ๐‘ข๐‘ฃ #๐‘‚(1) Using 1- to 6-, the average time complexity of every line of the BS algorithm is bounded by, max{ ๐‘‚(|๐‘ƒ ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ)|, ๐‘‚(|๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ)|}. By [20], the average path length of ๐‘‡ is ๐‘‚(log ๐‘›) which accounts for the worst average time complexity of the algorithm. The best average complexity can be ๐‘‚(1), because max{ ๐‘‚(|๐‘ƒ ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ)|, ๐‘‚(|๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ)|} and the degrees on ๐‘ƒ๐‘‡๐‘ข๐‘ฃ (๐‘ข, ๐‘ฅ) and ๐‘ƒ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ, ๐‘ฆ) can be ๐‘‚(1). Finally, assume ๐‘‡โ€ฒ is a tree and we have the preprocessing, ๐‘„ ๐‘‡ โ€ฒ = {๐น๐‘‡ โ€ฒ , ๐‘ ๐‘‡ โ€ฒ , ๐‘Šร— (๐‘‡ โ€ฒ ), ๐‘Š+ (๐‘‡ โ€ฒ )}. If we change the weight of one edge, then ๐น ๐‘‡ โ€ฒ and ๐‘ ๐‘‡ โ€ฒ remain unchanged, and by corollary 4.7, we can update ๐‘Šร— and ๐‘Š+ in ๐‘‚(1)-time. This completes the proof. โ–  The subsequent two propositions can be proved based on proposition 4.9. They are about solving problems 4.1 (OBS) and 4.2 (ABS), respectively. Proposition 4.10: Let ๐‘‡ be an ๐‘›-vertex positively weighted tree with ๐ธ(๐‘‡) = {๐‘’๐‘– }๐‘›๐‘–=1 . If we get {๐‘ค๐‘– , ๐›ผ๐‘– , ๐›ฝ๐‘– โˆˆ โ„โ‰ฅ0 }๐‘›๐‘–=1, then we can find an๐‘Ÿ such that ๐‘Š๐›ผ๐‘Ÿ ,๐›ฝ๐‘Ÿ (๐‘‡๐œ–๐‘Ÿ \๐‘’๐‘Ÿ ) = ๐‘š๐‘–๐‘›{๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– (๐‘‡๐œ–๐‘– \๐‘’๐‘– )}๐‘›๐‘–=1 and compute ๐‘Š๐›ผ๐‘Ÿ ,๐›ฝ๐‘Ÿ (๐‘‡๐œ–๐‘Ÿ \๐‘’๐‘Ÿ ), in an average time of ๐‘‚(๐‘› log ๐‘›) and the best time of ๐‘‚(๐‘›), where ๐œ–๐‘– with ๐‘ค๐‘– = ๐‘ค(๐œ–๐‘– ) is a BS of ๐‘’๐‘– w.r.t. ๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– , 0 โ‰ค ๐‘– โ‰ค ๐‘›. โ–  Proposition 4.11: Let ๐‘‡ be an ๐‘›-vertex positively weighted tree with ๐ธ(๐‘‡) = {๐‘’๐‘– }๐‘›๐‘–=1 . If we get {๐‘ค๐‘– , ๐›ผ๐‘– , ๐›ฝ๐‘– โˆˆ โ„}๐‘›๐‘–=1 , then we can find a BS, ๐œ–๐‘– with ๐‘ค๐‘– = ๐‘ค(๐œ–๐‘– ) w.r.t. ๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– for all ๐‘’๐‘– and compute ๐‘Š๐›ผ๐‘– ,๐›ฝ๐‘– (๐‘‡๐œ–๐‘– \๐‘’๐‘– ), 0 โ‰ค ๐‘– โ‰ค ๐‘›, in an average time of ๐‘‚(๐‘› log ๐‘›) and the best time of ๐‘‚(๐‘›). โ–  56 For simplicity, we avoided adding some facts for better performance of the BS algorithm. For example, by corollary 2.10, a leaf is not a Root of a tree with more than 2 vertices. In the BS algorithm, we either require a Root or a neighbor of a Root. Thus, if ๐‘‡๐‘ข๐‘ฃ or ๐‘‡๐‘ข๐‘ฃ are not trivial (single vertex), then the version of ๐‘‡ without the leaves can be used. That improves the actual performance of the BS algorithm. Proposition 4.12: For a simple tree ๐‘‡, there are most ๐‘Š(๐‘‡) distinct switches. More precisely, |{๐‘‡๐œ–\๐‘’ | (๐œ–, ๐‘’) โˆˆ ๐ธ(๐‘‡ ๐‘ โˆช ๐‘‡) ร— ๐ธ(๐‘‡) โˆง ๐‘‡๐œ–\๐‘’ is a switch}| = ๐‘Š(๐‘‡), and if ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ โˆช ๐‘‡) and ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), |{๐‘‡๐‘ฅ๐‘ฆ\๐‘’ | ๐‘’ โˆˆ ๐ธ(๐‘‡) โˆง ๐‘‡๐‘ฅ๐‘ฆ\๐‘’ is a switch }| = ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ), |{๐‘‡๐œ–\๐‘ข๐‘ฃ | ๐œ– โˆˆ ๐ธ(๐‘‡ ๐‘ โˆช ๐‘‡) โˆง ๐‘‡๐œ–\๐‘ข๐‘ฃ is a switch }| = ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ). ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ). Proof: Let ๐‘‡ be a simple tree. Using definition 1.6, ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ โˆช ๐‘‡) is a switch of ๐‘’ โˆˆ ๐ธ(๐‘‡), if and only if ๐‘’ โˆˆ ๐‘ƒ๐‘‡ (๐‘ฅ, ๐‘ฆ). Otherwise, ๐‘‡๐‘ฅ๐‘ฆ\๐‘’ is disconnected, indicating that it is not a switch. Therefore, there are exactly ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) distinct switches regarding ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ โˆช ๐‘‡). Thus, the total number of distinct switches is as follows: |{๐‘‡๐‘ฅ๐‘ฆ\๐‘’ | (๐‘ฅ๐‘ฆ, ๐‘’) โˆˆ ๐ธ(๐‘‡ ๐‘ โˆช ๐‘‡) ร— ๐ธ(๐‘‡) โˆง ๐‘‡๐‘ฅ๐‘ฆ\๐‘’ is a switch}| = โˆ‘ ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) = โˆ‘ ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) = ๐‘Š(๐‘‡). ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘ โˆช๐‘‡). {๐‘ฅ,๐‘ฆ}โІโˆˆ๐‘‰(๐‘‡) And |{๐‘‡๐‘ฅ๐‘ฆ\๐‘’ | ๐‘’ โˆˆ ๐ธ(๐‘‡) โˆง ๐‘‡๐‘ฅ๐‘ฆ\๐‘’ is a switch }| = ๐‘‘๐‘‡ (๐‘ฅ, ๐‘ฆ). In addition, ๐‘‡๐œ–\๐‘ข๐‘ฃ is a tree if and only if ๐œ– is an edge between ๐‘‡๐‘ข๐‘ฃ and ๐‘‡๐‘ฃ๐‘ข . Thus, |{๐‘‡๐œ–\๐‘ข๐‘ฃ | ๐œ– โˆˆ ๐ธ(๐‘‡ ๐‘ โˆช ๐‘‡) โˆง ๐‘‡๐œ–\๐‘ข๐‘ฃ is a switch }| = ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ). ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ). This completes the proof. โ–  ๐‘›2 For ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) of a simple tree ๐‘‡ with ๐‘› vertices, ๐‘› โˆ’ 1 โ‰ค ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ). ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) โ‰ค . Also, 4 by [10,11,17], (๐‘› โˆ’ 1)2 โ‰ค ๐‘Š(๐‘‡) โ‰ค (๐‘›+1 3 ). 57 4.3 Some Comparisons and Discussion In this section, we compare our method with some existing methods. For brevity, we mean average time complexity once we talk about complexity. The compared methods are not clearly solving the same problems that we did. But it is possible to convert them with some effort. The top tree method can find a positively weighted tree's median(s). It is almost equivalent to finding the Root of a tree in our method, disregarding ๐›ผ and ๐›ฝ. Thus, for an ๐‘›-vertex tree, ๐‘‡ and ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), we somehow can convert the top tree methods [7-9] to find a BS w.r.t. ๐‘Š๐›ผ=1,๐›ฝ=0 in ๐‘‚(log ๐‘›)-time for most cases. However, if ๐‘ข๐‘ฃ connects a Root of ๐‘‡๐‘ข๐‘ฃ and a Root of ๐‘‡๐‘ฃ๐‘ข , then the top tree method does not work. They also do not compute ๐‘Š๐›ผ,๐›ฝ of the switches regularly, which does not let us solve problem 2 even for their specific case of ๐›ผ = 1, ๐›ฝ = 0. Generalizing the top tree method, we may be able to solve problem 1 for a fixed ๐›ผ, ๐›ฝ and compute ๐‘Š๐›ผ,๐›ฝ , which is overcomplicated intuitively. But, if we renew the initial values of ๐›ผ, ๐›ฝ to some ๐›ผโ€ฒ, ๐›ฝโ€ฒ, then we have to repeat their ๐‘‚(๐‘›)-time preprocessing, which is costly. As we have seen, our method in BS algorithm solves โ€ฒ problem 1 in ๐‘‚(log ๐‘›) for any ๐›ผ, ๐›ฝ โˆˆ โ„โ‰ฅ0, computes ๐‘Š๐›ผ,๐›ฝ s and does not require a fresh preprocessing for the change of ๐›ผ, ๐›ฝ. Our method updates the preprocessing, ๐‘„๐‘‡ in ๐‘‚(1)- time after an edge weight change, whereas using top trees, an edge weight update takes up to ๐‘‚(log ๐‘›)-time. For another comparison, we borrow the solution of the best swap edge of multiple- source routing tree algorithms [15, 19-21, 29, 30] for problem 3. Suppose ๐‘‡ is a spanning tree of a positively edge-weighted graph ๐บ with ๐‘š edges and ๐‘› vertices. Then, in [15, 19- 21, 29, 30], researchers choose the BS from ๐ธ(๐บ) โˆ’ ๐ธ(๐‘‡), whereas we choose from ๐ธ(๐‘‡ ๐‘ ). Therefore, by choosing ๐บ to be ๐พ๐‘› , the mentioned algorithms can solve problem 3. Also, they choose the BS w.r.t. the routing cost rather than its generalization, ๐‘Š๐›ผ,๐›ฝ . Let ๐‘† โІ ๐‘‰(๐บ) be a set of sources and |๐‘†| > 1. Setting ๐‘“๐บ (๐‘ฃ) = 1 for all ๐‘ฃ โˆˆ ๐‘† and ๐‘“๐บ (๐‘ฃ) = 0 for all ๐‘ฃ โˆˆ ๐‘‰(๐บ)\๐‘†, results in 58 ๐‘Š1,โˆ’1 (๐บ) = ๐‘…๐ถ(๐บ, ๐‘†). That is, by specifying vertices weights as mentioned and letting ๐›ผ๐‘– = 1, ๐›ฝ๐‘– = โˆ’1 for 1 โ‰ค ๐‘– โ‰ค ๐‘›, and ๐บ = ๐พ๐‘› , algorithms of [20,21] will solve problem 3. The mentioned algorithms are expensive specifically for a single failed edge, and after updating the edge weights or inserting a BS, their ๐‘‚(๐‘›2 ) preprocessing is not valid. They do not also compute ๐‘Š๐›ผ,๐›ฝ โ€™s. More importantly, regarding the mentioned conversion, they solve problem 3 in more than ๐‘‚(๐‘›2 log ๐Ÿ ๐‘›)-time and up to ๐‘‚(๐‘›3 ) depending on the number of sources, where ๐›ผ๐‘– = 1, ๐›ฝ๐‘– = โˆ’1, 1 โ‰ค ๐‘– โ‰ค ๐‘› and sources are specified. In the terminology of [20-22], we do not limit the number of sources and, ๐›ผ๐‘– , ๐›ฝ๐‘– โˆˆ ๐‘… โ‰ฅ0 , 1 โ‰ค ๐‘– โ‰ค ๐‘› , where we attain an average time of ๐‘‚(๐‘› log ๐‘›) and the best time of ๐‘‚(๐‘›) for problem 3. As a general fact, note that choosing a brute-force strategy and distance matrix for the positively edge-weighted graph, computing ๐‘Š๐›ผ,๐›ฝ (๐‘‡) takes ๐‘‚(๐‘›3 ). Moreover, there are ๐‘›2 between ๐‘› โˆ’ 1 to switches regarding an edge. Therefore, using the bute-force strategy, 4 we will need between ๐‘‚(๐‘›4 ) to ๐‘‚(๐‘›5 ) time to compute a switch with the minimum ๐‘Š๐›ผ,๐›ฝ . While our method executes that in ๐‘‚(log ๐‘›), with the same flexibility. This difference is significant. Note that the existing discussed methods are comparable to ours with some constraints, but they have much less flexibility. Our tools is general and can be applied to similar optimization problems. For instance, see [15], where we use our method for the best swap edge of spanning trees. Another interesting problem can be solving the BS problems regarding ๐‘˜ ๐ท(๐‘‡) = ๐‘˜ โˆ‘{๐‘ข,๐‘ฃ}โІ๐‘‰(๐‘‡)(๐‘‘(๐‘ข, ๐‘ฃ)) by considering the weight ๐‘˜๐œŽ๐‘‡ (๐‘ฃ) = โˆ‘๐‘ฅโˆˆ๐‘‰(๐‘‡) ๐‘‘ ๐‘˜๐‘‡ (๐‘ฃ, ๐‘ฅ) for the vertices of a tree, ๐‘‡. See the appendix, where we have some computations related to the derivative and integral of, 2๐œŽ๐‘‡ . โ–ฒ Finding the minimum ๐‘-sources routing cost spanning tree is an ๐‘๐‘ƒ-hard problem for any ๐‘ > 1 and is a polynomial problem for ๐‘ = 1 [29-31]. 59 REFERENCES [1] Christos Alexopoulos, Jay A. Jacobson, State space partition algorithms for stochastic systems with applications to minimum spanning trees, Networks, 35 (2000), 118-138. [2] Furqan Aziz, Haji Gul, Irfan Uddin, Georgios V. Gkoutos, Path-based extensions of local link prediction methods for complex networks. Sci. Rep., 10 (2020), 19848. [3] Zhihao Dong, Yuanzhu Chen, Terrence S. Tricco, Cheng Li, Ting Hu, Hunting for vital nodes in complex networks using local information, Sci. Rep., 11 (2021), 9190. [4] William L. Hamilton, Rex Ying, Jure Leskovec, Inductive representation learning on large graphs. NIPSโ€™17: Proceedings of the 31st International Conference on Neural Information Processing Systems, (2017), 1025-1035. [5] Tao Zhou, Progresses and challenges in link prediction. iScience, 24 (2021), 103217. [6] A. Kanevsky, R. Tamassia, G. D. Battista, J. Chen, On-line maintenance of the four- connected components of a graph, In 32nd FOCS, (1991), 793-801. [7] S. Alstrup, J. Holm, K. de Lichtenberg, M. Thorup, Maintaining information in fully dynamic trees with top trees, ACM Trans. Algorithm, 1 (2005), 243-264. [8] S. Alstrup, J. Holm, M. Thorup, Maintaining center and median in dynamic trees. in: Proc. of the 8th Scandinavian Workshop on Algorithm Theory, (2000), 46-56. [9] Hung-Lung Wang, Maintaining centdians in a fully dynamic forest with top trees, Discrete App. Math., 181 (2015), 310-315. [10] H. N. Gabow, H. Kaplan, R. E. Tarjan, Unique maximum matching algorithms, J. Algorithms, 40 (2001), 159-183. [11] J. Holm, K. de Lichtenberg, M. Thorup, Poly-logarithmic deterministic fully-dynamic algorithms for connectivity, minimum spanning tree, 2-edge and biconnectivity, J. ACM., 48 (2001), 723-760. [12] E. Nardelli, G. Proietti, P. Widmayer, Finding all the best swaps of a minimum diameter spanning tree under transient edge failures, J. Graph Algorithms and Applications, 5 (2001), 39-57. 60 [13] Julien Baste, Didem Gรถzรผpek, Christophe Paul, Ignasi Sau, Mordechai Shalom, Dimitrios M. Thilikos, Parameterized complexity of finding a spanning tree with minimum reload cost diameter, Networks, 75 (2020), 259-277. [14] Davide Biloฬ€, Feliciano Colella, Luciano Gualaฬ€, Stefano Leucci, Guido Proietti, An Improved Algorithm for Computing All the Best Swap Edges of a Tree Spanner, Algorithmica, 82 (2020), 279-299. [15] Matteo Fischetti, Giuseppe Lancia, Paolo Serafini, Exact algorithms for minimum routing cost trees, Networks, 39 (2002), 161-173. [17] Beat Gfeller, Nicola Santoro, Peter Widmayer, A Distributed Algorithm for Finding All Best Swap Edges of a Minimum-Diameter Spanning Tree, IEEE Transactions on Dependable and Secure Computing, 8 (2011), 1-12. [18] Masayuki Kobayashi, Yoshio Okamoto, Submodularity of minimum-cost spanning tree games, Networks, 63 (2014), 231-238. [19] Seth Pettie, Sensitivity analysis of minimum spanning trees in sub-inverse-Ackermann time, In Proc. of the 16th Intl. Symposium on Algorithms and Computation, (2005), 964-973. [20] B.Y. Wu, G. Lancia, V. Bafna, K.-M. Chao, R. Ravi, C.Y. Tang, A polynomial time approximation scheme for minimum routing cost spanning trees, SIAM J. on Computing, 29 (1999), 761-778. [21] Davide Bilรฒ, Luciano Gualร , Guido Proietti, Finding Best Swap Edges Minimizing the Routing Cost of a Spanning Tree, Algorithmica, 68 (2014), 337-357. [22] B. Y. Wu, C. -Y. Hsiao, K.-M. Chao, The swap edges of a multiple-sources routing tree, Algorithmica, 50 (2008), 299-311. [23] M. H. Khalifeh, Abdol-Hossein Esfahanian; A Faster Algorithm for Finding Best Swap Edges of multiple-source Routing Tree, submitted [24] A. Meyerson, B. Tagiku, Minimizing Average Shortest Path Distances via Shortcut Edge Addition. Approximation, randomization, and combinatorial optimization, Algorithms and techniques. 12th international workshop, APPROX 2009, and 13th international workshop, RANDOM 2009, Berkeley, CA, USA, August 2123, (2009). Proceedings, 272-285. [25] H. Wiener, Structural determination of the paraffin boiling points, J. Am. Chem. Soc., 69 (1947), 17-20. 61 [26] Z. Shen, The average diameter of general tree structures, Comput. Math. Appl., 36 (1998), 111-130. [27] P. Dunklemann, R. C. Entringer, Average distance, minimum degree and spanning trees, J. Graph Theory, 33 (2000), 1-13. [28] Roger C. Entringer, Douglas E. Jackson, D. A. Snyder, Distance in graphs, Czech. Math. J., 26 (1976), 283-296. [29] B. D. McKay, The expected eigenvalue distribution of a large regular graph, Linear Algebra and its Applications, 40 (1981), 203-216. [30] Davide Biloฬ€, Luciano Gualaฬ€, Guido Proietti, A faster computation of all the best swap edges of a shortest paths tree, Algorithmica, 73 (2015), 547-570. [31] B.Y. Wu, A polynomial time approximation scheme for the two-source minimum routing cost spanning trees, J. of Algorithms, 44 (2002), 359-378. [32] B.Y. Wu, Approximation algorithms for the optimal p-source communication spanning tree, Discrete App. Math., 143 (2004), 31-42. [33] M. H. Khalifeh, Abdol-Hossein Esfahanian, Discrete Integral and Discrete Derivative on Graphs and Switch problems of Trees, Mathematics, Advances in Graph Theory: Algorithms and Applications, 11 (2023), 1678. 62 APPENDIX Let ๐‘‡ be a tree and ๐‘Ž๐‘ฅ โˆˆ ๐ธ(๐‘‡). Then, using the definition ( ๐‘˜๐œŽ๐‘‡ (๐‘ฃ) = โˆ‘๐‘ฅโˆˆ๐‘‰(๐‘‡) ๐‘‘ ๐‘˜๐‘‡ (๐‘ฃ, ๐‘ฅ), ๐‘ฃ โˆˆ ๐‘‰(๐‘‡)): 2 2 ๐œŽ๐‘‡ (๐‘Ž) = โˆ‘ ๐‘‘2๐‘‡ (๐‘Ž, ๐‘ฃ) + โˆ‘ [๐‘‘ 2๐‘‡ (๐‘ฅ, ๐‘ฃ) + (๐‘ค(๐‘Ž๐‘ฅ)) + 2๐‘ค(๐‘Ž๐‘ฅ)๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฃ)], ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘Ž ) ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘ฅ ) 2 2 ๐œŽ๐‘‡ (๐‘ฅ) = โˆ‘ [๐‘‘2๐‘‡ (๐‘Ž, ๐‘ฃ) + (๐‘ค(๐‘Ž๐‘ฅ)) + 2๐‘ค(๐‘Ž๐‘ฅ)๐‘‘ ๐‘‡ (๐‘Ž, ๐‘ฃ)] + โˆ‘ ๐‘‘ 2๐‘‡ (๐‘ฅ, ๐‘ฃ). ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘Ž ) ๐‘ฃโˆˆ๐‘‰(๐‘‡๐‘ฅ ) 2 2 โ€ฒ 2 ๐œŽ๐‘‡ (๐‘ฅ) โˆ’ 2๐œŽ๐‘‡ (๐‘Ž) (๐‘ค(๐‘Ž๐‘ฅ)) [๐‘›๐‘‡ (๐‘‡๐‘Ž๐‘ฅ ) โˆ’ ๐‘›๐‘‡ (๐‘‡๐‘ฅ๐‘Ž )] + 2๐‘ค(๐‘Ž๐‘ฅ)[๐œŽ ๐‘‡๐‘Ž๐‘ฅ (๐‘Ž) โˆ’ ๐œŽ ๐‘‡๐‘ฅ๐‘Ž (๐‘ฅ)] ๐œŽ๐‘‡ (๐‘Ž๐‘ฅ โƒ—โƒ—โƒ—โƒ— ) = = ๐‘ค๐‘‡ (๐‘Ž๐‘ฅ) ๐‘ค๐‘‡ (๐‘Ž๐‘ฅ) = ๐‘ค(๐‘Ž๐‘ฅ)๐œŽ๐‘‡โ€ฒ (๐‘Ž๐‘ฅ) + 2[๐œŽ ๐‘‡๐‘Ž๐‘ฅ (๐‘Ž) โˆ’ ๐œŽ ๐‘‡๐‘ฅ๐‘Ž (๐‘ฅ)] Also, one can use the same idea of Eq. 4.3 and see that, 2 ๐ทโ€ฒ (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = 2๐ท(๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) โˆ’ 2๐ท(๐‘‡) = 2[๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ฅ)๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฆ) โˆ’ ๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ข)๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ)] + ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ). ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )[๐‘ค(๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค(๐‘ข๐‘ฃ)] + ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) [ 2๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ฅ) โˆ’ 2๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ข)] + ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )[ 2๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฆ) โˆ’ 2๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ)] + 2๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) [๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ฅ) โˆ’ ๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ข)] + 2๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ )[๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ฆ) โˆ’ ๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฆ)]. We had that, ๐œŽ๐‘‡โ€ฒ is consistence, thus by theorem 2.13, ๐‘ฅ ๐‘ฆ โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ = ๐œŽ (๐‘ฅ) โˆ’ ๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ข), ๐‘‡๐‘ข๐‘ฃ and โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข = ๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฆ) โˆ’ ๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ). ๐‘ข ๐‘ฃ Therefore, ๐‘ฅ ๐‘ฆ 2 โ€ฒ ๐ท (๐‘‡๐‘ฅ๐‘ฆ\๐‘ข๐‘ฃ ) = 2 [(โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ข๐‘ฃ ๐‘‘๐‘‡๐‘ข๐‘ฃ + ๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ข))(โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข + ๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ)) โˆ’ ๐œŽ ๐‘‡๐‘ข๐‘ฃ (๐‘ข)๐œŽ ๐‘‡๐‘ฃ๐‘ข (๐‘ฃ)] ๐‘ข ๐‘ฃ ๐‘ฅ ๐‘ฆ ๐‘ฅ + ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) [โˆซ 2๐œŽ๐‘‡โ€ฒ๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ ] + ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) [โˆซ 2๐œŽ๐‘‡โ€ฒ๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข ] + 2๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ) [โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ข๐‘ฃ ๐‘‘ ๐‘‡๐‘ข๐‘ฃ ] ๐‘ข ๐‘ฃ ๐‘ข ๐‘ฆ + 2๐‘› ๐‘‡ (๐‘‡๐‘ฃ๐‘ข ) [โˆซ ๐œŽ๐‘‡โ€ฒ๐‘ฃ๐‘ข ๐‘‘ ๐‘‡๐‘ฃ๐‘ข ] + ๐‘›๐‘‡ (๐‘‡๐‘ข๐‘ฃ ). ๐‘›๐‘‡ (๐‘‡๐‘ฃ๐‘ข )[๐‘ค(๐‘ฅ๐‘ฆ) โˆ’ ๐‘ค(๐‘ข๐‘ฃ)]. ๐‘ฃ 63 CHAPTER 5: DISTANCE PRESERVING GRAPHS AND ๐œน 5.1 Introduction In this short chapter, we will have an asymptotic approach to problem 5, if ๐›ฟ(๐บ) > |๐‘‰(๐บ)| for the graph ๐บ, then it is dp. As mentioned, the result may help to minimize the 2 potential mutations leading to a graph being dp. By definition, dh graphs are a subset of sdp graphs, and dp graphs are a subset of dp graphs. Problem 5 comes from [8], which is minimal regarding the minimum degree of a graph with dp property. ๐‘› Problem 3([8]): Let ๐บ be an ๐‘›โ€vertex graph with ๐›ฟ(๐บ) > . Then ๐บ is dp. โ–ฒ 2 In contrast, we have the following result from [7]. ๐‘› Proposition 5.1([7]): For any integer ๐‘› โ‰ฅ 5, and 2 โ‰ค ๐‘Ÿ < 2, where ๐‘Ÿ is even, there exists an ๐‘Ÿโ€regular graph on ๐‘› vertices without any isometric subgraph of order ๐‘› โˆ’ 1.โ–  The best known bound which implies that an ๐‘›โ€vertex graph ๐บ is distance preserving 2 is ๐›ฟ(๐บ) โ‰ฅ 3 ๐‘› โˆ’ 1, see [7]. The graphs which satisfy that bound also have additional properties [2,3,7]. Determining whether or not a graph is dh is linear [7]. That is an ๐‘๐‘ƒโ€ complete problem for the case of sdp [3]. For more detail and background, see [1,2,5,6]. We have an asymptotic approach to conjecture 5.1, that is, for graph ๐บ, if ๐›ฟ(๐บ) > (1 + ๐‘› ๐œ€) 2 and ๐œ€ > 0, there is ๐‘ such that if |๐‘‰(๐บ)| > ๐‘, then ๐บ is dp. In this chapter, by [๐‘Ž, ๐‘], we mean the set of all integers of the interval. Also, when there is no ambiguity, ๐›ฟ stands for ๐›ฟ(๐บ) in a graph ๐บ. Lemma 5.2 ([7]): A graph ๐บ has an isometric subgraph of order ๐‘Ÿ, for any ๐‘Ÿ โˆˆ [1, โˆ†(๐บ) + 1]. โ–  64 We use an estimation for ๐‘›! using a continuous function. Lemma 5.3 (Sterlingโ€™s Approximation): Suppose ๐‘› is an integer. Then, ๐‘› ๐‘› ๐‘›! โ†’ โˆš2๐œ‹๐‘› ( ๐‘’ ) as ๐‘› โ†’ โˆž. โ–  5.2 On Distance Preserving Conjecture Theorem 5.4: For every ๐œ– > 0 there is integer ๐‘ > 0 such that every graph ๐บ with 1 ๐‘› โ‰ฅ ๐‘ vertices and ๐›ฟ โ‰ฅ ( + ๐œ€)๐‘› is dp. 2 ๐‘› Proof: Suppose ๐บ is a graph on ๐‘› vertices and ๐›ฟ > 2. If ๐‘ฃ โˆˆ ๐‘‰(๐บ) then for any set ๐ด with {๐‘ฃ} โІ ๐ด โІ ๐‘๐บ [๐‘ฃ], ๐ป = ๐บ[๐ด] is a subgraph of ๐บ with diam(๐ป) โ‰ค 2. It is easy to see that ๐ป โ‰ค ๐บ. That guarantees that ๐บ has an isometric subgraph of order ๐‘˜ for every ๐‘˜ โˆˆ [1, ๐›ฟ + 1], (also by lemma 5.2). As ๐บ โ‰ค ๐บ, it remains to prove ๐บ has an isometric subgraph of order ๐‘˜ for every ๐‘˜ โˆˆ [๐›ฟ + 2, ๐‘› โˆ’ 1] to conclude that ๐บ is distance preserving. For ๐›ฟ > ๐‘› โˆ’ 3, [๐›ฟ + 2, ๐‘› โˆ’ 1] is empty; therefore, it is enough to consider the graphs ๐บ with ๐›ฟ โˆˆ ๐‘› ๐‘› [2 + 1, ๐‘› โˆ’ 3]. And for a graph ๐บ with ๐›ฟ โˆˆ [ 2 + 1, ๐‘› โˆ’ 3], by Pigeonhole Principle, diam(๐บ) = 2, and any induced non-isometric subgraph of ๐บ has a diameter bigger than two. Now assume toward a contradiction that ๐บ does not have an isometric subgraph of order ๐‘˜ for some ๐‘˜ โˆˆ [๐›ฟ + 2, ๐‘› โˆ’ 1]. Letting ๐‘Ÿ = ๐‘› โˆ’ ๐‘˜, ๐‘Ÿ โˆˆ [1, ๐‘› โˆ’ ๐›ฟ โˆ’ 2], this assumption is equivalent to saying that there is ๐‘Ÿ โˆˆ [1, ๐‘› โˆ’ ๐›ฟ โˆ’ 2] such that for every ๐ด โˆˆ ๐‘ƒ๐‘Ÿ (๐‘‰(๐บ)) we have at least one pair {๐‘ฅ, ๐‘ฆ} โІ ๐‘‰(๐บ โˆ’ ๐ด) with ๐‘‘๐บโˆ’๐ด (๐‘ฅ, ๐‘ฆ) > 2 and ๐‘‘๐บ (๐‘ฅ, ๐‘ฆ) = 2. Such pairs will be called bad pairs. Given such an ๐‘Ÿ, we will find a lower bound for the number of distinct bad pairs. To do this, we require to count the number of elements ๐ด โˆˆ ๐‘ƒ๐‘Ÿ (๐‘‰(๐บ)) such that for a specific ๐‘› pair {๐‘ฅ, ๐‘ฆ} โŠ‚ ๐‘‰(๐บ โˆ’ ๐ด) we have ๐‘‘๐บโˆ’๐ด (๐‘ฅ, ๐‘ฆ) > 2. First, note that ๐›ฟ > forces ๐‘†: = ๐‘๐บ (๐‘ฅ) โˆฉ 2 ๐‘๐บ (๐‘ฆ) โ‰  โˆ…. In addition, if for ๐ด โˆˆ ๐‘ƒ๐‘Ÿ (๐‘‰(๐บ)) we have ๐‘‘๐บโˆ’๐ด (๐‘ฅ, ๐‘ฆ) > 2 then it must be that 65 ๐‘† โІ ๐ด and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐บ ๐‘ ). So given ๐‘ฅ, ๐‘ฆ, and thus ๐‘†, the number of ways to pick an ๐‘Ÿ-element ๐‘› set ๐ด with ๐‘† โІ ๐ด โІ ๐‘‰ โˆ’ {๐‘ฅ, ๐‘ฆ} is exactly ๐‘“|๐‘†| = (๐‘›โˆ’|๐‘†|โˆ’2 ๐‘Ÿโˆ’|๐‘†| ). Moreover ๐›ฟ > implies |๐‘†| โ‰ฅ 2 2๐›ฟ โˆ’ ๐‘› + 2, and it is easy to see that ๐‘“|๐‘†| is decreasing in this domain. Therefore for a given ๐‘Ÿ and a pair ๐‘ฅ, ๐‘ฆ โˆˆ ๐‘‰(๐บ), there are at most ๐‘“2๐›ฟโˆ’๐‘›+2 elements like ๐ด โˆˆ ๐‘ƒ๐‘Ÿ (๐‘‰(๐บ)) such that ๐‘‘๐บ โˆ’ ๐ด (๐‘ฅ, ๐‘ฆ) > 2 in the graphs ๐บ โˆ’ ๐ด. This upper bound means we have at least |๐‘ƒ๐‘Ÿ(๐‘‰(๐บ)) | (๐‘›๐‘Ÿ) ๐‘”(๐‘›, ๐‘Ÿ, ๐›ฟ) = โŒŠ โŒ‹ = โŒŠ 2๐‘›โˆ’2๐›ฟโˆ’4 โŒ‹ ๐‘“2๐›ฟโˆ’๐‘›+2 ( ) ๐‘›+๐‘Ÿโˆ’2๐›ฟโˆ’2 bad pairs. Moreover, we saw that bad pairs, ๐‘ฅ๐‘ฆ, belong to ๐ธ(๐บ ๐‘ ). It follows that ๐ธ(๐บ ๐‘ ) โ‰ฅ ๐‘”(๐‘›, ๐‘Ÿ, ๐›ฟ). On the other hand, using the fact that summing the degrees of a graph gives twice the number of edges, ๐‘› |๐ธ(๐บ ๐‘ )| โ‰ค (๐‘› โˆ’ ๐›ฟ โˆ’ 1). 2 ๐‘› We now wish to show that for every ๐‘Ÿ โˆˆ [1, ๐‘› โˆ’ ๐›ฟ โˆ’ 2], ๐‘”(๐‘›, ๐‘Ÿ, ๐›ฟ) > 2 (๐‘› โˆ’ ๐›ฟ โˆ’ 1) which will result in a contradiction to the two previous inequalities. That implies that ๐บ has at least one isometric subgraph of order ๐‘˜ for every ๐‘˜ โˆˆ [๐›ฟ + 2, ๐‘›]. But instead we 1 choose ๐‘Ÿโ€ฒ = ๐‘› โˆ’ ๐›ฟโ€ฒ โˆ’ 2 where ๐›ฟโ€ฒ = (2 + ๐œ€)๐‘› and ๐œ– is an appropriate positive number. Now ๐‘› ๐‘› using Stirling's approximation, ๐‘›! โ‰… โˆš2๐œ‹๐‘› ( ๐‘’ ) , we can see that: โ€ฒ โ€ฒ) (๐‘›โˆ’๐›ฟ๐‘›โ€ฒ โˆ’2) โˆ1๐‘–=0(๐‘› โˆ’ ๐›ฟโ€ฒ โˆ’ ๐‘– ) โˆ3๐‘–=0(2๐‘› โˆ’ 2๐›ฟ โ€ฒ โˆ’ ๐‘–) ๐‘›! (2๐‘› โˆ’ 3๐›ฟ โ€ฒ )! ๐‘”(๐‘›, ๐‘Ÿ , ๐›ฟ =โŒŠ โŒ‹= โŒŠ . โŒ‹ (2๐‘›โˆ’2๐›ฟ โ€ฒ โˆ’4 โ€ฒ ) โˆ2๐‘–=1(๐›ฟ โ€ฒ + ๐‘–) โˆ3๐‘–=0(2๐‘› โˆ’ 3๐›ฟ โ€ฒ โˆ’ ๐‘–) (๐‘› โˆ’ ๐›ฟ โ€ฒ )! (2๐‘› โˆ’ 2๐›ฟ โ€ฒ )! 2๐‘›โˆ’3๐›ฟ โˆ’4 ๐‘› ๐‘› ๐‘› 2 โˆ’3๐œ€ ๐‘› โˆš๐‘›( 2 โˆ’ 3๐œ€ ๐‘›) ๐‘› ๐‘› ( 2 โˆ’ 3๐œ€ ๐‘›) > ๐‘› ๐‘› โˆ’๐œ€ ๐‘› โˆš( โˆ’ ๐œ€ ๐‘›) (๐‘› โˆ’ 2๐œ€ ๐‘›) (๐‘› โˆ’ ๐œ€ ๐‘›) 2 (๐‘› โˆ’ 2๐œ€ ๐‘›)๐‘› โˆ’2๐œ€ ๐‘› 2 2 66 1 ๐‘› โˆ’3๐œ€ ๐œ€ 1 โˆ’ 6๐œ€ 2 โ‰ˆ (4 . ( ) ) . 1 โˆ’ 6๐œ€ + 12๐œ€ 2 โˆ’ 8๐œ€ 3 Therefore, choosing any ๐œ€ > 0, ๐‘”(๐‘›, ๐‘Ÿ โ€ฒ , ๐›ฟ โ€ฒ ) โˆ ๐‘ ๐‘› , for some ๐‘ > 1. And this means there ๐‘› is ๐‘ such that ๐‘”(๐‘›, ๐‘Ÿ โ€ฒ , ๐›ฟ โ€ฒ ) > 2 (๐‘› โˆ’ ๐›ฟ โ€ฒ โˆ’ 1) โ‰ฅ |๐ธ(๐บ ๐‘ )| when ๐‘› โ‰ฅ ๐‘. Surprisingly one can see that ๐‘”(๐‘›, ๐‘Ÿโ€ฒ, ๐›ฟโ€ฒ) is decreasing on ๐‘Ÿ โ€ฒ โˆˆ [1, ๐‘› โˆ’ ๐›ฟ โˆ’ 2]. Accordingly, |๐ธ(๐บ ๐‘ )| < ๐‘”(๐‘›, ๐‘Ÿโ€ฒ, ๐›ฟโ€ฒ) for ๐‘Ÿ โ€ฒ โˆˆ [1, ๐‘› โˆ’ ๐›ฟโ€ฒ โˆ’ 2], and this completes the proof. โ–  Remark 5.5: One may require an estimation for ๐œ€ and ๐‘. Using |๐ธ(๐บ ๐‘ )| and the log๐‘ latest displayed inequality ๐œ€ โ‰ˆ ๐‘‚( ). But if we require the smallest ๐‘ regarding an ๐œ€, ๐‘ for actual goals, then we should find the smallest integer which confirms the function ๐‘” is greater than the |๐ธ(๐บ ๐‘ )|. โ–ฒ 67 REFERENCES [1] V. Chepoi, Distanceโ€preserving subgraphs of Johnson graphs, Combinatorica, 37 (2017), 1039-1055. [2] V. Chepoi, On distanceโ€preserving and domination orderings, SIAM J. Discr. Math., 11 (1998), 414-436. [3] D. Coudert et al., Distanceโ€preserving orderings in graphs. RRโ€8973, Inria Sophia Antipolis, (2016). [4] G. Damiand, M. Habib, C. Paul, A simple paradigm for graph recognition: application to cographs and distance hereditary graphs, Theoretical Computer Science, 263 (2001), 99- 111. [5] D. Z. Djokovic, Distanceโ€preserving subgraphs of hypercubes, J. Combin. Theory Ser. B., 14 (1973), 263-267. [7] R. L. Graham, P. M. Winkler, On isometric embeddings of graphs, Trans. Amer. Math. Soc., 288 (1985), 527-536. [8] R. Nussbaum, Distanceโ€Preserving Graphs, Ph.D. Thesis, Diss. Michigan State University, 2014. [9] R. Nussbaum, Abdol-Hossein Esfahanian, Preliminary results on distanceโ€preserving graphs, Congressus Numerantium, 211 (2012), 141-149. 68 CHAPTER 6: INSET EDGE OF TREES AND WIENER INDEX 6.1 Introduction Average distance, degree distribution, and clustering coefficient are the three most robust network topology measures. The sensitivity of the average distance of a network, both after missing a link and adding a link, is interesting for researchers [3-7, 12]. In this chapter, we work on simple graphs. By definition, an added edge to a graph is an inset edge, which is a mutation. The average distance of a graph is the average of the distances between every pair of vertices with finite distances [2]. Predicting ๐‘˜ > 1 inset edges, which minimize the average distance of a simple graph, is known to be NP-Hard [14], which is a polynomial problem for ๐‘˜ = 1. Solving the problem for the trees fast enough may speed up the solution for the graphsโ€™ inset edges via spanning tree sampling. This chapter first establishes some tools for precisely analyzing the effect of inset edges on the tree's average distance. Using the tools, one can avoid using the distance matrix to help the better performance of algorithms. Then, some applications of the tools and a tight bound for the change of average distance when an inset edge is added to a tree are presented. The tools restrict the search space for finding the minimum gradient of average distance. Afterward, we calculate the gradient of an inset edge on the average distance of a tree for all edges. There is a heuristic algorithm for max{๐ทโ€ฒ(๐‘‡๐‘’ )}๐‘’โˆˆ๐ธ(๐‘‡ ๐‘) in problem 3, where ๐‘‡ is replaced with a connected graph [19]. The time complexity of the algorithm for trees is ๐‘‚(๐‘›3 ) where there are ๐‘› vertices. We devised an exact algorithm that computes and sorts the set {๐ทโ€ฒ(๐‘‡๐‘’ )}๐‘’โˆˆ๐ธ(๐‘‡ ๐‘) . The algorithmsโ€™ average time is ๐‘‚(๐‘›2 . log ๐‘›). A tree has ๐‘‚(๐‘›2 ) inset edge, that is, the algorithm is minimal on average, where it significantly reduces its former ๐‘‚(๐‘›5 ) solution [20]. The algorithm is dynamic and recursively computes 69 the Wiener index (total distances) of all pseudotrees out of a tree. In fact, it calculates the total distance of a pseudotree in ๐‘‚(log ๐‘›)-time on average with the minimal possible best time of ๐‘‚(1). Using established matrix tools, the algorithm strictly avoids extra computations depending on the input treesโ€™ topology. That results in a time complexity proportional to the Wiener index of the input tree. 6.2 Main Tools and Preliminary Results โˆ’1 As observed graph's average distance is equal to ๐ท(๐บ) = ๐‘Š(๐บ) ยท (|๐‘‰(๐บ)| 2 ) where ๐บ is a simple connected graph, [1,8,10-14,17-20]. By definition of gradient, (|๐‘‰(๐บ)| 2 )๐ทโ€ฒ (๐บ๐‘ ) = ๐‘Š โ€ฒ (๐บ๐‘ ). Accordingly, in this chapter, the results for ๐‘Š hold for ๐ท as well, with some constant coefficient consideration. If ๐‘‡ is a tree and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ), ๐‘‡๐‘ฅ๐‘ฆ\โˆ… is a mutation, and for ease, it is denoted by ๐‘‡๐‘ฅ๐‘ฆ . So, ๐‘‡๐‘ฅ๐‘ฆ is a unicyclic graph, and ๐‘ฅ๐‘ฆ is the inset edge. When we know the length of the cycle of ๐‘‡๐‘ฅ๐‘ฆ is ๐‘˜ we indicate it by ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ . Suppose ๐ถ is the cycle of ๐‘‡๐‘ฅ๐‘ฆ๐‘˜ , we define: ๐ถ๐‘ฅ = { ๐‘ฃ โˆˆ ๐‘‰(๐ถ) | ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฃ) < ๐‘‘ ๐‘‡ (๐‘ฆ, ๐‘ฃ) }, ๐ถ๐‘ฆ = { ๐‘ฃ โˆˆ ๐‘‰(๐ถ) | ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฃ) > ๐‘‘ ๐‘‡ (๐‘ฆ, ๐‘ฃ) }, ๐ถ๐‘€ = { ๐‘ฃ โˆˆ ๐‘‰(๐ถ) | ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฃ) = ๐‘‘ ๐‘‡ (๐‘ฆ, ๐‘ฃ) }. ๐‘˜ Note that |๐ถ๐‘ฅ | = |๐ถ๐‘ฆ | = โŒŠ2โŒ‹, |๐ถ๐‘€ | = 0 when ๐‘˜ is even, and |๐ถ๐‘€ | = 1 otherwise. Now, ๐‘˜ index the element(s) of ๐ถ๐‘ฅ to ๐‘ฅ๐‘– '(s), 1 โ‰ค ๐‘– โ‰ค โŒŠ2โŒ‹ in such a way that ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฅ๐‘– ) = ๐‘– โˆ’ 1. ๐‘˜ Similarly, index the element(s) of ๐ถ๐‘ฆ to ๐‘ฆ๐‘– '(s), 1 โ‰ค ๐‘– โ‰ค โŒŠ2โŒ‹, in such a way that ๐‘‘ ๐‘‡ (๐‘ฆ, ๐‘ฆ๐‘– ) = ๐‘– โˆ’ 1. Moreover, if ๐ถ๐‘€ has the single element, we denote the element by ๐‘ฅ๐‘€ . 70 As we see, the indexing is unique and partitions the vertices of ๐ถ. Additionally, for ๐‘ฃ โˆˆ ๐‘‰(๐ถ) suppose ๐‘‡๐‘ฃ to be the maximal subtree of ๐‘‡๐‘ฅ๐‘ฆ such that, ๐‘‰(๐‘‡๐‘ฃ ) โˆฉ ๐‘‰(๐ถ) = {๐‘ฃ}. Informally, ๐‘‡๐‘ฃ is the sub-tree attached to the vertex ๐‘ฃ โˆˆ ๐‘‰(๐ถ) with no other vertex from ๐ถ except ๐‘ฃ. We denote the number of vertices of ๐‘‡๐‘ฃ , |๐‘‰(๐‘‡๐‘ฃ )|, by ๐‘ค๐‘ฃ . See figure 6.1. Figure 6.1 ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ for even and odd kโ€™s. A resolution to the indexing and maximal subtrees ๐‘‡๐‘ฅ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘‡๐‘ฆ1 ๐‘‡๐‘ฅ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘‡๐‘ฆ1 ๐‘‡๐‘ฅ2 ๐‘ฅ2 ๐‘ฆ2 ๐‘‡๐‘ฆ2 ๐‘‡๐‘ฅ2 ๐‘ฅ2 ๐‘ฆ2 ๐‘‡๐‘ฆ2 ๐‘‡๐‘ฅ ๐‘˜ ๐‘ฅ๐‘˜ ๐‘ฆ๐‘˜ ๐‘‡๐‘ฆ ๐‘˜ ๐‘‡๐‘ฅ ๐‘˜ ๐‘ฅ๐‘˜ ๐‘ฆ๐‘˜ ๐‘‡๐‘ฆ ๐‘˜ โŒŠ โŒ‹ โŒŠ โŒ‹ โŒŠ โŒ‹ โŒŠ โŒ‹ โŒŠ โŒ‹ โŒŠ โŒ‹ โŒŠ โŒ‹ โŒŠ โŒ‹ 2 2 2 2 2 2 2 2 ๐‘ฅ๐‘€ ๐‘‡๐‘ฅ๐‘€ Using the notations and definitions, we have the following theorem, which has a critical role in our analysis and reduction of the time complexity of the actual calculations. Theorem 6.1: For a tree ๐‘‡, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )= โˆ‘ (2๐‘‘๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜) โ‹… ๐‘ค๐‘ข โ‹… ๐‘ค๐‘ฃ (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)> 2 Proof: Suppose ๐ถ is the cycle of ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ . Using the definition of ๐‘Š and our notations 71 ๐‘˜ ๐‘Š(๐‘‡๐‘ฅ๐‘ฆ )= โˆ‘ ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) + โˆ‘ ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) {๐‘ข,๐‘ฃ}โІ๐‘‰(๐ถ๐‘ฅ โˆช ๐ถ๐‘€ ) {๐‘ข,๐‘ฃ}โІ๐‘‰(๐ถ๐‘ฆ โˆช ๐ถ๐‘€ ) + โˆ‘ ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ฃ ), ๐‘‰(๐‘‡๐‘ฃ )) + โˆ‘ ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) ๐‘ฃโˆˆ๐‘‰(๐ถ) (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)โ‰ค 2 + โˆ‘ ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) (6.1) (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)> 2 Looking at the updated distances from ๐‘‡ to ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ one can see that, (๐‘ข, ๐‘ฃ) โˆˆ ๐ถ๐‘ฅ ร— ๐ถ๐‘ฆ ๐‘‘๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) = ๐‘‘ ๐‘‡ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) except for ๐‘˜ . ๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) > 2 Therefore, ๐‘˜ ๐‘Š(๐‘‡) โˆ’ ๐‘Š(๐‘‡๐‘ฅ๐‘ฆ )= โˆ‘ ๐‘‘๐‘‡ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) โˆ’ โˆ‘ ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )). (6.2) (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ ๐‘˜ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)> ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)> 2 2 ๐‘˜ Besides, for every ๐‘Ž โˆˆ ๐‘‰(๐‘‡๐‘ข ) and ๐‘ โˆˆ ๐‘‰(๐‘‡๐‘ฃ ) if ๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) > 2, ๐‘‘๐‘‡ (๐‘Ž, ๐‘) > ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ๐‘˜ (๐‘Ž, ๐‘), (6.3) ๐‘‘๐‘‡ (๐‘Ž, ๐‘ข) = ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘Ž, ๐‘ข), (6.4) ๐‘‘ ๐‘‡ (๐‘, ๐‘ฃ) = ๐‘‘๐‘‡๐‘ฅ๐‘ฆ๐‘˜ (๐‘, ๐‘ฃ). (6.5) More precisely, for equation 6.3, using the cycle of ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘‘ ๐‘‡๐‘ฅ๐‘ฆ๐‘˜ (๐‘ข, ๐‘ฃ) = 2 โ‹… ๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜. As we have, |๐‘‰(๐‘‡๐‘ข )| = ๐‘ค๐‘ข , and |๐‘‰(๐‘‡๐‘ฃ )| = ๐‘ค๐‘ฃ , by 6.3 to 6.5, 72 ๐‘‘๐‘‡ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) โˆ’ ๐‘‘๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ (๐‘‰(๐‘‡๐‘ข ), ๐‘‰(๐‘‡๐‘ฃ )) = (2. ๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜) โ‹… ๐‘ค๐‘ข โ‹… ๐‘ค๐‘ข (6.7) ๐‘˜ where ๐‘‘๐‘‡ (๐‘ข, ๐‘ฃ) > 2. equations 6.2 and 6.7 lead us to, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )= โˆ‘ (2๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜) โ‹… ๐‘ค๐‘ข โ‹… ๐‘ค๐‘ฃ (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)> 2 That completes the proof. โ–  As a useful example of theorem 6.1, ๐‘Š โ€ฒ (๐‘‡๐‘ข๐‘ฃ 3 ) = ๐‘ค๐‘ข โ‹… ๐‘ค๐‘ฃ . Also, note that by definition 1.4 ๐‘š๐‘–๐‘›๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ) = ๐‘š๐‘–๐‘›๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) ๐‘Š(๐‘‡๐‘ฅ๐‘ฆ ). We need to define some matrices to present some benefits of theorem 6.1. For ease ๐‘˜ hereafter, let ๐‘˜ โ€ฒ = โŒŠ2โŒ‹. Suppose we are given a ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ . We associate the vectors, ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ or ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ ๐‘˜ ๐‘ฅ = [ ๐‘ฅ๐‘ฆ ๐‘ค๐‘– ] to ๐‘‡๐‘ฅ๐‘ฆ๐‘˜ , ๐‘ฆ which is a ๐‘˜ โ€ฒ -vector and, ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘ค๐‘– = ๐‘ค๐‘ฅ๐‘– = |๐‘‰(๐‘‡๐‘ฅ๐‘– )|, see figure 6.1. Similarly, we define ๐‘ฅ๐‘ฆ๐‘พ or ๐‘ฆ ๐‘ฆ ๐‘ฆ ๐‘ฅ๐‘ฆ๐‘พ ๐‘˜ = [ ๐‘ฅ๐‘ฆ๐‘ค๐‘– ] where ๐‘ฅ๐‘ฆ๐‘ค๐‘– = ๐‘ค๐‘ฆ๐‘– = |๐‘‰(๐‘‡๐‘ฆ๐‘– )|, 1 โ‰ค ๐‘– โ‰ค ๐‘˜ โ€ฒ , see figure 6.1. Then we associate a matrix ๐’™๐’š๐‘พ to ๐‘‡๐‘ฅ๐‘ฆ as follows, ๐‘ฅ ๐‘ฆ ๐‘ฅ๐‘ฆ๐‘พ = ๐‘ฅ๐‘ฆ๐‘พ ร— ( ๐‘ฅ๐‘ฆ๐‘พ)๐‘ก . ๐‘ฆ Therefore, in a ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘–๐‘— ]๐‘˜ โ€ฒ ร—๐‘˜ โ€ฒ , ๐‘ค๐‘–๐‘— = ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘ค๐‘– โ‹… ๐‘ฅ๐‘ฆ๐‘ค๐‘— = ๐‘ค๐‘ฅ๐‘– โ‹… ๐‘ค๐‘ฆ๐‘— . Next, we introduce the matrix ๐‘ญ๐‘˜ . The matrix ๐‘ญ๐‘˜ is a ๐‘˜ โ€ฒ ร— ๐‘˜ โ€ฒ matrix as follows, ๐‘ซ๐‘˜ + ๐‘ถ๐‘˜ ๐‘˜ is odd, ๐‘ญ๐‘˜ = { ๐‘ซ๐‘˜ Otherwise. where ๐‘ซ๐‘˜ = [๐‘‘๐‘–๐‘— ] and ๐‘ถ๐‘˜ = [๐‘œ๐‘–๐‘— ] are also ๐‘˜ โ€ฒ ร— ๐‘˜ โ€ฒ matrices as follows, 73 2(๐‘˜ โ€ฒ โˆ’ ๐‘– โˆ’ ๐‘— + 1) ๐‘– + ๐‘— โ‰ค ๐‘˜โ€ฒ, ๐‘‘๐‘–๐‘— = { 0 otherwise. and 1 ๐‘– + ๐‘— โˆ’ 1 โ‰ค ๐‘˜โ€ฒ, ๐‘œ๐‘–๐‘— = { 0 otherwise. For more resolution, see the following. 2๐‘˜ โ€ฒ โˆ’ 1 2๐‘˜ โ€ฒ โˆ’ 3 2๐‘˜ โ€ฒ โˆ’ 5 โ€ฆ 1 2๐‘˜ โ€ฒ โˆ’ 3 2๐‘˜ โ€ฒ โˆ’ 5 โ€ฆ 1 0 2๐‘˜ โ€ฒ โˆ’ 5 โ€ฆ 1 0 0 ๐‘ญ๐‘˜ = โ‹ฎ ๐‘˜ is odd โ‹ฎ 1 โ‹ฎ โ‹ฎ 1 0 โ€ฆ 0 [ 1 0 0 โ€ฆ 0 0] 2๐‘˜ โ€ฒ โˆ’ 2 2๐‘˜ โ€ฒ โˆ’ 4 2๐‘˜ โ€ฒ โˆ’ 6 โ€ฆ 2 0 2๐‘˜ โ€ฒ โˆ’ 4 2๐‘˜ โ€ฒ โˆ’ 6 โ€ฆ 2 0 0 2๐‘˜ โ€ฒ โˆ’ 6 โ‹ฎ โ€ฆ 2 0 0 0 โ‹ฎ 0 ๐‘ญ๐‘˜ = ๐‘˜ is even โ‹ฎ 2 โ‹ฎ 2 0 โ‹ฎ 2 0 0 โ€ฆ 0 [ 0 0 0 โ€ฆ 0 0 ] 1 1 1 โ€ฆ 1 1 1 โ€ฆ 1 0 1 โ€ฆ 1 0 0 ๐‘ถ๐‘˜ = โ‹ฎ โ‹ฎ 1 โ‹ฎ โ‹ฎ 1 0 โ€ฆ 0 [ 1 0 0 โ€ฆ 0 0 ] ๐‘ค๐‘ฅ1 ๐‘ค๐‘ฅ2 ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘ฆ1 ๐‘ค๐‘ฆ2 โ€ฆ ๐‘ค๐‘ฆ โ€ฒ ] ๐‘˜ โ‹ฎ [๐‘ค๐‘ฅ๐‘˜โ€ฒ ] 74 ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ1 ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ2 ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ3 โ€ฆ ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ ๐‘ค๐‘ฅ2 . ๐‘ค๐‘ฆ1 ๐‘ค๐‘ฅ2 . ๐‘ค๐‘ฆ2 โ‹ฎ โ€ฆ ๐‘ค๐‘ฅ2 . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ ๐‘ค๐‘ฅ3 . ๐‘ค๐‘ฆ1 โ‹ฎ โ€ฆ ๐‘ค๐‘ฅ3 . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ = โ‹ฎ โ€ฆ โ‹ฎ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ1 โ€ฆ โ‹ฎ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ โˆ’2 ๐‘˜ โˆ’2 ๐‘˜ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ1 โ€ฆ โ‹ฎ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ โˆ’1 ๐‘˜ โˆ’1 ๐‘˜ โˆ’1 ๐‘˜ โˆ’1 ๐‘˜ [ ๐‘ค๐‘ฅ๐‘˜โ€ฒ . ๐‘ค๐‘ฆ1 โ€ฆ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ ๐‘˜ ๐‘˜โ€ฒ โˆ’2 ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ ๐‘˜ โˆ’1 ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ] ๐‘˜ ๐‘˜ ๐‘ค11 ๐‘ค12 ๐‘ค13 โ€ฆ ๐‘ค1๐‘˜ โ€ฒ ๐‘ค21 ๐‘ค22 โ‹ฎ โ€ฆ ๐‘ค2๐‘˜ โ€ฒ ๐‘ค31 โ‹ฎ ๐‘ค3๐‘˜ โ€ฒ = โ‹ฎ โ€ฆ โ‹ฎ ๐‘ค๐‘˜ โ€ฒ โˆ’2,1 โ€ฆ โ‹ฎ ๐‘ค๐‘˜ โ€ฒ โˆ’2,๐‘˜ โ€ฒ ๐‘ค๐‘˜ โ€ฒ โˆ’1,1 โ€ฆ โ‹ฎ ๐‘ค๐‘˜ โ€ฒ โˆ’1,๐‘˜ โ€ฒ โˆ’1 ๐‘ค๐‘˜ โ€ฒ โˆ’1,๐‘˜ โ€ฒ [ ๐‘ค๐‘˜ โ€ฒ ,1 โ€ฆ ๐‘ค๐‘˜ โ€ฒ ,๐‘˜ โ€ฒ โˆ’2 ๐‘ค๐‘˜ โ€ฒ ,๐‘˜โ€ฒ โˆ’1 ๐‘ค๐‘˜ โ€ฒ ,๐‘˜ โ€ฒ ] In fact, ๐‘ญ๐‘˜ is an upper-triangular matrix that provides the coefficients of ๐‘ค๐‘ข . ๐‘ค๐‘ฃ in the formula of ๐‘Š โ€ฒ in theorem 6.1. To express our next result, we recall the Hadamard multiplication and the norm one of the matrices as follows. If ๐‘จ = [๐‘Ž๐‘–๐‘— ] is a matrix, then โ€–๐‘จโ€– = โˆ‘๐‘–,๐‘— |๐‘Ž๐‘–๐‘— | . The Hadamard product of two matrices ๐‘จ = [๐‘Ž๐‘–๐‘— ] and ๐‘ฉ = [๐‘๐‘–๐‘— ] with equal dimensions is an element-wise product that produces a matrix with the exact dimensions of ๐‘จ and ๐‘ฉ as follows, ๐‘ช = ๐‘จ โŠš ๐‘ฉ = [๐‘๐‘–๐‘— = ๐‘Ž๐‘–๐‘— โ‹… ๐‘๐‘–๐‘— ]. Note also that ๐‘’๐‘– denotes the ๐‘–โ€™th unit standard vector of proper length. Lemma 6.2: For a tree ๐‘‡, we have: ๐‘˜ ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ) = โ€–๐‘ญ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–. 75 Proof: Suppose ๐ถ is the cycle of ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ and ๐‘ข, ๐‘ฃ โˆˆ ๐‘‰(๐ถ). According to the definition of ๐‘ญ๐‘˜ and ๐‘ฅ๐‘ฆ๐‘พ if the ๐‘–๐‘—โ€™th entry of ๐‘ฅ๐‘ฆ๐‘พ is ๐‘ค๐‘ข โ‹… ๐‘ค๐‘ฃ , then the ๐‘–๐‘—โ€™th entry of ๐‘ญ๐’Œ is (2๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜ ๐‘˜ ๐‘˜), for ๐‘‘๐‘‡ (๐‘ข, ๐‘ฃ) > 2. And if ๐‘‘๐‘‡ (๐‘ข, ๐‘ฃ) โ‰ค 2 , then the corresponding entry of ๐‘ฅ๐‘ฆ๐‘พ is zero. Therefore, using the definition of Hadamard multiplication, โ€–๐‘ญ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– = โˆ‘ (2๐‘‘๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜) โ‹… ๐‘ค๐‘ข โ‹… ๐‘ค๐‘ฃ , (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)> 2 By theorem 6.1, the RHS of the above equation is equal to ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ). โ–  Remark 6.3: As defined, when we introduce a graph, ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ we mean an inset edge ๐‘ฅ๐‘ฆ is added to ๐‘‡, which has created a ๐‘˜-cycle. Since in the indexing of the cycle of ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ,๐‘ฅ= ๐‘ฅ1 and ๐‘ฆ = ๐‘ฆ1 so ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ = ๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 . We fix the initial indexing. Then, we abuse the initial indexing of the cycle of ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ to say that the inset edge of ๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 is ๐‘ฅ2 ๐‘ฆ1 . That means we remove ๐‘ฅ1 ๐‘ฆ1 and add ๐‘ฅ2 ๐‘ฆ1 to ๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 . That changes ๐‘˜ to ๐‘˜ โˆ’ 1 as well. Also, based on the initial indexing, ๐‘‡๐‘ฅ๐‘˜+1 0 ๐‘ฆ1 means the inset edge is ๐‘ฅ0 ๐‘ฆ1 where ๐‘ฅ0 is a neighbor of ๐‘ฅ1 except ๐‘˜โˆ’๐‘–โˆ’๐‘—+2 from ๐‘ฅ2 . A similar argument applies for, ๐‘‡๐‘ฅ๐‘– ๐‘ฆ๐‘— , regarding the initial indexing of ๐‘‡๐‘ฅ๐‘ฆ๐‘˜ .โ–ฒ The next theorem gives the lower and upper bound of, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) over the set of all trees with ๐‘› vertices. The upper bound is interesting since for a tree, ๐‘‡ with ๐‘› vertices, (๐‘› โˆ’ 1)2 โ‰ค ๐‘Š(๐‘‡) โ‰ค (๐‘›3) [16]. Theorem 6.4: For a tree ๐‘‡ with ๐‘› vertices, ๐‘›3 ๐‘›2 9๐‘› 1 โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ) โ‰ค โˆ’ โˆ’ + 2. 16 32 8 Moreover, the lower bound holds if and only if ๐‘‡ has two leaves with a distance of two, and the inset edge connects them. The upper bound holds if and only if the following holds, 76 1. ๐‘› โ‰ก 0 ๐‘š๐‘œ๐‘‘ 8, ๐‘› โ‰ฅ 16, ๐‘› 2. ๐‘‡ is formed by attaching an arbitrary vertex of an arbitrary tree with vertices 4 ๐‘› to a leaf of a ๐‘ƒ๐‘›+3 and attaching an arbitrary vertex of another arbitrary tree with 2 4 vertices to the other leaf of ๐‘ƒ๐‘›+3 . 2 3. ๐‘ฅ๐‘ฆ connects the leaves of ๐‘ƒ๐‘›+3 in the tree formed in the previous step. 2 Figure 6.2 Estimate structure of trees admitting upper bound of theorem 6.4 Proof: To prove the upper bound, consider the graph ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ with a non-trivial ๐‘‡๐‘ฅ๐‘– , where 2 โ‰ค ๐‘– โ‰ค ๐‘˜โ€ฒ and |๐‘‰ (๐‘‡ )| = ๐‘›. Detach the elements of ๐‘‰(๐‘‡๐‘ฅ๐‘– )/{๐‘ฅ๐‘– } and attach them arbitrarily to the vertices of ๐‘‡๐‘ฅ1 and name the formed graph ๐บ. By lemma 6.2, we can see that if |๐‘‰(๐‘‡๐‘ฅ๐‘– )/{๐‘ฅ๐‘– }| = ๐‘ค, ๐‘ฆ ๐‘ก ๐‘Š โ€ฒ (๐บ) = โ€–๐‘ญ๐‘˜ โŠš ( ๐‘ฅ๐‘ฆ ๐‘ฅ ๐‘พ + ๐‘ค โ‹… ๐‘’1 โˆ’ ๐‘ค โ‹… ๐‘’๐‘– ) โ‹… ( ๐‘ฅ๐‘ฆ๐‘พ) โ€– ๐‘ฆ ๐‘ฆ ๐‘ก = ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) + โ€–๐‘ญ๐‘˜ โŠš ( ๐‘ค โ‹… ๐‘’1 ). ( ๐‘ฅ๐‘ฆ๐‘พ)๐‘ก โ€– โˆ’ โ€–๐‘ญ๐‘˜ โŠš (๐‘ค โ‹… ๐‘’๐‘– ) โ‹… ( ๐‘ฅ๐‘ฆ๐‘พ) โ€–. (6.8) This is straightforward to check that, ๐‘ฆ ๐‘ฆ โ€–๐‘ญ๐‘˜ โŠš ( ๐‘ค โ‹… ๐‘’1 ) โ‹… ( ๐‘ฅ๐‘ฆ๐‘พ)๐‘ก โ€– > โ€–๐‘ญ๐‘˜ โŠš (๐‘ค โ‹… ๐‘’๐‘– ) โ‹… ( ๐‘ฅ๐‘ฆ๐‘พ)๐‘ก โ€–. Therefore by Eq. 6.8, ๐‘Š โ€ฒ (๐บ) > ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ). Consequently, since ๐‘– was arbitrary and ๐‘– โ‰  1: 77 1: ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ) is maximum โŸน โˆ€ ๐‘‡๐‘ฅ๐‘– , 2 โ‰ค ๐‘– โ‰ค ๐‘˜ โ€ฒ , is trivial. 2: Likewise, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) is maximum โŸน โˆ€ ๐‘‡๐‘ฆ๐‘– , 2 โ‰ค ๐‘– โ‰ค ๐‘˜ โ€ฒ , is trivial. Since the matrix, ๐‘ฅ๐‘ฆ๐‘พ is independent of, ๐‘ค๐‘ฅ๐‘€ , 3: ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ) is maximum โŸน ๐‘‡๐‘ฅ๐‘€ is trivial. Using facts 1 to 3, 4: ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ) is maximum โŸน โˆ€๐‘ฃ โˆˆ ๐‘‰(๐ถ)/{๐‘ฅ, ๐‘ฆ}, |๐‘‡๐‘ฃ | = ๐‘ค๐‘ฃ = 1 where ๐ถ is the cycle of ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ . ๐‘ฆ ๐‘ก That is, ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘ฅ , 1,1, โ€ฆ ,1]๐‘ก and ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘ฆ , 1,1, โ€ฆ ,1] . 5: Since |๐‘‰(๐ถ)| = ๐‘˜ and |๐‘‰(๐‘‡)| = ๐‘›, so, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) is maximum โŸน ๐‘ค๐‘ฅ + ๐‘ค๐‘ฆ = ๐‘› โˆ’ ๐‘˜ + 2. (6.9) Using theorem 6.1 and Eq. 6.9, we can see that; ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) is maximum โŸน ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 ๐‘ค๐‘ฅ . ๐‘ค๐‘ฆ = โŒŠ โŒ‹โŒˆ โŒ‰. 2 2 Consequently, by facts 1-5 and theorem 6.1, if ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) is maximum and ๐‘˜ โ‰ก 2 ๐‘š๐‘œ๐‘‘ 4:(See appendix A for more details on calculations) ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 1 ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ )=โŒŠ โŒ‹โŒˆ โŒ‰ (๐‘˜ โˆ’ 2) + (๐‘˜ โˆ’ 2)(๐‘˜ โˆ’ 4)(๐‘› โˆ’ ๐‘˜ + 2) 2 2 4 1 1 + (๐‘˜ โˆ’ 4)(๐‘˜ โˆ’ 6) โˆ’ (๐‘˜ โˆ’ 6)(๐‘˜ โˆ’ 2) , (6.10) 2 8 and for ๐‘˜ โ‰ก 0 ๐‘š๐‘œ๐‘‘ 4: ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 1 ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ )=โŒŠ โŒ‹โŒˆ โŒ‰ (๐‘˜ โˆ’ 2) + (๐‘˜ โˆ’ 2)(๐‘˜ โˆ’ 4)(๐‘› โˆ’ ๐‘˜ + 2) 2 2 4 1 1 + (๐‘˜ โˆ’ 4)(๐‘˜ โˆ’ 6) โˆ’ (๐‘˜ โˆ’ 4)2 , (6.11) 2 8 and for odd ๐‘˜โ€ฒ๐‘ : 78 ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 1 1 ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )=โŒŠ โŒ‹โŒˆ โŒ‰ (๐‘˜ โˆ’ 2) + (๐‘˜ โˆ’ 3)2 (๐‘› โˆ’ ๐‘˜ + 2) + (๐‘˜ โˆ’ 5)2 2 2 4 2 1 โˆ’ (๐‘˜ โˆ’ 5)(๐‘˜ โˆ’ 3). (6.12) 8 Because ๐‘› = |๐‘‰(๐‘‡)| is a constant, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) in equations 6.10 to 6.12 is a function of ๐‘˜ = |๐ถ|. To find the maximum of ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) we can take its derivative w.r.t ๐‘˜ for each case of 6.10 to 6.12 and find the critical points. To do this, we require to consider two ๐‘˜ ) ๐œ•๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘›โˆ’๐‘˜+2 possibilities. First, if is an integer, then the roots of, in equations 6.10 to 2 ๐œ•๐‘˜ 6.12 are equal to the following, respectively, ๐‘›2 + 2๐‘› โˆ’ 24 ๐‘›2 โˆ’ 2๐‘› โˆ’ 24 ๐‘›2 โˆ’ 2๐‘› โˆ’ 25 ๐‘˜1 = , ๐‘˜2 = and ๐‘˜3 = . 2๐‘› โˆ’ 7 2๐‘› โˆ’ 7 2๐‘› โˆ’ 7 ๐‘˜ ) ๐œ•๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘›โˆ’๐‘˜+2 Second, if is not an integer, then the critical points of in equations 6.10 2 ๐œ•๐‘˜ to 6.12 are, respectively. ๐‘›2 + 2๐‘› โˆ’ 26 ๐‘›2 โˆ’ 2๐‘› โˆ’ 25 ๐‘›2 โˆ’ 2๐‘› โˆ’ 26 ๐‘˜1 = , ๐‘˜2 = and ๐‘˜3 = . 2๐‘› โˆ’ 7 2๐‘› โˆ’ 7 2๐‘› โˆ’ 7 Now for, ๐‘˜๐‘– , ๐‘– = 1 , 2, 3, we require to use the values, โŒŠ๐‘˜๐‘– โŒ‹ ๐‘œ๐‘Ÿ โŒˆ๐‘˜๐‘– โŒ‰ to find the maximum of, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) in their respective equations. After doing so, we observe that the maximum reachable value is equal to ๐‘›3 ๐‘›2 9๐‘› โˆ’ โˆ’ + 2. 16 32 8 That proves the upper bound. One can check that the described trees of the theorem touch the above upper bound. Moreover, no other cases meet both the constraints 1 to 5 and the upper bound. The lower bound is evident because, according to theorem 6.1, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) โ‰ฅ 1 as we had: 79 ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )= โˆ‘ (2๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜) โ‹… ๐‘ค๐‘ข โ‹… ๐‘ค๐‘ฃ . (๐‘ข,๐‘ฃ)โˆˆ๐ถ๐‘ฅ ร—๐ถ๐‘ฆ ๐‘˜ ๐‘‘๐‘‡ (๐‘ข,๐‘ฃ)> 2 On the other hand, if either of ๐‘ค๐‘ข , ๐‘ค๐‘ฃ ๐‘œ๐‘Ÿ (2๐‘‘ ๐‘‡ (๐‘ข, ๐‘ฃ) โˆ’ ๐‘˜) is greater than 1, then ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) > 1. That means the only trees that can touch the lower bound are the ones described in the theorem. This completes the proof. โ–  Remark 6.5: The previous theorem gives the best upper bound of ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) where |๐‘‰(๐‘‡)| = ๐‘› โ‰ฅ 16, and ๐‘› is divisible by 8. Using the theoremโ€™s proof, one can establish a lower tight upper bound when ๐‘› โ‰ข 0 ๐‘š๐‘œ๐‘‘ 8 or ๐‘› = 8. In fact, if ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) is maximum, ๐‘ฆ using I and II from theorem 6.4, ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘ฅ , 1,1, โ€ฆ ,1]๐‘ก and ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘ฆ , 1,1, โ€ฆ ,1]. Moreover, ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 we had ๐‘ค๐‘ฅ . ๐‘ค๐‘ฆ = โŒŠ โŒ‹โŒˆ โŒ‰. Thus, without loss of generality, we can let ๐‘ค๐‘ฅ = 2 2 ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 โŒŠ โŒ‹ , ๐‘ค๐‘ฆ = โŒˆ โŒ‰. Note that the structure of ๐‘‡๐‘ฅ and ๐‘‡๐‘ฆ do not affect the maximum 2 2 attainable ๐‘Š โ€ฒ but the size of them. So their structures are arbitrary. By lemma 6.2, ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = โ€–๐‘ญ๐‘˜ โŠš ( ๐‘ฅ๐‘ฆ ๐‘ฅ ๐‘พ ร— ( ๐‘ฅ๐‘ฆ๐‘พ)๐‘ก )โ€–. Thus, interested readers can calculate ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) using the provided variables, and intuitively see that, if ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) is maximum, then ๐‘› ๐‘˜โ‰ˆ . 2 Knowing the latter fact, one may find some finite alternatives close to ๐‘˜ (๐‘˜ ยฑ 2, ๐‘˜ ยฑ 1, and ๐‘˜) that satisfy the given conditions to help find an upper bound of ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) among the ๐‘›โ€™s that was not discussed in theorem 6.4. โ–ฒ Suppose we are given a ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ which means the inset edge is ๐‘ฅ1 ๐‘ฆ1 . If we remove ๐‘ฅ1 ๐‘ฆ1 and substitute with ๐‘ฅ2 ๐‘ฆ2 then we have a (๐‘˜ โˆ’ 2)-cycle in, ๐‘‡๐‘ฅ2๐‘ฆ2 . We can make just one ๐‘ฆ change to the vectors, ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ and ๐‘ฅ๐‘ฆ๐‘พ and calculate ๐‘Š โ€ฒ (๐‘‡๐‘ฅ2๐‘ฆ2 ). That lets us avoid some 80 recalculations, and thus we can save time. In the following two theorems, we present the details. ๐‘ฆ Theorem 6.6: Suppose ๐‘‡ is a tree and the vectors, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ ๐‘ฅ and the matrix ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘–๐‘— ] are associated with ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ , where ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) > 4. Then ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜2๐‘ฆ2 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) if and only if: โˆ‘ ๐‘ค๐‘–๐‘— โ‰ฅ ๐‘ค11 ๐‘˜ is even , 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–,๐‘—>1 2( โˆ‘ ๐‘ค๐‘–๐‘— ) + โˆ‘ ๐‘ค๐‘–๐‘— โ‰ฅ 2๐‘ค11 ๐‘˜ is odd. 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–+๐‘—=๐‘˜ โ€ฒ +2 { ๐‘–,๐‘—>1 ๐‘–,๐‘—>1 Proof: Suppose we have ๐‘‡๐‘ฅ๐‘˜1 ๐‘ฆ1 and ๐‘‘ ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 ) > 4. If we remove ๐‘ฅ1 ๐‘ฆ1 from ๐‘‡๐‘ฅ๐‘˜1 ๐‘ฆ1 and add ๐‘ฅ2 ๐‘ฆ2 to ๐‘‡ regarding the indexing of ๐ถ๐‘ฅ1 and ๐ถ๐‘ฆ1 in ๐‘‡๐‘ฅ๐‘˜1 ๐‘ฆ1 , then we reach ๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 . Therefore, ๐‘ฅ2 ๐‘ฅ1 ๐‘ฅ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ1 ๐‘ฆ1 ๐‘พ[2: ] + ๐‘ฅ1๐‘ฆ11 ๐‘ค1 โ‹… ๐‘’1 , and ๐‘ฆ2 ๐‘ฆ1 ๐‘ฆ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ1 ๐‘ฆ1 ๐‘พ[2: ] + ๐‘ฅ1๐‘ฆ11 ๐‘ค1 โ‹… ๐‘’1 . ๐‘ฆ2 ๐‘ฅ Moreover, we know that ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ2 ๐‘ฆ2 ๐‘พ ร— ( ๐‘ฅ2๐‘ฆ22 ๐‘พ)๐’• . Therefore, using lemma 6.2, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) = โ€–๐‘ญ๐‘˜โˆ’2 โŠš ๐‘ฅ2๐‘ฆ2 ๐‘พโ€– โˆ’ โ€–๐‘ญ๐‘˜ โŠš ๐‘ฅ1๐‘ฆ1๐‘พโ€–. Expanding the latter equation using the definitions for odd and even ๐‘˜ separately, one can see that (see appendix B: for more details of the calculation) 81 โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ ๐‘ค11 ๐‘˜ is even, 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–,๐‘—>1 โ€ฒ ๐‘Š (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) โˆ’๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) = 2( โˆ‘ ๐‘ค๐‘–๐‘— ) + โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ 2๐‘ค11 ๐‘˜ is odd. 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–+๐‘—=๐‘˜ โ€ฒ +2 { ๐‘–,๐‘—>1 ๐‘–,๐‘—>1 This completes the proof. โ–  In the following theorem, we compute ๐‘Š โ€ฒ (๐‘‡๐‘ฅ2๐‘ฆ1 ) using ๐‘Š โ€ฒ (๐‘‡๐‘ฅ1 ๐‘ฆ1 )Regarding the indexing of ๐ถ๐‘ฅ1 and ๐ถ๐‘ฆ1 . That is, we remove ๐‘ฅ1 ๐‘ฆ1 from ๐‘‡๐‘ฅ1 ๐‘ฆ1 and insert the edge ๐‘ฅ2 ๐‘ฆ1 to the ๐‘‡. ๐‘ฆ Theorem 6.7: Suppose ๐‘‡ is a tree and the vectors ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ ๐‘ฅ and the matrix ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘–๐‘— ] are associated with ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ , where ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) > 3. Then ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) if and only if, โˆ‘ ๐‘ค๐‘–๐‘— โ‰ฅ โˆ‘ ๐‘ค1๐‘— ๐‘˜ is even, 3โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 0<๐‘—<๐‘˜โ€ฒ ๐‘–>1, ๐‘—<๐‘˜โ€ฒ โˆ‘ ๐‘ค๐‘–๐‘— โ‰ฅ โˆ‘ ๐‘ค1๐‘— ๐‘˜ is odd. 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 0<๐‘—โ‰ค๐‘˜โ€ฒ { ๐‘–>1, ๐‘—<๐‘˜โ€ฒ Proof: Suppose we have ๐‘‡๐‘ฅ๐‘˜1 ๐‘ฆ1 and ๐‘‘ ๐‘‡ (๐‘ฅ1 , ๐‘ฆ1 ) > 3. By lemma 6.2, ๐‘ฅ ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) = โ€–๐น๐‘˜ โŠš ( ๐‘ฅ1๐‘ฆ11 ๐‘พ) โ‹… ( ๐‘ฅ1๐‘ฆ11 ๐‘พ)๐‘ก โ€–, (6.13) and ๐‘ฅ ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 ) = โ€–๐น๐‘˜โˆ’1 โŠš ( ๐‘ฅ2๐‘ฆ21 ๐‘พ) โ‹… ( ๐‘ฅ2๐‘ฆ11 ๐‘พ)๐‘ก โ€–. (6.14) Note that changing the inset edge from ๐‘ฅ1 ๐‘ฆ1 to ๐‘ฅ2 ๐‘ฆ1 changes ๐‘˜ to ๐‘˜ โˆ’ 1, and ๐‘ญ๐‘˜ varies for odd and even ๐‘˜โ€ฒ๐‘ . But, it is interesting to see that for both even and odd ๐‘˜โ€™s: 82 ๐‘ฅ ๐‘ฆ ๐‘ฅ ๐‘ฅ ๐‘ฅ โ€–๐น๐‘˜โˆ’1 โŠš ( ๐‘ฅ2๐‘ฆ21 ๐‘พ) โ‹… ( ๐‘ฅ2๐‘ฆ11 ๐‘พ)๐‘ก โ€– = โ€–(๐น๐‘˜ + ๐‘‚๐‘˜ ) โŠš ( ๐‘ฅ1 ๐‘ฆ11๐‘พ โˆ’ ๐‘ฅ1 ๐‘ฆ11๐‘ค1 โ‹… ๐‘’1 + ๐‘ฅ1๐‘ฆ11 ๐‘ค1 โ‹… ๐‘ฆ ๐‘’2 ). ( ๐‘ฅ1๐‘ฆ11 ๐‘พ)๐‘ก โ€–. The LHS of the above equation is equal to ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 ). Expanding the RHS of the above equation and the LHS of equation 6.13 for odd and even ๐‘˜โ€™s, using the definitions of involved matrices, gives (calculations are similar to that of theorem 6.6; see appendix B: for a similar calculation) โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ โˆ‘ ๐‘ค1๐‘— ๐‘˜ is even, 3โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 0<๐‘—<๐‘˜โ€ฒ ๐‘–>1, ๐‘—<๐‘˜โ€ฒ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) = โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ โˆ‘ ๐‘ค1๐‘— ๐‘˜ is odd. 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 0<๐‘—โ‰ค๐‘˜โ€ฒ { ๐‘–>1, ๐‘—<๐‘˜โ€ฒ Therefore, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1 ๐‘ฆ1 ) if and only if, โˆ‘ ๐‘ค๐‘–๐‘— โ‰ฅ โˆ‘ ๐‘ค1๐‘— ๐‘˜ is even, 3โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 0<๐‘—<๐‘˜โ€ฒ ๐‘–>1, ๐‘—<๐‘˜โ€ฒ โˆ‘ ๐‘ค๐‘–๐‘— โ‰ฅ โˆ‘ ๐‘ค1๐‘— ๐‘˜ is odd. 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 0<๐‘—โ‰ค๐‘˜โ€ฒ { ๐‘–>1, ๐‘—<๐‘˜โ€ฒ This completes the proof. โ–  The following results show some applications of theorems 6.6 and 6.7. That is, we can almost ignore the edges of a tree ๐‘‡ that share a vertex with a leaf when finding max ๐ทโ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ). ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘ ) Corollary 6.8: Suppose ๐‘‡ is a tree on ๐‘› > 6 vertices and ๐‘‡ โ‰‡ ๐‘†๐‘› . Then there is ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡ ๐‘ ) where ๐‘ข and ๐‘ฃ are not both leaves and, ๐‘Š โ€ฒ (๐‘‡๐‘ข๐‘ฃ ) = max ๐‘ ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ). ๐‘Ž๐‘โˆˆ๐ธ(๐‘‡ ) 83 Proof: Suppose we are given a ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ such that ๐‘‘๐‘’๐‘”(๐‘ฅ) = ๐‘‘๐‘’๐‘”(๐‘ฆ) = 1. That means ๐‘ค๐‘ฅ1 = ๐‘ค๐‘ฆ1 = 1 and so ๐‘ค11=1. For the proof of corollary, it is sufficient to show that for any ๐‘˜ > 2 there is ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) such that ๐‘ข or ๐‘ฃ are not both leaves and ๐‘Š โ€ฒ (๐‘‡๐‘ข๐‘ฃ ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ). If ๐‘˜ > 5, then by theorem 6.6 we clearly have, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ), where ๐‘ฅ2 and ๐‘ฆ2 are not leaves. For the remaining finite cases, ๐‘˜ = 5,4,3, we assume that ๐‘ค๐‘ฅ = ๐‘ค๐‘ฆ = 1, ๐‘› > 6 and ๐‘‡ โ‰‡ ๐‘†๐‘› . Accordingly, if ๐‘˜ = 4, then ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1 ๐‘ฆ1 ) = 2 and ๐‘ฅ2 is not a leaf. If ๐‘˜ = 5, we observe that either, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 2 ๐‘ฆ1 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’11 ๐‘ฆ2 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 ๐‘€ ๐‘ฆ1 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 ๐‘€ ๐‘ฅ1 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) is greater than ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) and ๐‘ฅ2 , ๐‘ฆ2 or, ๐‘ฅ๐‘€ are not leaves (see appendix C: for more detail). If ๐‘˜ = 3, ๐‘Š โ€ฒ (๐‘‡๐‘ง๐‘ฆ ๐‘˜โˆ’1 1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) = 1, where ๐‘ง is any non-leaf vertex. This completes the proof. โ–  Theorem 6.9: Suppose ๐‘ฃ is a leaf of a tree ๐‘‡ and ๐‘ง โˆˆ ๐‘‰(๐‘‡) is arbitrary. If ๐‘‘ ๐‘‡ (๐‘ฃ, ๐‘ง) โˆˆ โ„•/{2,3,4,6}, then either a non-leaf ๐‘ฅ โˆˆ ๐‘‰(๐‘‡) exists such that ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘ง ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ง ) or the non-leaves ๐‘ฅ, ๐‘ฆ โˆˆ ๐‘‰(๐‘‡) exist such that ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘ง ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ). Proof: We break the proof into two claims, which cover the theorem conditions. Claim (1): If ๐‘ฃ is a leaf of ๐‘‡, ๐‘‘๐‘‡ (๐‘ฃ, ๐‘ง) = ๐‘˜ โˆ’ 1, ๐‘˜ > 4 and, ๐‘˜ is even; then there exist a non-leaf ๐‘ข โˆˆ ๐‘‰(๐‘‡) such that ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘ง ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ข๐‘ง ). Proof of Claim (1): By theorem 6.7's proof: ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’1 2 ๐‘ง1 )= โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ โˆ‘ ๐‘ค1๐‘— . (6.15) 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 0<๐‘—<๐‘˜ โ€ฒ ๐‘–>1, ๐‘—<๐‘˜ โ€ฒ Since deg(๐‘ฃ) = 1, so by definition ๐‘ฃ ๐‘ฃ๐‘ง๐‘ค1 = 1 and ๐‘ง โˆ‘ ๐‘ฃ๐‘ง ๐‘ค๐‘— = โˆ‘ ๐‘ค1๐‘— . (6.16) 0<๐‘—<๐‘˜ โ€ฒ 0<๐‘—<๐‘˜ โ€ฒ Thus, by the definition of ๐‘ฃ๐‘ง๐‘พ, for ๐‘˜ โ€ฒ โ‰ฅ 3, 84 ๐‘ง (6.17) โˆ‘ ๐‘ฃ๐‘ง๐‘ค๐‘— = โˆ‘ ๐‘ค1๐‘— โ‰ค โˆ‘ ๐‘ค๐‘–๐‘— . 0<๐‘—<๐‘˜ โ€ฒ 0<๐‘—<๐‘˜ โ€ฒ 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 ๐‘–>1, ๐‘—<๐‘˜ โ€ฒ and using equations 6.15 and 6.17, ๐‘Šโ€ฒ(๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’1 2 ๐‘ง1 ), where ๐‘ฃ2 is not a leaf. Claim (2): If ๐‘ฃ is a leaf of ๐‘‡, ๐‘‘ ๐‘‡ (๐‘ฃ, ๐‘ง) = ๐‘˜ โˆ’ 1, ๐‘˜ > 7 and, ๐‘˜ is odd, then either a non-leaf ๐‘ฅ โˆˆ ๐‘‰(๐‘‡) exists such that, ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘ง ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ง ) or the non-leaves ๐‘ฅ, ๐‘ฆ โˆˆ ๐‘‰(๐‘‡) exist such that, ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘ง ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ). Proof of Claim (2): The proof for the odd ๐‘˜โ€™s is tricky and needs a precise comparison. First, by theorem 6.7's proof, we know that, ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’1 2 ๐‘ง1 )= โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ โˆ‘ ๐‘ค1๐‘— , (6.18) 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 0<๐‘—โ‰ค๐‘˜ โ€ฒ ๐‘–>1,๐‘—<๐‘˜ โ€ฒ and by theorem 6.6's proof, ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’22 ๐‘ง2 ) = 2( โˆ‘ ๐‘ค๐‘–๐‘— ) + โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ 2๐‘ค11 . (6.19) 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–+๐‘—=๐‘˜ โ€ฒ +2 ๐‘–,๐‘—>1 ๐‘–,๐‘—>1 Assuming, ๐‘ฃ ๐‘ฃ๐‘ง๐‘พ = [1,1, โ€ฆ ,1]๐‘ก , ๐‘ง ๐‘ฃ๐‘ง๐‘พ = [๐‘Ž๐‘– ]๐‘˜ โ€ฒ and expanding Eq. 6.18 if ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’1 2 ๐‘ง1 ), then by theorem 6.7 (see appendix C fo detail) ๐‘˜ โ€ฒ โˆ’1 ๐‘Ž๐‘˜ โ€ฒ โ‰ฅ โˆ‘ (๐‘˜ โ€ฒ โˆ’ ๐‘–)๐‘Ž๐‘– , (6.20) ๐‘–=1 Similarly assuming, ๐‘ฃ ๐‘ฃ๐‘ง๐‘พ = [1,1, โ€ฆ ,1]๐‘ก , ๐‘ง ๐‘ฃ๐‘ง๐‘พ = [๐‘Ž๐‘– ]๐‘˜ โ€ฒ and expanding Eq. 6.19 if ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’2 2 ๐‘ง2 ), then by theorem 6.6 (see appendix C for detail) 85 ๐‘˜โ€ฒ 2๐‘Ž1 โ‰ฅ โˆ‘(2๐‘˜ โ€ฒ โˆ’ 2๐‘– + 1)๐‘Ž๐‘– . (6.21) ๐‘–=2 It is straightforward to see that if ๐‘˜ โ€ฒ โ‰ฅ 4, then either (20) or (21) does not hold. That is, if (20) holds, then (21) does not happen, and if (21) occurs, then (20) does not hold. Moreover, it is easy to see if ๐‘ฃ ๐‘ฃ๐‘ง๐‘พ โ‰  [1,1, โ€ฆ ,1]๐‘ก then the RHS of (20) and (21) will be greater, not harming our argument. Consequently, using (18) and (19), either ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’1 2 ๐‘ง1 ) or ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โ‰ค ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’2 2 ๐‘ง2 ), where ๐‘ฃ2 and ๐‘ง2 do not represent leaves. This completes the proof. โ–  Remark 6.10: By corollary 6.8 and theorem 6.9, except for some specified cases, there exists an inset edge between two non-leaf vertices of a tree, which minimizes the average distance of a tree. In fact, using the following result by Renyi, Proposition 6.11: The expected number of leaves in a random labeled tree on ๐‘› vertices is ๐‘›/๐‘’ where ๐‘’ is the Euler's number. โ–  ๐‘›โˆ’๐‘› one can limit our search space from (๐‘›2) โˆ’ |๐ธ(๐‘‡)| inset edges to nearly ( 2 ๐‘’) inset ๐‘› ๐‘›โˆ’ ( ๐‘’) 2 ๐‘’โˆ’1 2 edges, when seeks min ๐‘ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ). That eliminates 1 โˆ’ (๐‘› โ‰ˆ 1โˆ’( ) โ‰ˆ %60 of ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ) 2) ๐‘’ potential inset edges for min ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ). โ–ฒ ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘ ) The next theorem is another application of theorems 6.6 and 6.7 to an efficient algorithm. Theorem 6.12: Suppose ๐‘‡ is a tree, ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ) and ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) = ๐‘˜ โˆ’ 1. If we are given ๐‘ฆ the vectors ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ and ๐‘ฅ๐‘ฆ๐‘พ, then we can obtain the following {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+2 ๐‘– ๐‘ฆ๐‘– )} โˆช {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+1 ๐‘–+1 ๐‘ฆ๐‘– )} โˆช {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+1 ๐‘– ๐‘ฆ๐‘–+1 )} , 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ โˆ’1 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ โˆ’1 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ โˆ’1 using ๐‘‚(๐‘˜ 2 ) operations. ๐‘ฆ Proof: Suppose we have ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ , ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ), ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ and ๐‘ฅ๐‘ฆ๐‘พ. Using lemma 6.2, 86 ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = โ€–๐‘ญ๐‘˜ โŠš ( ๐‘ฅ๐‘ฆ ๐‘ฅ ๐‘พ ร— ( ๐‘ฅ๐‘ฆ๐‘พ)๐‘ก )โ€–. Thus, it costs us ๐‘‚(๐‘˜ 2 ) operations to calculate, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ), ๐‘ฅ๐‘ฆ๐‘พ, and โ€–๐‘ถ๐’Œ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–. By theorem 6.6, if ๐‘˜ is even, then ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) = โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ ๐‘ค11 . (6.22) 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–,๐‘—>1 and by definitions of ๐‘ถ๐‘˜ and ๐‘ฅ๐‘ฆ๐‘พ, โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ ๐‘ค11 = โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– โˆ’ โˆ‘ ๐‘ค๐‘–1 โˆ’ โˆ‘ ๐‘ค1๐‘– . (6.23) 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ ๐‘–,๐‘—>1 Since we already have โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– and ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ), by (6.22) and (6.23) we obtain ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) in ๐‘‚(๐‘˜)-time. Moreover, having ๐‘ฅ๐‘ฆ๐‘พ, โ€–๐‘ถ๐’Œ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ and ๐‘ฅ๐‘ฆ๐‘พ, the following calculations clearly take at most ๐‘‚(๐‘˜)-time to compute, ๐‘ฅ2 ๐‘ฆ2 ๐‘พ, โ€–๐‘ถ๐‘˜โˆ’2 โŠš ๐‘ฅ2๐‘ฆ2 ๐‘พโ€–, ๐‘ฅ2 ๐‘ฆ2 ๐‘ฅ2 ๐‘ฆ2 ๐‘พ, and ๐‘ฅ2 ๐‘ฆ2 ๐‘พ 1-By definition โ€–๐‘ถ๐‘˜โˆ’2 โŠš ๐‘ฅ2 ๐‘ฆ2๐‘พโ€– = โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– โˆ’ โˆ‘ (๐‘ค๐‘–1 +๐‘ค1๐‘– ) โˆ’ โˆ‘ ๐‘ค๐‘–๐‘— . 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ ๐‘–+๐‘—=๐‘˜ โ€ฒ +2 2-Changing the first and second columns and rows of ๐‘ฅ๐‘ฆ๐‘พ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ๐‘ฆ๐‘พ[๐Ÿ: , ๐Ÿ: ] ๐‘ฅ ๐‘ฆ +( ๐‘ฅ๐‘ฆ ๐‘พ[๐Ÿ: ]๐‘ค๐‘ฆ as the first row) + ( ๐‘ฅ๐‘ฆ๐‘พ[๐Ÿ: ]๐‘ค๐‘ฅ as the first column) 3-By definition ๐‘ฅ2 ๐‘ฅ ๐‘ฅ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ๐‘ฆ๐‘พ[2: ] + ๐‘ฅ1๐‘ฆ11๐‘ค1 โ‹… ๐‘’1 , and ๐‘ฆ2 ๐‘ฆ ๐‘ฆ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ๐‘ฆ๐‘พ[2: ] + ๐‘ฅ1๐‘ฆ11๐‘ค1 โ‹… ๐‘’1 . 87 ๐‘ฅ3 ๐‘ฆ3 Similarly, we can obtain ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’4 3 ๐‘ฆ3 ), ๐‘ฅ3 ๐‘ฆ3 ๐‘พ, ๐‘ฅ3 ๐‘ฆ3 ๐‘พ, ๐‘ฅ3 ๐‘ฆ3 ๐‘พ, and โ€–๐‘ถ๐’Œโˆ’๐Ÿ’ โŠš ๐‘ฅ3 ๐‘ฆ3๐‘พโ€– with ๐‘ฅ2 ๐‘ฆ2 ๐‘‚(๐‘˜) operations from, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ), ๐‘ฅ2 ๐‘ฆ2 ๐‘พ, ๐‘ฅ2 ๐‘ฆ2 ๐‘พ, ๐‘ฅ2 ๐‘ฆ2 ๐‘พ, and โ€–๐‘ถ๐’Œโˆ’๐Ÿ โŠš ๐‘ฅ2 ๐‘ฆ2๐‘พโ€–. That is, we can obtain, {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+2 ๐‘– ๐‘ฆ๐‘– )} in ๐‘‚(๐‘˜ ร— ๐‘˜)-time. A similar argument applies to odd ๐‘˜โ€ฒs 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ โˆ’1 according to theorem 6.6. By using theorem 6.7, similarly, we can compute {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+1 ๐‘–+1 ๐‘ฆ๐‘– )} and {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+1 ๐‘– ๐‘ฆ๐‘–+1 )} in ๐‘‚(๐‘˜ 2 )-time. This completes the proof.โ–  1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ โˆ’1 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ โˆ’1 Remark 6.13: The average diameter of a tree ๐‘‡ on ๐‘› vertices, is ๐‘™๐‘œ๐‘”(๐‘›) [15]. On the other hand, by theorem 6.12, we obtained {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+2 ๐‘– ๐‘ฆ๐‘– )} in ๐‘‚(๐‘˜ 2 )-time. Thus, we 1โ‰ค๐‘–โ‰ค๐‘˜ โ€ฒ โˆ’1 can obtain each ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘–+2 ๐‘– ๐‘ฆ๐‘– ), 1 โ‰ค ๐‘– โ‰ค ๐‘˜ โ€ฒ โˆ’ 1, in ๐‘‚(๐‘˜)-time subject to the given condition. Since ๐‘˜ < ๐‘‘๐‘–๐‘Ž๐‘š(๐‘‡) + 1 and the number of inset edges is of ๐‘‚(๐‘›2 ) we have the following question: โ–ฒ Question 6.14: Suppose ๐‘‡ is a tree on ๐‘› vertices. Is it possible to obtain {๐‘Š(๐‘‡๐‘ฅ๐‘ฆ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) with the average time complexity of ๐‘‚(๐‘›2 log(๐‘›))? โ–ฒ 6.3 Main Result: An algorithm For Inset Edge of Trees 6.3.1 Some Tools to Divide and Conquer Definition 6.15: Suppose ๐บ is a graph and ๐‘ข, ๐‘ฃ โˆˆ ๐‘‰(๐บ). We define the relative neighborhood of ๐‘ข compared to ๐‘ฃ as follows: ๐‘๐บ๐‘ฃ (๐‘ข) = {๐‘ฅ โˆˆ ๐‘‰(๐บ) | ๐‘‘(๐‘ฅ, ๐‘ข) < ๐‘‘(๐‘ฅ, ๐‘ฃ)}. And let, |๐‘๐บ๐‘ฃ (๐‘ข)| = ๐‘›๐บ๐‘ฃ (๐‘ข) . โ–ฒ Note that if ๐‘‡ is a tree on ๐‘› vertices, then for every ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡), ๐‘›๐‘ฃ๐‘‡ (๐‘ข) + ๐‘›๐‘ข๐‘‡ (๐‘ฃ) = ๐‘›, and if ๐‘ฅ๐‘–โˆ’1 , ๐‘ฅ๐‘– โˆˆ ๐ถ๐‘ฅ and ๐‘ฆ๐‘–โˆ’1 , ๐‘ฆ๐‘– โˆˆ ๐ถ๐‘ฆ in a ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ , then ๐‘ฅ ๐‘›๐‘‡๐‘–โˆ’1 (๐‘ฅ๐‘– ) = |๐‘‡๐‘ฅ๐‘– | = ๐‘ค๐‘ฅ๐‘– , and ๐‘ฆ ๐‘›๐‘‡๐‘–โˆ’1 (๐‘ฆ๐‘– ) = |๐‘‡๐‘ฆ๐‘– | = ๐‘ค๐‘ฆ๐‘– . 88 Definition 6.16: Each inset edge connects two vertices of a tree. The path that connects the two vertices has a middle vertex/edge, which is the vertex/edge that has an equal distance from the pathsโ€™ two endpoints. If the length of the path is even, then the middle is a vertex, and the middle is an edge if the length is odd. We call the middle vertex/edge of the path that connects the vertices of an inset edge of a tree the middle of that inset edge. โ–ฒ Note that a vertex/edge of a tree can be the middle of more than one inset edge. But every inset edge has a unique middle. Moreover, a leaf or an edge incident with a leaf can not be middle of any inset edge. Theorem 6.17: The set of inset edges of a tree, ๐ธ(๐‘‡ ๐‘ ), forms equivalence classes regarding the middles. More precisely, each equivalence class is the inset edges of the tree with the same middle. Proof: An inset edge forms a unique cycle in a tree. Therefore, every inset edge has a unique middle. That partitions the inset edges into sets of inset edges with the same middles. This completes the proof. โ–  Definition 6.18: Suppose the vertex/edge ๐‘ง is the middle of the inset edge, ๐‘ฅ๐‘ฆ, which means ๐‘‘(๐‘ง, ๐‘ฅ) = ๐‘‘(๐‘ง, ๐‘ฆ). If ๐‘Ž๐‘ is another inset edge such that ๐‘Ž๐‘ฅ โˆˆ ๐ธ(๐‘‡), ๐‘๐‘ฆ โˆˆ ๐ธ(๐‘‡), and ๐‘‘(๐‘ง, ๐‘Ž) = ๐‘‘(๐‘ง, ๐‘ฅ) + 1 and ๐‘‘(๐‘ง, ๐‘) = ๐‘‘(๐‘ง, ๐‘ฆ) + 1, then we say ๐‘Ž๐‘ is the next parallel edge of ๐‘ฅ๐‘ฆ. โ–ฒ In definition 6.18; ๐‘ฅ๐‘ฆ, ๐‘Ž๐‘, ๐‘ฅ๐‘Ž, and ๐‘ฆ๐‘ induce a ๐ถ4 , which is ๐‘ฅ๐‘ฆ๐‘๐‘Ž๐‘ฅ. Using a different point of view, if ๐‘Ž โˆˆ ๐‘(๐‘ฅ) โˆ’ ๐ถ๐‘ฅ and ๐‘ โˆˆ ๐‘(๐‘ฆ) โˆ’ ๐ถ๐‘ฆ , then ๐‘Ž๐‘ is the next parallel edge of ๐‘ฅ๐‘ฆ. Moreover, ๐‘ฅ๐‘ฆ and ๐‘Ž๐‘ have the same middle. Theorem 6.19: If ๐‘‡ is a tree and ๐‘ข๐‘ฃ is the next parallel edge of ๐‘ฅ๐‘ฆ in ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ with ๐‘ฆ ๐‘ฅ๐‘ข, ๐‘ฆ๐‘ฃ โˆˆ ๐ธ(๐‘‡) , then ๐‘ข ๐‘ข๐‘ฃ ๐‘ค1 = ๐‘›๐‘‡๐‘ฅ (๐‘ข), ๐‘ฃ ๐‘ข๐‘ฃ๐‘ค1 = ๐‘›๐‘‡ (๐‘ฃ) and: 89 ๐‘˜โ€ฒ ๐‘˜+2 ) ๐‘˜ ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘Šโ€ฒ(๐‘‡๐‘ข๐‘ฃ โˆ’ ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ) = โˆ’2 โˆ‘ ๐‘ค๐‘–๐‘— + โˆ‘ ๐‘ค๐‘–๐‘— + 2 โˆ‘( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘Ÿ + ๐‘ฅ๐‘ฆ ๐‘ค๐‘Ÿ . ๐‘ข๐‘ฃ ๐‘ค1 ) ๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 ๐‘–+๐‘—=๐‘˜ โ€ฒ +1 ๐‘Ÿ=1 ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘ข ๐‘ฃ โˆ’( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ + ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ . ๐‘ข๐‘ฃ๐‘ค1 ) + โˆ’4 ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ข๐‘ฃ ๐‘ค1 , ๐‘˜ ๐‘–๐‘  ๐‘œ๐‘‘๐‘‘, ๐‘˜โ€ฒ ๐‘˜+2 ) ๐‘˜ ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘Šโ€ฒ(๐‘‡๐‘ข๐‘ฃ โˆ’ ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ) = โˆ’2 โˆ‘ ๐‘ค๐‘–๐‘— + 2 โˆ‘ ๐‘ค๐‘–๐‘— + 2. โˆ‘( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘Ÿ + ๐‘ฅ๐‘ฆ ๐‘ค๐‘Ÿ . ๐‘ข๐‘ฃ ๐‘ค1 ) ๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 ๐‘–+๐‘—= ๐‘˜ โ€ฒ +1 ๐‘Ÿ=1 ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘ข ๐‘ฃ { โˆ’2( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ + ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ . ๐‘ข๐‘ฃ๐‘ค1 ) โˆ’ 4 ๐‘ข๐‘ฃ๐‘ค1 . ๐‘ข๐‘ฃ ๐‘ค1 , ๐‘˜ ๐‘–๐‘  ๐‘’๐‘ฃ๐‘’๐‘›. ๐‘ฆ where the vectors ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ ๐‘ฅ and the matrix ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘–๐‘— ] are associated with ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ . Proof: Suppose we have ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ and ๐‘ฅ and ๐‘ฆ are some non-leaf vertices. Then, ๐‘ข๐‘ฃ with ๐‘ข โˆˆ ๐‘(๐‘ฅ) โˆ’ ๐ถ๐‘ฅ and ๐‘ฃ โˆˆ ๐‘(๐‘ฆ) โˆ’ ๐ถ๐‘ฆ is the next parallel edge of ๐‘ฅ๐‘ฆ. With the theoremsโ€™ assumptions, if we remove ๐‘ฅ๐‘ฆ from ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ and add ๐‘ข๐‘ฃ to ๐‘‡, ๐‘›๐‘‡๐‘ฅ (๐‘ข) 0 ๐‘ฅ ๐‘›๐‘‡๐‘ฅ (๐‘ข) ๐‘ฅ๐‘ฆ๐‘ค1 ๐‘ฅ 0 ๐‘ฅ๐‘ฆ๐‘ค2 ๐‘ข 0 ๐‘ข๐‘ฃ๐‘พ = โˆ’ (6.24) โ‹ฎ ๐‘ฅ โ‹ฎ [ ๐‘ฅ๐‘ฆ ๐‘ค๐‘˜ โ€ฒ ] [ 0 ] And ๐‘ฆ 0 ๐‘›๐‘‡ (๐‘ฃ) ๐‘ฆ ๐‘ฆ ๐‘›๐‘‡ (๐‘ฃ) ๐‘ฅ๐‘ฆ๐‘ค1 ๐‘ฆ 0 ๐‘ฃ ๐‘ฅ๐‘ฆ๐‘ค2 0 ( ๐‘ข๐‘ฃ ๐‘พ )๐‘‡ = โˆ’ (6.25) โ‹ฎ โ‹ฎ ๐‘ฆ [ ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ ] [ 0 ] ๐‘ฆ That means, ๐‘ข ๐‘ข๐‘ฃ๐‘ค1 = ๐‘›๐‘‡๐‘ฅ (๐‘ข) and ๐‘ฃ ๐‘ข๐‘ฃ๐‘ค1 = ๐‘›๐‘‡ (๐‘ฃ). We know that ๐‘ข๐‘ฃ๐‘พ = ๐‘ข ๐‘ข๐‘ฃ๐‘พ ๐‘ฃ ร— ( ๐‘ข๐‘ฃ ๐‘พ)๐‘ก . Expanding the following equation, using equations 6.24, 6.25, and lemma 6.2: 90 ๐‘˜+2 ) ๐‘˜ ๐‘Šโ€ฒ(๐‘‡๐‘ข๐‘ฃ โˆ’ ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ) = โ€–๐‘ญ๐‘˜+2 โŠš ๐‘ข๐‘ฃ๐‘พโ€– โˆ’ โ€–๐‘ญ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–, we have, ๐‘˜โ€ฒ ๐‘˜+2 ) ๐‘˜ ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘Šโ€ฒ(๐‘‡๐‘ข๐‘ฃ โˆ’ ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ) = โˆ’2 โˆ‘ ๐‘ค๐‘–๐‘— + โˆ‘ ๐‘ค๐‘–๐‘— + 2 โˆ‘( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘Ÿ + ๐‘ฅ๐‘ฆ ๐‘ค๐‘Ÿ . ๐‘ข๐‘ฃ ๐‘ค1 ) ๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 ๐‘–+๐‘—=๐‘˜ โ€ฒ +1 ๐‘Ÿ=1 ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘ข ๐‘ฃ โˆ’( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ + ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ . ๐‘ข๐‘ฃ๐‘ค1 ) + โˆ’4 ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ข๐‘ฃ ๐‘ค1 , ๐‘˜ ๐‘–๐‘  ๐‘œ๐‘‘๐‘‘, ๐‘˜โ€ฒ ๐‘˜+2 ) ๐‘˜ ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘Šโ€ฒ(๐‘‡๐‘ข๐‘ฃ โˆ’ ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ) = โˆ’2 โˆ‘ ๐‘ค๐‘–๐‘— + 2 โˆ‘ ๐‘ค๐‘–๐‘— + 2. โˆ‘( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘Ÿ + ๐‘ฅ๐‘ฆ ๐‘ค๐‘Ÿ . ๐‘ข๐‘ฃ ๐‘ค1 ) ๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 ๐‘–+๐‘—= ๐‘˜ โ€ฒ +1 ๐‘Ÿ=1 ๐‘ข ๐‘ฆ ๐‘ฅ ๐‘ฃ ๐‘ข ๐‘ฃ { โˆ’2( ๐‘ข๐‘ฃ ๐‘ค1 . ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ + ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ . ๐‘ข๐‘ฃ๐‘ค1 ) โˆ’ 4 ๐‘ข๐‘ฃ๐‘ค1 . ๐‘ข๐‘ฃ ๐‘ค1 , ๐‘˜ ๐‘–๐‘  ๐‘’๐‘ฃ๐‘’๐‘›. This completes the proof. โ–  6.3.2 A Matrix Norm Technique In general, the time complexity of calculating ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = โ€–๐น๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– is ๐‘‚(๐‘˜ 2 )-time. Here, using some regularity of ๐น๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พ, a technique is proposed that reduces the total time complexity of computing, {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )} ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) . But note that, I-Using theorem 6.19, it is impossible to calculate ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) in less than ๐‘‚(๐‘˜ 2 ) for a single given ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ). II-But, if ๐‘ข๐‘ฃ is the next parallel edge of ๐‘ฅ๐‘ฆ, then we will achieve ๐‘Š โ€ฒ (๐‘‡๐‘ข๐‘ฃ ๐‘˜+2 ) from ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) in ๐‘‚(๐‘˜). If ๐ด is a given matrix, let ๐ด[specified indices] denote a matrix corresponding to ๐ด where the specified indices have the same values as ๐ด and are zero otherwise. Also, [๐‘Ž โˆง ๐‘‰] notation appends the number ๐‘Ž as the first entry of a vector ๐‘‰, extending its length by one. 91 Proposition 6.20: Suppose we have ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ , and ๐‘Ž๐‘ is the next parallel edge of ๐‘ฅ๐‘ฆ. If we have ๐‘ฆ ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ, ), and โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–, ๐‘ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ๐‘ฆ then using ๐‘›๐‘‡๐‘ฅ (๐‘Ž) and ๐‘›๐‘‡ (๐‘) we can obtain the following in ๐‘‚(๐‘˜) = ๐‘‚(๐‘‘(๐‘Ž, ๐‘))-time. ๐‘Ž ๐‘ ๐‘˜+2 ๐‘Ž๐‘ ๐‘พ, ๐‘Ž๐‘ ๐‘พ, ๐‘Ž๐‘ ๐‘พ, ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) and โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€–. Proof: Suppose we have ๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ and ๐‘Ž๐‘ is the next parallel edge of ๐‘ฅ๐‘ฆ and, ๐‘›๐‘‡๐‘ฅ (๐‘Ž) and ๐‘ฆ ๐‘›๐‘‡ (๐‘) are given. Thus, ๐‘Ž โˆˆ ๐‘(๐‘ฅ) โˆ’ ๐ถ๐‘ฅ and ๐‘ โˆˆ ๐‘(๐‘ฆ) โˆ’ ๐ถ๐‘ฆ . ๐‘ฆ We want to prove that if we have ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ) and โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– then ๐‘Ž ๐‘ ๐‘˜+2 we can obtain ๐‘Ž๐‘ ๐‘พ, ๐‘Ž๐‘ ๐‘พ, ๐‘Ž๐‘ ๐‘พ, ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) and โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€– with ๐‘‚(๐‘˜) operations. We break the proof into four parts, ๐‘จ), ๐‘ฉ), ๐‘ช), and ๐‘ซ), as follows: ๐‘จ) โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– โ†’ โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€– By definition of ๐‘Ž๐‘ ๐‘พ, one can see that: If ๐‘˜ โ‰  1, โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€– ๐‘ฆ ๐‘ฆ = โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– โˆ’ โ€– ๐‘ฅ๐‘ฆ๐‘พ[๐‘– + ๐‘— = ๐‘˜ โ€ฒ + 1]โ€– + ๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘ฅ๐‘ฆ๐‘พ[๐‘˜ โ€ฒ ] + ๐‘›๐‘‡ (๐‘). ๐‘ฅ๐‘ฆ ๐‘ฅ ๐‘พ[๐‘˜ โ€ฒ ] And if ๐‘˜ = 1, ๐‘ฆ ๐‘ฆ โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€– = ๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘ฅ๐‘ฆ ๐‘พ[๐‘˜ โ€ฒ ] + ๐‘›๐‘‡ (๐‘). ๐‘ฅ๐‘ฆ๐‘ฅ ๐‘พ[๐‘˜ โ€ฒ ] โˆ’ 3๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘›๐‘‡๐‘ฅ (๐‘Ž). As โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– is given, โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€– is calculatable in ๐‘‚(๐‘˜)-time clearly. 92 ๐‘˜+2 ๐‘ฉ) ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ) โ†’ ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) Using theorem 6.19 and our notation, one can check that, 1-If ๐‘˜ is Even ๐‘˜+2 ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) = ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) + 2โ€– ๐‘ฅ๐‘ฆ๐‘พ[๐‘– + ๐‘— = ๐‘˜ โ€ฒ + 1]โ€– โˆ’ 2โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– + 2โ€–๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘ฅ๐‘ฆ๐‘พโ€– ๐‘ฆ ๐‘ฆ ๐‘ฆ +2โ€–๐‘›๐‘‡ (๐‘). ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พโ€– โˆ’ 2๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘ฅ๐‘ฆ๐‘พ[๐‘˜ โ€ฒ ] โˆ’ 2๐‘›๐‘‡ (๐‘). ๐‘ฅ๐‘ฆ ๐‘ฅ ๐‘พ[๐‘˜ โ€ฒ ] โˆ’ 4 ๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘›๐‘‡๐‘ฅ (๐‘Ž). 2-If ๐‘˜ is Odd and ๐‘˜ โ‰ฅ 3 ๐‘˜+2 ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) = ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) + โ€– ๐‘ฅ๐‘ฆ๐‘พ[๐‘– + ๐‘— = ๐‘˜ โ€ฒ + 1]โ€– โˆ’ 2โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– + 2โ€–๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘ฅ๐‘ฆ๐‘พโ€– ๐‘ฆ ๐‘ฆ ๐‘ฆ + 2โ€–๐‘›๐‘‡ (๐‘). ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พโ€– โˆ’ ๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘ฅ๐‘ฆ๐‘พ[๐‘˜ โ€ฒ ] โˆ’ ๐‘›๐‘‡ (๐‘). ๐‘ฅ๐‘ฆ ๐‘ฅ ๐‘พ[๐‘˜ โ€ฒ ] โˆ’ 4 ๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘›๐‘‡๐‘ฅ (๐‘Ž) And if ๐‘˜ = 1 ๐‘˜+2 ๐‘ฆ ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) = โ€–๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘ฅ๐‘ฆ๐‘พโ€– + โ€–๐‘›๐‘‡ (๐‘). ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พโ€– โˆ’ 3๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘›๐‘‡๐‘ฅ (๐‘Ž) At the RHS of all the above cases, except for โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– and ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) that is given by the assumptions, everything else can be calculated in ๐‘‚(๐‘˜). ๐‘Ž ๐‘ฆ ๐‘ ๐‘ช) ๐‘ฅ๐‘ฆ๐‘ฅ ๐‘พโŸถ ๐‘Ž๐‘๐‘พ and ๐‘ฅ๐‘ฆ๐‘พ โŸถ ๐‘Ž๐‘๐‘พ ๐‘Ž ๐‘ By equations 6.24 and 6.25, ๐‘Ž๐‘๐‘พ and ๐‘Ž๐‘ ๐‘พ are computable in ๐‘‚(1) using ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ and ๐‘ฆ ๐‘ฅ๐‘ฆ๐‘พ, respectively. Thatโ€™s because, ๐‘ฆ ๐‘›๐‘‡๐‘ฅ (๐‘Ž) ๐‘›๐‘‡ (๐‘) ๐‘ฅ ๐‘ฅ ๐‘ฆ ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘ค1 โˆ’ ๐‘› ๐‘‡ (๐‘Ž) ๐‘ฅ๐‘ฆ๐‘ค1 โˆ’ ๐‘› ๐‘‡ (๐‘) ๐‘ฅ ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘ค2 ๐‘ฅ๐‘ฆ๐‘ค2 ๐‘Ž ๐‘ ๐‘Ž๐‘๐‘พ = and ( ๐‘Ž๐‘ ๐‘พ)๐‘‡ = . โ‹ฎ โ‹ฎ ๐‘ฅ ๐‘ฆ [ ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ ] [ ๐‘ฅ๐‘ฆ๐‘ค๐‘˜ โ€ฒ ] 93 ๐‘ซ) ๐‘ฅ๐‘ฆ๐‘พ โŸถ ๐‘Ž๐‘ ๐‘พ Using equations 6.24 and 6.25, and the definition of ๐‘Ž๐‘ ๐‘พ, one can see that line 6 in the following outputs ๐‘Ž๐‘๐‘พ. Let ๐‘Ž๐‘ ๐‘พ = 0(๐‘˜โ€ฒ+1)ร—(๐‘˜โ€ฒ+1) ๐‘ฆ ๐‘ฆ ๐Ÿ โˆ’ ๐‘Ž๐‘๐‘พ[๐‘“๐‘–๐‘Ÿ๐‘ ๐‘ก ๐‘Ÿ๐‘œ๐‘ค]+= ๐‘›๐‘‡๐‘ฅ (๐‘Ž). [๐‘›๐‘‡ (๐‘) โˆง ๐‘ฅ๐‘ฆ๐‘พ] ๐‘ฆ ๐Ÿ โˆ’ ๐‘Ž๐‘๐‘พ[๐‘“๐‘–๐‘Ÿ๐‘ ๐‘ก ๐‘๐‘œ๐‘™๐‘ข๐‘š๐‘›]+= ๐‘›๐‘‡ (๐‘). [๐‘›๐‘‡๐‘ฅ (๐‘Ž) โˆง ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พ] ๐‘ฆ ๐‘ฆ ๐Ÿ‘ โˆ’ ๐‘Ž๐‘๐‘พ[๐‘ ๐‘’๐‘๐‘œ๐‘›๐‘‘ ๐‘Ÿ๐‘œ๐‘ค]โˆ’= ๐‘›๐‘‡๐‘ฅ (๐‘Ž). [๐‘›๐‘‡ (๐‘) โˆง ๐‘ฅ๐‘ฆ๐‘พ] ๐‘ฆ ๐Ÿ’โˆ’ ๐‘Ž๐‘๐‘พ[๐‘ ๐‘’๐‘๐‘œ๐‘›๐‘‘ ๐‘๐‘œ๐‘™๐‘ข๐‘š๐‘›]โˆ’= ๐‘›๐‘‡ (๐‘). [๐‘›๐‘‡๐‘ฅ (๐‘Ž) โˆง ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พ] ๐‘ฆ ๐Ÿ“ โˆ’ ๐‘Ž๐‘๐‘พ[2][2]+= ๐‘›๐‘‡๐‘ฅ (๐‘Ž). ๐‘›๐‘‡ (๐‘) ๐Ÿ” โˆ’ ๐‘Ž๐‘๐‘พ[2: ๐‘˜, 2: ๐‘˜] = ๐‘ฅ๐‘ฆ๐‘พ Any of the above lines can be reached in ๐‘‚(๐‘˜) except ๐‘ฅ๐‘ฆ๐‘พ in line 6, which is given by the assumptions. This completes the proof. โ–  6.3.3 Main Algorithm for Inset Edge of Trees In this section, based on ๐‘จ), ๐‘ฉ), ๐‘ช) and ๐‘ซ) from proposition 6.20, we devise a recursive algorithm for computing {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )} ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) of a given tree ๐‘‡. Remark 6.20.5: Suppose ๐‘‡ is a tree, and we have, {(๐‘›๐‘ฃ๐‘‡ (๐‘ข), ๐‘›๐‘ข๐‘‡ (๐‘ฃ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) 1) If ๐‘ฃ โˆˆ ๐‘‰(๐‘‡) and ๐‘ฅ, ๐‘ฆ โˆˆ ๐‘(๐‘ฃ), then using lemma 6.2 and definitions ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ = [๐‘›๐‘ฃ๐‘‡ (๐‘ฅ)] ๐‘ฆ ๐‘ฅ๐‘ฆ๐‘พ = [๐‘›๐‘ฃ๐‘‡ (๐‘ฆ)] ๐‘ฅ๐‘ฆ๐‘พ = [๐‘›๐‘ฃ๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ)] โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– = ๐‘›๐‘ฃ๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = ๐‘›๐‘ฃ๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) 94 By proposition 6.20, we can compute the above equivalent data for the next parallel edges of ๐‘ฅ๐‘ฆ and so on. Thus, starting from every {๐‘ฅ, ๐‘ฆ} โІ ๐‘(๐‘ฃ) and producing the data for the next parallel edges, we will compute, ๐‘Š โ€ฒ for all the edges with the middle, ๐‘ฃ. โ–ฒ 2) If ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡) and ๐‘ฅ๐‘ฆ is the next parallel edge of ๐‘ข๐‘ฃ. By lemma 6.2 and definitions ๐‘ฅ ๐‘›๐‘ข๐‘‡ (๐‘ฅ) ๐‘ฅ๐‘ฆ๐‘พ =[ ] ๐‘›๐‘ฃ๐‘‡ (๐‘ข) โˆ’ ๐‘›๐‘ข๐‘‡ (๐‘ฅ) ๐‘ฆ ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘ฅ๐‘ฆ๐‘พ =[ ๐‘ข (๐‘ฃ) ] ๐‘›๐‘‡ โˆ’ ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘›๐‘ข๐‘‡ (๐‘ฅ) ๐‘ฅ๐‘ฆ๐‘พ = [ ] . [๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘›๐‘ข๐‘‡ (๐‘ฃ) โˆ’ ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ)] ๐‘›๐‘ฃ๐‘‡ (๐‘ข) โˆ’ ๐‘›๐‘ข๐‘‡ (๐‘ฅ) โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– = ๐‘›๐‘ข๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = 2. ๐‘›๐‘ข๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) Similar to 1) and using proposition 6.20, we can compute the above equivalent data for the next parallel edges of ๐‘ฅ๐‘ฆ and so on. That helps to compute ๐‘Š โ€ฒ for all the edges with the middle ๐‘ข๐‘ฃ. โ–ฒ By theorem 6.17, iterating the idea of 1) for the vertices of ๐‘‡ and 2) for the edges of ๐‘‡, we compute {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )} ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) . We will implement the mentioned method with the following algorithm. Its correctness follows the passed resultsโ€™ proof. Algorithm 6.21: Input: Adjacency list of an ๐‘›-vertex nontrivial tree ๐‘‡ Output: {๐‘พโ€ฒ(๐‘ป๐’Œ๐’™๐’š )}๐’™๐’šโˆˆ๐‘ฌ(๐‘ป๐’„) Compute ๐‘ = {(๐‘›๐‘ฃ๐‘‡ (๐‘ข), ๐‘›๐‘ข๐‘‡ (๐‘ฃ))}๐‘ข๐‘ฃโˆˆ๐ธ(๐‘‡) 95 ๐…๐จ๐ซ ๐‘ฃ โˆˆ ๐‘‰(๐‘‡): ๐…๐จ๐ซ ๐‘ฅ โˆˆ ๐‘(๐‘ฃ) ๐…๐จ๐ซ ๐‘ฆ โˆˆ ๐‘(๐‘ฃ) ๐ข๐Ÿ (๐‘ฅ โ‰  ๐‘ฆ) ๐‘ฅ๐‘ฆ๐‘พ = [๐‘›๐‘ฃ๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ)] ๐ด = ๐‘(๐‘ฅ) โˆ’ ๐‘ฃ ๐ต = ๐‘(๐‘ฆ) โˆ’ ๐‘ฃ ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ = [๐‘›๐‘ฃ๐‘‡ (๐‘ฅ)] ๐‘ฆ ๐‘ฅ๐‘ฆ๐‘พ = [๐‘›๐‘ฃ๐‘‡ (๐‘ฆ)] โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– = ๐‘›๐‘ฃ๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = ๐‘›๐‘ฃ๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐Ž๐ฎ๐ญ๐ฉ๐ฎ๐ญ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) and ๐‘Ž๐‘ ๐‘ฆ ๐…๐ฎ๐ง๐œ๐ญ๐ข๐จ๐ง( ๐‘ฅ๐‘ฆ๐‘พ, โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–, ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ), ๐ด, ๐ต, ๐‘ฅ, ๐‘ฆ, ๐‘˜ โ€ฒ = 1, ๐‘ = 1) ๐ž๐ง๐ ๐ž๐ง๐ ๐ž๐ง๐ ๐ž๐ง๐ 96 ๐…๐จ๐ซ ๐‘ข๐‘ฃ โˆˆ ๐ธ(๐‘‡): ๐…๐จ๐ซ ๐‘ฅ โˆˆ ๐‘(๐‘ข) โˆ’ ๐‘ฃ ๐…๐จ๐ซ ๐‘ฆ โˆˆ ๐‘(๐‘ฃ) โˆ’ ๐‘ข ๐‘›๐‘ข๐‘‡ (๐‘ฅ) ๐‘ฅ๐‘ฆ๐‘พ = [ ๐‘ฃ ] . [๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘›๐‘ข๐‘‡ (๐‘ฃ) โˆ’ ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ)] ๐‘›๐‘‡ (๐‘ข) โˆ’ ๐‘›๐‘ข๐‘‡ (๐‘ฅ) ๐ด = ๐‘(๐‘ฅ) โˆ’ ๐‘ข ๐ต = ๐‘(๐‘ฆ) โˆ’ ๐‘ฃ ๐‘ฅ ๐‘›๐‘ข๐‘‡ (๐‘ฅ) ๐‘ฅ๐‘ฆ๐‘พ =[ ] ๐‘›๐‘ฃ๐‘‡ (๐‘ข) โˆ’ ๐‘›๐‘ข๐‘‡ (๐‘ฅ) ๐‘ฆ ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘ฅ๐‘ฆ๐‘พ =[ ] ๐‘›๐‘ข๐‘‡ (๐‘ฃ) โˆ’ ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– = ๐‘›๐‘ข๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = 2. ๐‘›๐‘ข๐‘‡ (๐‘ฅ). ๐‘›๐‘ฃ๐‘‡ (๐‘ฆ) ๐Ž๐ฎ๐ญ๐ฉ๐ฎ๐ญ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) and ๐‘Ž๐‘ ๐‘ฆ ๐‘ญ๐’–๐’๐’„๐’•๐’Š๐’๐’( ๐‘ฅ๐‘ฆ๐‘พ, โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–, ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ), ๐ด, ๐ต, ๐‘ฅ, ๐‘ฆ, ๐‘˜ โ€ฒ = 1, ๐‘ = 2) ๐ž๐ง๐ ๐ž๐ง๐ ๐ž๐ง๐ 97 ๐‘ฆ ๐‘ญ๐’–๐’๐’„๐’•๐’Š๐’๐’( ๐‘ฅ๐‘ฆ๐‘พ, โ€–๐‘ถ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€–, ๐‘ฅ๐‘ฆ๐‘ฅ๐‘พ, ๐‘ฅ๐‘ฆ๐‘พ, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ), ๐ด, ๐ต, ๐‘ฅ, ๐‘ฆ, ๐‘˜ โ€ฒ , ๐‘) ๐ข๐Ÿ (๐ด โ‰  โˆ… ๐‘Ž๐‘›๐‘‘ ๐ต โ‰  โˆ…) ๐…๐จ๐ซ ๐‘Ž โˆˆ ๐ด ๐…๐จ๐ซ ๐‘ โˆˆ ๐ต ๐ด = ๐‘(๐‘Ž) โˆ’ ๐‘ฅ ๐ต = ๐‘(๐‘) โˆ’ ๐‘ฆ Compute โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€– \\based on ๐‘จ) proposition 6.20 and N ๐‘˜+2 Compute ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) \\based on ๐‘ฉ) proposition 6.20 and N ๐‘Ž ๐‘ Compute ๐‘Ž๐‘ ๐‘พ and ๐‘Ž๐‘ ๐‘พ \\based on ๐‘ช) proposition 6.20 and N Compute ๐‘Ž๐‘ ๐‘พ \\based on ๐‘ซ) proposition 6.20 and N ๐‘˜+2 ๐Ž๐ฎ๐ญ๐ฉ๐ฎ๐ญ ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ) and ๐‘Ž๐‘ ๐‘ญ๐’–๐’๐’„๐’•๐’Š๐’๐’( ๐‘Ž๐‘๐‘พ, โ€–๐‘ถ๐‘˜+2 โŠš ๐‘Ž๐‘๐‘พโ€–, ๐‘Ž๐‘๐‘Ž๐‘พ, ๐‘Ž๐‘๐‘๐‘พ, ๐‘Š โ€ฒ (๐‘‡๐‘Ž๐‘ ๐‘˜+2 ), ๐ด, ๐ต, ๐‘Ž, ๐‘, ๐‘˜ โ€ฒ + 1, ๐‘) ๐ž๐ง๐ ๐ž๐ง๐ ๐ž๐ง๐ โ–  6.3.4 Algorithm Complexity and Conclusion By theorem 6.17, each vertex/edge is the middle of an equivalence class of inset edge. Algorithm 6.21 iterates over the vertices and edges of a tree as middles, computing ๐‘Šโ€ฒ for each element of each class of inset edges regarding each middle using proposition 6.20. By theorem 6.17, the equivalence classes of middles partition the set of the treesโ€™ inset edges. Therefore, the algorithm uniquely covers all inset edges, computing {๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )} ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) . 98 Lemma 6.22: Suppose ๐‘‡ is a tree, and ๐‘ฃ โˆˆ ๐‘‰(๐บ) or ๐‘’ โˆˆ ๐ธ(๐บ) is the middle of the inset edge, ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ), with ๐‘‘(๐‘ฅ, ๐‘ฃ or ๐‘’) = ๐‘‘(๐‘ฆ, ๐‘ฃ or ๐‘’) = ๐‘˜. Then algorithm 6.21 computes ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ๐‘˜ ), in ๐‘‚(๐‘˜) = ๐‘‚(๐‘‘(๐‘ฅ, ๐‘ฆ))-time. Proof: Use remark 6.20.5 and proposition 6.20. โ–  Lemma 6.23(see [9,16]): If ๐‘‡ is a tree on ๐‘› vertices, then (๐‘› โˆ’ 1)2 โ‰ค ๐‘Š(๐‘‡ ) โ‰ค (๐‘›+1 3 ) โ–  The Wiener index of the moleculesโ€™ chemical graphs is correlated with the moleculesโ€™ specific physical and chemical properties. There are several efficient algorithms for calculating the Wiener index and its variations for a graph [1,7,11,13]. By theorm 3., one can calculate ๐‘Š(๐‘‡) in ๐‘‚(๐‘›)-time, where ๐‘› = |๐‘‰(๐‘‡)|. The next theorem gives a reflctive relation between the complexity of computing ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ) for all ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ) and ๐‘Š(๐‘‡). Theorem 6.24: Suppose ๐‘‡ is a tree. Algorithm 6.21โ€™s time complexity for computing {๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) is ๐‘‚(๐‘Š(๐‘‡))-time. Proof: Suppose ๐‘‡ is an ๐‘›-vertex tree and ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ) is an inset edge. According to lemma 6.22, algorithm 6.21 requires, at most ๐‘1 ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) + ๐‘2 operations to compute, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ), for some ๐‘1, ๐‘2 > 0. Thus by lemma 6.23, algorithm 6.21sโ€™ total operations for the computing {๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) is bounded by the following, where ๐‘3 ,๐‘4 , and ๐‘5 are some positive constants. ๐‘› โˆ‘ (๐‘1 ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) + ๐‘2 ) โ‰ค ๐‘3 โˆ‘ ๐‘‘ ๐‘‡ (๐‘ฅ, ๐‘ฆ) + (( ) โˆ’ (๐‘› โˆ’ 1)) ๐‘4 ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘ ) ๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘ ) 2 ๐‘› = ๐‘3 ๐‘Š(๐‘‡) + (( ) โˆ’ (๐‘› โˆ’ 1)) ๐‘4 โˆ’ ๐‘3 (๐‘› โˆ’ 1) < ๐‘5 ๐‘Š(๐‘‡). 2 That completes the proof. โ–  Remark 6.25: By theorem 6.24, computing {๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) takes ๐‘‚(๐‘Š(๐‘‡))-time. ๐‘›2 โˆ’3๐‘›+2 By [15], ๐‘Š(๐‘‡) โ‰ˆ (๐‘›2) log ๐‘›, on average. Due to the presence of ๐‘– = |๐ธ(๐‘‡ ๐‘ )| = inset 2 99 edges, we can sort {๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ๐‘˜ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) in ๐‘‚(๐‘–. log(๐‘›))-time. And it is surprising that, we can compute all elements of {๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) and then sort it, all in just ๐‘‚(๐‘–. log (๐‘›))-time on average. We will have ๐‘Š(๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ), once we have ๐‘Š(๐‘‡) and ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ), because ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ) โˆ’ ๐‘Š(๐‘‡) = ๐‘Š(๐‘‡๐‘ฅ๐‘ฆ ). Thus, the Wiener index of a unicyclic graph is computed in ๐‘‚(log ๐‘›)-time on average and ๐‘‚(1)-time at best by algorithm 6.21. Using general tools such as distance matrix, one achieves {๐‘Šโ€ฒ(๐บ๐‘ฅ๐‘ฆ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐บ๐‘) in ๐‘‚(๐‘›3 |๐ธ(๐บ ๐‘ )|) time. That gives an ๐‘‚(๐‘›5 )-time complexity when ๐บ is a tree [20]. โ–ฒ The main algorithms is implemented on the pg platform by professor Esfahanian. See appendix D. Remark 6.26: We saw that ๐‘Š โ€ฒ (๐‘‡๐‘ข๐‘ฃ 3 ) = ๐‘ค๐‘ข . ๐‘ค๐‘ฃ . We guess that computing ๐‘Šโ€ฒ(๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) for any ๐‘ฅ๐‘ฆ โˆˆ ๐ธ(๐‘‡ ๐‘ ) can be done in ๐‘‚(1)-time, which is now ๐‘‚(๐‘‘(๐‘ฅ, ๐‘ฆ)) by algorithm 6.21. We will probably need more matrix techniques to achieve such a time complexity. Moreover, if we only want to find the minimum of ๐‘Šโ€ฒ, we can limit the search space based on the middles. Thus, based on our intuition, we have the following conjectures: Conjecture 6.27: {๐‘Š(๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ )}๐‘ฅ๐‘ฆโˆˆ๐ธ(๐‘‡ ๐‘) can be calculated in ๐‘‚(|๐ธ(๐‘‡ ๐‘ )|)-time. โ–ฒ Conjecture 6.28: For a given tree, ๐‘‡, the middle(s) of the inset edge(s) with the minimum ๐‘Š โ€ฒ belong(s) to ๐ธ(๐‘ƒโ€ฒ ) โˆช ๐‘‰(๐‘ƒโ€ฒ ) with ๐‘ƒโ€ฒ is the longest path(s) between the center(s) and ๐œŽ๐‘‡ -Root(s) of ๐‘‡. โ–ฒ 100 REFERENCES [1] Roberto Aringhieri, Pierre Hansen, Federico Malucelli, A Linear Algorithm for the Hyper- Wiener Index of Chemical Trees, J. Chem. Inf. Comput. Sci., 41 (2001), 958-963. [2] F. Chung, L. Lu, The Average Distances in Random Graphs with Given Expected Degrees, Proceedings of the National Academy of Sciences, 99 (2002), 15879-15882. [3] A. Clauset, C. Moore, M. E. J. Newman, Hierarchical Structure and the Prediction of Missing Links in Networks, Nature, 453 (2008), 98-101. [4] J. Copic, M. O. Jackson, A. Kirman, Identifying Community Structures from Network Data via Maximum Likelihood Methods, The B.E. Journal of Theoretical Economics, 9 (2005), 09-27. [5] S. Currarini, M. O. Jackson, P. Pin, An Economic Model of Friendship: Homophily, Minorities and Segregation, Econometrica, 77 (2009), 1003-1045. [6] A. Drger, M. Kronfeld, M. J. Ziller, J. Supper, H. Planatscher, J.B. Magnus, M. Oldiges, O. Kohlbacher, A. Zell, Modeling metabolic networks in C. glutamicum: a comparison of rate laws in combination with various parameter optimization strategies", BMC Syst. Biol., 3 (2009). [7] M.H. Khalifeh, Abdol-Hossein Esfahanian, Some results about the inset edge and average distance of trees, Discrete Appl. Math., 325 (2023), 186-199. [8] Aleksander Kelenc, Sandi Klavลพar, Niko Tratnik, The Edge-Wiener Index of Benzenoid Systems in Linear Time, MATCH Commun. Math. Comput. Chem., 74 (2015), 521-532. [9] M.H. Khalifeh, H.Yousefi Azari, A.R. Ashrafi, S.G. Wagner, Some new results on distance- based graph invariants, Eur. J. Comb., 30 (2009), 1149-1163. [10] Sandi Klavzar, Ivan Gutman, Wiener number of vertex-weighted and a chemical application, Discrete Appl. Math., 80 (1997), 73-81. [11] Sandi Klavลพar, Petra ลฝigert, Ivan Gutman, An algorithm for the calculation of the hyper- Wiener index of benzenoid hydrocarbons, Computers & Chemistry, 24 (2000), 229-233. [12] Y. Matsuo, Y. Ohsawa, M. Ishizuka, Average-Clicks: A New Measure of Distance on the World Wide Web, Journal of Intelligent Information Systems, 20 (2003), 20-51. [13] Bojan Mohar, Tomaลพ Pisanski, How To Compute The Winer Index of a Graph, J. of 101 Mathematical Chem., 267 (1988), 277 267. [14] A. Meyerson, B. Tagiku, Minimizing Average Shortest Path Distances via Shortcut Edge Addition, Approximation, randomization, and combinatorial optimization, Algorithms and techniques. 12th international workshop, APPROX 2009, and 13th international workshop, RANDOM 2009, Berkeley, CA, USA, August 2123, (2009), Proceedings (pp.272-285) [15] Z. Shen, The average diameter of general tree structures, Comput. Math. Appl., 36 (1998), 111-130. [16] H. B. Valikara, V. S. Shigehali, H. S. Ramane, Bounds on the Wiener number of a graph, MATCH Commun. Math. Comput. Chem, 50 (2004), 117-132. [17] Stephan G. Wagner, A Class of Trees and its Wiener Index, Acta Applicandae Mathematica, 91 (2006), 119-132. [18] H. Wiener, Structural determination of the paraffin boiling points, J. Am. Chem. Soc., 69 (1947), 17-20. [19] A. R. Ashrafi, S. Yousefi, A new algorithm for computing distance matrix and Wiener index of zig-zag polyhex nanotubes, Nanoscale Research Letters, 2 (2007), 202-206. [20] Dennis Ross, Edge impact in graphs and social network matrix completion, Diss. Michigan State University, (2014). 102 APPENDIX A: EQUATIONS 6-10 TO 6-12 ๐‘ฆ ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 We have ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘ฅ , 1,1, โ€ฆ ,1]๐‘ก and ๐‘ฅ๐‘ฆ๐‘พ = [๐‘ค๐‘ฆ , 1,1, โ€ฆ ,1], and ๐‘ค๐‘ฅ ๐‘ค๐‘ฆ = โŒŠ โŒ‹.โŒˆ โŒ‰. 2 2 ๐‘›โˆ’๐‘˜+2 ๐‘›โˆ’๐‘˜+2 Without loss of generality, we can let ๐‘ค๐‘ฅ = โŒŠ โŒ‹ and ๐‘ค๐‘ฆ = โŒˆ โŒ‰. By lemma 6.2 2 2 ๐‘ฆ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘ฆ ๐‘˜ ) = โ€–๐‘ญ๐‘˜ โŠš ๐‘ฅ๐‘ฆ๐‘พโ€– = โ€–๐‘ญ๐‘˜ โŠš ( ๐‘ฅ๐‘ฆ ๐‘ฅ ๐‘พ ร— ( ๐‘ฅ๐‘ฆ๐‘พ)๐‘ก )โ€–. If we use the definition of ๐น๐‘˜ for the given ๐‘˜โ€™s and calculate the above formula, we earn the given formulas, 6.10 to 6.12. 103 APPENDIX B: THE FORMULAS OF THEOREM 6.6 First of all, ๐‘ฅ2 ๐‘ฅ1 ๐‘ฅ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ1 ๐‘ฆ1 ๐‘พ[2: ] + ๐‘ฅ1๐‘ฆ11 ๐‘ค1 โ‹… ๐‘’1 , ๐‘ฆ2 ๐‘ฆ1 ๐‘ฆ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = ๐‘ฅ1 ๐‘ฆ1 ๐‘พ[2: ] + ๐‘ฅ1๐‘ฆ11 ๐‘ค1 โ‹… ๐‘’1 mean ๐‘ฅ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค2 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค2 ๐‘ฅ1 0 ๐‘ค๐‘ฅ2 ๐‘ค๐‘ฅ1 ๐‘ฅ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค3 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค3 ๐‘ค๐‘ฅ3 0 ๐‘ฅ2 ๐‘ฆ2 1. ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = + = + ๐‘ฅ2 ๐‘ฆ2 ๐‘พ = + โ‹ฎ โ‹ฎ โ‹ฎ [๐‘ค๐‘ฅ๐‘˜โ€ฒ ] [ 0 ] โ‹ฎ ๐‘ฅ1 โ‹ฎ ๐‘ฅ1 [ ๐‘ฅ1 ๐‘ฆ1๐‘ค๐‘˜ โ€ฒ ] [ 0 ] [ ๐‘ฅ1๐‘ฆ1๐‘ค๐‘˜ โ€ฒ ] ๐‘ฆ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค1 0 ๐‘ค๐‘ฆ2 ๐‘ค๐‘ฆ1 ๐‘ค๐‘ฆ3 0 = + โ‹ฎ โ‹ฎ [๐‘ค๐‘ฆ๐‘˜โ€ฒ ] [ 0 ] โ‹ฎ [ 0 ] Where, ๐‘ฅ1 ๐‘ฆ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค1 ๐‘ฅ1 ๐‘ค๐‘ฅ1 ๐‘ฆ1 ๐‘ค๐‘ฆ1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค2 ๐‘ฅ1 ๐‘ฆ1 ๐‘ค2 ๐‘ค๐‘ฅ2 ๐‘ค๐‘ฆ2 ๐‘ฅ1 ๐‘ฆ ๐‘ฆ1 ๐‘ฅ ๐‘ฅ๐‘ฆ๐‘พ = ๐‘ฅ1 ๐‘ฆ1 ๐‘พ = = and ๐‘ฅ๐‘ฆ๐‘พ = ๐‘ฅ1 ๐‘ฆ1 ๐‘พ = = โ‹ฎ โ‹ฎ โ‹ฎ [๐‘ค๐‘ฅ๐‘˜โ€ฒ ] โ‹ฎ [๐‘ค๐‘ฆ๐‘˜โ€ฒ ] ๐‘ฅ1 ๐‘ฆ1 [ ๐‘ฅ1๐‘ฆ1๐‘ค๐‘˜ โ€ฒ ] [ ๐‘ฅ1๐‘ฆ1 ๐‘ค๐‘˜ โ€ฒ ] Also, 104 2๐‘˜ โ€ฒ โˆ’ 1 2๐‘˜ โ€ฒ โˆ’ 3 2๐‘˜ โ€ฒ โˆ’ 5 โ€ฆ 1 2๐‘˜ โ€ฒ โˆ’ 3 2๐‘˜ โ€ฒ โˆ’ 5 โ€ฆ 1 0 2๐‘˜ โ€ฒ โˆ’ 5 โ€ฆ 1 0 0 ๐‘ญ๐‘˜ = โ‹ฎ ๐‘˜ is odd โ‹ฎ 1 โ‹ฎ โ‹ฎ 1 0 โ€ฆ 0 [ 1 0 0 โ€ฆ 0 0] 2๐‘˜ โ€ฒ โˆ’ 2 2๐‘˜ โ€ฒ โˆ’ 4 2๐‘˜ โ€ฒ โˆ’ 6 โ€ฆ 2 0 2๐‘˜ โ€ฒ โˆ’ 4 2๐‘˜ โ€ฒ โˆ’ 6 โ€ฆ 2 0 0 2๐‘˜ โ€ฒ โˆ’ 6 โ‹ฎ โ€ฆ 2 0 0 0 โ‹ฎ 0 ๐‘ญ๐‘˜ = ๐‘˜ is even โ‹ฎ 2 โ‹ฎ 2 0 โ‹ฎ 2 0 0 โ€ฆ 0 [ 0 0 0 โ€ฆ 0 0 ] Thus, ๐‘ฅ1 ๐‘ฅ ๐‘ฅ1 ๐‘ฆ1 ๐‘พ = ๐‘ฅ1 ๐‘ฆ1 ๐‘พ ร— ( ๐‘ฅ1๐‘ฆ11 ๐‘พ)๐‘ก ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ1 ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ2 ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ3 โ€ฆ ๐‘ค๐‘ฅ1 . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ ๐‘ค๐‘ฅ2 . ๐‘ค๐‘ฆ1 ๐‘ค๐‘ฅ2 . ๐‘ค๐‘ฆ2 โ‹ฎ โ€ฆ ๐‘ค๐‘ฅ2 . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ ๐‘ค๐‘ฅ3 . ๐‘ค๐‘ฆ1 โ‹ฎ โ€ฆ ๐‘ค๐‘ฅ3 . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ = โ‹ฎ โ€ฆ โ‹ฎ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ1 โ€ฆ โ‹ฎ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ โˆ’2 ๐‘˜ โˆ’2 ๐‘˜ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ1 โ€ฆ โ‹ฎ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ๐‘˜ โˆ’1 ๐‘˜ โˆ’1 ๐‘˜ โˆ’1 ๐‘˜ โˆ’1 ๐‘˜ [ ๐‘ค๐‘ฅ . ๐‘ค ๐‘ฆ โ€ฆ ๐‘ค ๐‘ฅ . ๐‘ค ๐‘ฆ ๐‘ค ๐‘ฅ . ๐‘ค ๐‘ฆ ๐‘ค๐‘ฅ โ€ฒ . ๐‘ค๐‘ฆ โ€ฒ ] ๐‘˜โ€ฒ 1 ๐‘˜โ€ฒ ๐‘˜โ€ฒ โˆ’2 ๐‘˜โ€ฒ ๐‘˜โ€ฒ โˆ’1 ๐‘˜ ๐‘˜ ๐‘ค11 ๐‘ค12 ๐‘ค13 โ€ฆ ๐‘ค1๐‘˜ โ€ฒ ๐‘ค21 ๐‘ค22 โ‹ฎ โ€ฆ ๐‘ค2๐‘˜ โ€ฒ ๐‘ค31 โ‹ฎ ๐‘ค3๐‘˜ โ€ฒ = โ‹ฎ โ€ฆ โ‹ฎ ๐‘ค๐‘˜ โ€ฒ โˆ’2,1 โ€ฆ โ‹ฎ ๐‘ค๐‘˜ โ€ฒ โˆ’2,๐‘˜ โ€ฒ ๐‘ค๐‘˜ โ€ฒ โˆ’1,1 โ€ฆ โ‹ฎ ๐‘ค๐‘˜ โ€ฒ โˆ’1,๐‘˜ โ€ฒ โˆ’1 ๐‘ค๐‘˜ โ€ฒ โˆ’1,๐‘˜ โ€ฒ [ ๐‘ค๐‘˜ ,1 โ€ฒ โ€ฆ ๐‘ค๐‘˜ ,๐‘˜ โˆ’2 ๐‘ค๐‘˜ โ€ฒ ,๐‘˜โ€ฒ โˆ’1 โ€ฒ โ€ฒ ๐‘ค๐‘˜ โ€ฒ ,๐‘˜ โ€ฒ ] ๐‘ฅ2 Similarly, we can expand ๐‘ฅ2 ๐‘ฆ2 ๐‘พ in the following with the given vectores ๐‘ฅ2 ๐‘ฆ2 ๐‘พ and ๐‘ฆ2 ๐‘ฅ2 ๐‘ฆ2 ๐‘พ ๐‘ฅ2 ๐‘ฅ ๐‘ฅ2 ๐‘ฆ2 ๐‘พ= ๐‘ฅ2 ๐‘ฆ2 ๐‘พ ร— ( ๐‘ฅ2๐‘ฆ22 ๐‘พ)๐‘ก 105 Therefore, after a tedious calculation by theorem 6.l, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ) = โ€–๐‘ญ๐‘˜โˆ’2 โŠš ๐‘ฅ2 ๐‘ฆ2๐‘พโ€– โˆ’ โ€–๐‘ญ๐‘˜ โŠš ๐‘ฅ1๐‘ฆ1 ๐‘พโ€– โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ ๐‘ค11 ๐‘˜ is even, 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–,๐‘—>1 = 2( โˆ‘ ๐‘ค๐‘–๐‘— ) + โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ 2๐‘ค11 ๐‘˜ is odd. 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–+๐‘—=๐‘˜ โ€ฒ +2 { ๐‘–,๐‘—>1 ๐‘–,๐‘—>1 106 APPENDIX C: FOR COROLLARY 6.8 AND THEOREM 6.9 For ๐‘˜ = 5 , if ๐‘ค๐‘ฅ1 = ๐‘ค๐‘ฆ1 = 1, then ๐‘ค๐‘ฅ2 + ๐‘ค๐‘ฆ2 + ๐‘ค๐‘€ = ๐‘› โˆ’ 2. Using the indexing of the cycle of ๐‘‡๐‘ฅ51 ๐‘ฆ1 we have: ๐‘Š โ€ฒ (๐‘‡๐‘ฅ51๐‘ฆ1 ) = 3 + ๐‘ค๐‘ฆ2 + ๐‘ค๐‘ฅ2 , ๐‘Š โ€ฒ (๐‘‡๐‘ฅ32๐‘ฆ2 ) = (1 + ๐‘ค๐‘ฅ2 )(๐‘ค๐‘ฆ2 + 1), ๐‘Š โ€ฒ (๐‘‡๐‘ฅ42๐‘ฆ1 ) = 2(1 + ๐‘ค๐‘ฅ2 ), ๐‘Š โ€ฒ (๐‘‡๐‘ฅ41๐‘ฆ2 ) = 2(1 + ๐‘ค๐‘ฆ2 ), ๐‘Š โ€ฒ (๐‘‡๐‘ฅ3๐‘€ ๐‘ฆ1 ) = 1 + ๐‘ค๐‘ฅ1 + ๐‘ค๐‘ฅ2 + ๐‘ค๐‘ฅ๐‘€ , ๐‘Š โ€ฒ (๐‘‡๐‘ฅ3๐‘€ ๐‘ฅ1 ) = 1 + ๐‘ค๐‘ฆ1 + ๐‘ค๐‘ฆ2 + ๐‘ค๐‘ฅ๐‘€ . Given ๐‘ค๐‘ฅ1 = ๐‘ค๐‘ฆ1 = 1, ๐‘ค๐‘ฅ2 + ๐‘ค๐‘ฆ2 + ๐‘ค๐‘€ = ๐‘› โˆ’ 2, and ๐‘› > 6, clearly either ๐‘Š โ€ฒ (๐‘‡๐‘ฅ41 2 ๐‘ฆ1 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’1 1 ๐‘ฆ2 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 ๐‘€ ๐‘ฆ1 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2๐‘€ ๐‘ฅ1 ) or, ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜โˆ’2 2 ๐‘ฆ2 ) is greater than ๐‘Š โ€ฒ (๐‘‡๐‘ฅ๐‘˜1๐‘ฆ1 ). 4: equations 6.20 and 6.21 We know that ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘ง ๐‘˜) = โ€–๐‘ญ๐‘˜ โŠš ( ๐‘ฃ๐‘ง ๐‘ฃ ๐‘พ ร— ( ๐‘ฃ๐‘ง๐‘ง ๐‘พ)๐‘ก )โ€– and ๐‘ฅ๐‘ฆ๐‘พ = ๐‘ฃ ๐‘ฃ๐‘ง๐‘พ ๐‘ง ร— ( ๐‘ฃ๐‘ง ๐‘พ)๐‘ก = [๐‘ค๐‘–๐‘— ]. In the theorem we have ๐‘ฃ ๐‘ฃ๐‘ง๐‘พ = [1,1, โ€ฆ ,1]๐‘ก , ๐‘ง ๐‘ฃ๐‘ง๐‘พ = [๐‘Ž๐‘– ]๐‘˜ โ€ฒ , and ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’1 2 ๐‘ง1 )= โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ โˆ‘ ๐‘ค1๐‘— . 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 0<๐‘—โ‰ค๐‘˜โ€ฒ ๐‘–>1, ๐‘—<๐‘˜โ€ฒ Thus, ๐‘˜ โ€ฒ โˆ’1 โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ โˆ‘ ๐‘ค1๐‘— , = ๐‘Ž๐‘˜ โ€ฒ โˆ’ โˆ‘ (๐‘˜ โ€ฒ โˆ’ ๐‘–)๐‘Ž๐‘– , 3โ‰ค๐‘–+๐‘— โ‰ค ๐‘˜ โ€ฒ +1 0<๐‘—โ‰ค๐‘˜ โ€ฒ ๐‘–=1 ๐‘–>1, ๐‘—<๐‘˜ โ€ฒ โ€ฒ and ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’1 2 ๐‘ง1 ) means, ๐‘Ž๐‘˜ โ€ฒ โ‰ฅ โˆ‘๐‘˜๐‘–=1โˆ’1(๐‘˜ โ€ฒ โˆ’ ๐‘–)๐‘Ž๐‘– . Similarly, if 107 ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’2 2 ๐‘ง2 ) = 2( โˆ‘ ๐‘ค๐‘–๐‘— ) + โˆ‘ ๐‘ค๐‘–๐‘— โˆ’ 2๐‘ค11 , 4โ‰ค๐‘–+๐‘—โ‰ค๐‘˜ โ€ฒ +1 ๐‘–+๐‘—=๐‘˜ โ€ฒ +2 ๐‘–,๐‘—>1 ๐‘–,๐‘—>1 then ๐‘˜โ€ฒ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1 ๐‘ง1 ) โˆ’ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’2 2 ๐‘ง2 ) = 2๐‘Ž1 โˆ’ โˆ‘(2๐‘˜ โ€ฒ โˆ’ 2๐‘– + 1)๐‘Ž๐‘– . ๐‘–=2 โ€ฒ And ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜1๐‘ง1 ) โ‰ฅ ๐‘Š โ€ฒ (๐‘‡๐‘ฃ๐‘˜โˆ’2 2 ๐‘ง2 ) means 2๐‘Ž1 โ‰ฅ โˆ‘๐‘˜๐‘–=2(2๐‘˜ โ€ฒ โˆ’ 2๐‘– + 1)๐‘Ž๐‘– . 108 APPENDIX D: ALGORITHM 6.21 IN pg import pg import time import networkx from numpy import linalg as LN import numpy as np import copy def vertex_weight(G): lst=[] for item in G: lst.append([item, 1]) return lst E =30 # number of edges t=pg.random_tree(E) # a random tree on E edges adj_list=t.adjacency_list() A_L=t.adjacency_list() tree_leaves=t.leaves() weihted_adg_t=vertex_weight(adj_list) nunv=[] n=E N=np.zeros((n,n)) while E!= 1: #Producing matrix of ๐‘›๐‘ข (๐‘ฃ)๐‘›๐‘ฃ (๐‘ข) S=tree_leaves tree_leaves=[] for v in S: if E==1: break u=adj_list[v][0] weihted_adg_t[u][1]+=weihted_adg_t[v][1] 109 nunv.append((u, v)) N[u][v]= weihted_adg_t[v][1] N[v][u]= n-weihted_adg_t[v][1] adj_list[u].remove(v) E-=1 if len(adj_list[u])==1: tree_leaves.append(u) W=0 for uv in nunv: u=uv[0] v=uv[1] W+=N[u][v]*N[v][u] wiener=t.wienerIndex() impacts=[] '''''''''''''''''''''''''''''''''''''''''''''''''''''''''' xyW=np.zeros((n,n)) xyxW=np.zeros((n,1)) xyyW=np.zeros((1,n)) ccc=[0] def function (A, B, x, y, k, N_OxyW, Wp, kp,xyW,xyxW,xyyW): ccc[0]+=1 if A and B: for a in A: Ap = A_L[a][:] Ap.remove(x) for b in B: xyW2=np.zeros((k+1,k+1)) xyxW2=np.zeros((k+1,1)) xyyW2=np.zeros((1,k+1)) 110 Bp = A_L[b][:] Bp.remove(y) nxa = N[x][a] nyb = N[y][b] nxny = nxa*nyb # nxa*nyb nW_d = sum([ xyW[-k+i][-1-i] for i in range(k)]) #||xyW[i+j=k+1]|| xyyW2[0][0] = nyb #[nyb^xyyW] xyyW2[0,1:] = xyyW[0,:] r =nxa * xyyW2 # nxa*[nyb^xyxW] xyxW2[0][0] = nxa #[nxa^xyxW] xyxW2[1:,0]= xyxW[:,0] c = nyb * xyxW2 # nxa*[nyb^xyxW] #print("xyW2[0, :] = r[:] = ",xyW2[0, :] , r[:]) #abW xyW2[1:,1:] = xyW xyW2[0, :] = r[0,:] xyW2[:, 0] = c[:,0] xyW2[1,:] -= r[0,:] xyW2[:,1] -= c[:,0] xyW2[1][1]+= nxny n_r=np.sum(r) #||nxa*[nyb^xyxW]|| n_c=np.sum(c) #||nyb*[nxa^xyxW]|| #||O*abW|| N_OxyW_k2 = (nxa*xyyW2[0][-1] + nyb*xyxW2[-1][0] + N_OxyW - nW_d ) if kp == 2: Wp2 = Wp + 2*(nW_d - N_OxyW + n_r + n_c - nxa*xyyW2[0][-1] -nyb*xyxW2[-1][0] - 2*nxny) elif kp ==3: 111 Wp2 = Wp + nW_d + 2*( n_r + n_c - 2*nxny - N_OxyW) -nxa*xyyW2[0][-1] -nyb*xyxW2[-1][0] else: Wp2 = n_r + n_c - nxny N_OxyW_k2 = n_r + n_c - 3*nxny #abaW xyxW2[1][0] -=nxa #xyxW[-k-1][0]= N[x][a][1] #abbW xyyW2[0][1] -=nyb #xyyW[0][-k-1]= N[y][b][1] impacts.append((W-Wp2,(a,b))) if kp==2: function (Ap, Bp, a, b, k+1, N_OxyW_k2, Wp2, 2,xyW2,xyxW2,xyyW2) else: function (Ap, Bp, a, b, k+1, N_OxyW_k2, Wp2, 3,xyW2,xyxW2,xyyW2) for v, nv in enumerate(A_L): if len(nv)>1: xyW=np.zeros((1,1)) xyxW=np.zeros((1,1)) xyyW=np.zeros((1,1)) for i, x in enumerate(nv): A=A_L[x][:] A.remove(v) for y in nv[i+1:]: B=A_L[y][:] B.remove(v) nvx = N[v][x] 112 nvy = N[v][y] xyW[0][0] = nvx*nvy xyxW[0][0] = nvx xyyW[0][0] = nvy N_OxyW = nvx*nvy Wp = N_OxyW impacts.append((W-Wp,(x,y))) function( A, B, x, y, 1, N_OxyW, Wp,1,xyW,xyxW,xyyW) for uv in nunv: u = uv[0] v = uv[1] nu = A_L[u][:] nv = A_L[v][:] nu.remove(v) nv.remove(u) if nu and nv: xyW=np.zeros((2,2)) xyxW=np.zeros((2,1)) xyyW=np.zeros((1,2)) #print(u,v,nu,nv) for x in nu: A=A_L[x][:] A.remove(u) for y in nv: #print(x,y) #print(A_L[x],v) #print(A_L[y],v) B=A_L[y][:] 113 B.remove(v) nux = N[u][x] nvy = N[v][y] xyxW[0][0] = nux xyxW[1][0] = N[v][u] - nux xyyW[0][0] = nvy xyyW[0][1] = N[u][v] - nvy xyW=xyxW*xyyW N_OxyW = np.sum(xyW)-xyW[-1][-1] Wp = 2*nux*nvy impacts.append((W-Wp,(x,y))) function( A, B, x, y, 2, N_OxyW, Wp , 2,xyW,xyxW,xyyW) print("done") print(n*(n-1)/2-(n-1),ccc, len(impacts)) impacts.sort() print(impacts[0],W,W-impacts[1][1]) print("done") comp=t.edgeImpact() print(comp[-1]) 114