The Shortest Path Problem for the Distant Graph of the Projective Line Over the Ring of Integers

The distant graph $G = G(\mathbb{P}(Z),\triangle)$ of the projective line over the ring of integers is considered. The shortest path problem in this graph is solved by use of Klein's geometric interpretation of Euclidean continued fractions. In case the minimal path is non-unique, all the possible splitting are described which allows us to give necessary and sufficient conditions for existence of a unique shortest path.


Introduction
The projective line P(R) over any ring R with 1 can be defined using admissible pairs( [BHa00]). For some rings, for example for commutative ones, it is equivalent to using unimodular pairs. One of the basic concerning the projective line over ring P(R) is the distant relation on the set of points. A pair (x,ȳ) ∈ P(R) × P(R) is in the distant relation if det[x, y] is a unit in R for any choice x ∈x and y ∈ȳ. In that way one defines distant graph G = G(P(R), ) for any ring P(R) ( [BHe05]). The vertices of the distant graph on P(R) are the points of P(R), the edges of the graph are the undirected pairs of distant points. The distance function dist(x,ȳ) is the minimal number of edges needed to walk fromx toȳ. Diameter of the G is the supremum of all distances between its points.
The notion of the distant relation was introduced in the nineties of the previous century (see e.g. [He95]). A. Blunck and H. Havlicek explored this notion later in [BHa01] and [BHa05]. They gave for instance the necessary and sufficient condition for the distant graph to be connected. Until today it is not known too much more about this class of graphs.
We consider the projective line over Z. In this case points of P(Z) are cyclic modules Z(a, b), where (a, b) ∈ Z × Z is a unimodular pair. Because Z is GE 2 ring ( [C66]), the distant graph G is connected ( [BHa01], [BHa05]) of the infinite diameter. In this paper we give a simple direct proof of this fact.
The aim of this paper is to analyse paths in the distant graph G(P(R), ) and solve the shortest path problem for it.
The main tool in our considerations is the transition algorithm introduced in [SW11] (see also [SW14]) for bases of Z 2 in order to investigate some kind of Markov partitions of the two dimensional torus. We adopt this algorithm and express it in terms of the projective line. Then we make use of it to find the shortest paths connecting given two non-adjacent vertices. It also allows us to provide the necessary and sufficient conditions for existence of the exactly one shortest path between them.
For any non-adjacent verticesx ,ȳ ∈ G(P(R), ) we define so called cone relations on P(Z) \ {x,ȳ} with precisely two equivalence classes. Any path entirely contained in one of this classes is called a consistent path. We prove that in each of equivalence classes of the cone relation there is precisely one shortest path connectingx andȳ (Theorem 3.1). All vertices of those two paths together withx andȳ form the set of vertices of some subgraph, called by us the Klein graph K(x,ȳ). If we abandon the assumption of consistency then the issue becomes more complicated. It turns out that in general there may be lots of shortest paths between two non-adjacent vertices. Nevertheless we prove that there is at least one shortest path which is contained in some induced subgraph of K(x,ȳ) called by us a corner graph. This observation allows us to give a recipe to find one of the shortest path. Consequently we obtain the formula for the distance dist(x,ȳ) between two vertices (Theorem 4.5). Further, the careful insight into the corner graph enables to formulate the necessary and sufficient conditions for the existence of more than one shortest path (Theorem 5.3).
We would like to express our gratitude to professor Hans Havlicek for attracting our attention to the problem and fruitful discussion on the subject.
We also thank to Mariusz Bodzioch, a PhD student of our faculty, for help in preparing the figures.

Basic tools
Having two adjacent verticesē,f ∈ P(Z) we may create four bases in Z 2 : The basic property of those bases is the following lemma proved in [SW11]: The above lemma may be expressed in various ways. It is, for example, equivalent to the fact that the interior of the parallelogram spanned by members of a basis in Z 2 contains no vectors from Z 2 . In other words the only vectors in the closed parallelogram are its vertices. By Pick's formula this is equivalent for the parallelogram to have area equal to one. This is in turn equivalent to the equality where [e, f ] stands for the matrix with columns equal to e and f respectively. To interpret the above lemma in terms of projective line we need to define some equivalence relation on P(Z) \ {x,ȳ} for every distinct elementsx,ȳ ∈ P(Z):ū ∼ {x,ȳ}v if α ux α uy α vx α vy > 0, where α ux , α uy , α vx , α vy ∈ R such that Each such a relation call a cone relation. Since each of vectors in the inequality appears twice, the relation is well defined. Every cone relation has two equivalence classes being images of C + (x, y) ∩ Z 2 and C − (x, y) ∩ Z 2 by the canonical projection from the plane onto the projective line. Now Lemma 2.1 has the following interpretation.
We will need also the following obvious observation.
Lemma 2.3. Ifx,ȳ,ū andv are pairwise distinct elements of P(Z) then In the graph theory the set of vertices is called a clique if its elements are pairwise adjacent. From Lemma 2.2 one can easily deduce the following corollary.
1. The maximal clique in P(Z) has exactly three elements.
2. Every pair of adjacent vertices belongs to precisely two maximal cliques.
3. If {x,ȳ,ū} and {x,ȳ,v} are two maximal cliques then It is not difficult to find maximal cliques for every pairx ȳ. Indeed {x,ȳ, x + y} and {x,ȳ, x − y} are the only maximal cliques containingx andȳ. Now we will express the algorithm from [SW11] in terms of the projective line and will use it in the two next section to find shortest paths connecting an arbitrary pair of vertices of the distant graph.
Using the Extended Euclidean Algorithm find a sequence (c n ) n∈Z of all vertices of the distant graph adjacent tox. The sequence (c n ) n∈Z may be ordered in such a way that {c n ,c n+1 ,x} is a clique for every n ∈ Z. Ifȳ ∈ (c n ) then stop.
If not, find precisely one n 0 ∈ Z such thatc n 0 ∼ {x,ȳ}cn 0 +1 . Denotec n 0 and c n 0 +1 byē 1 andf 1 arbitrarily. By 1. and 2. of Corollary 2.4 there is precisely oneḡ 2 =x such that {ē 1 ,f 1 ,ḡ 2 } is a clique. Either In the sequel of this paper we assume the case (TR). The other case is completely symmetric. It means that considering (TL) instead of (TR) we have to mutually exchange all notations. For instance we exchange symbols e j andf j . Later on we introduce some numbers r, a j , A j associated to verticesē j and l, b j , B j associated to verticesf j . We also must exchange them considering the case (TL) instead of (TR).
If not, denoted the above vertex byf 2 and repeat the same construction with e a 1 +1 andf 2 playing role off 1 andē 2 , respectively. We get the sequence Then repeat the above construction withē a 1 +1 andf b 1 +1 playing role ofē 1 and f 1 , respectively. The transition algorithm is depicted in Fig. 1 Since all lines in R 2 determined by members of P(Z) are rational our algorithm eventually stops after reachingȳ. The proof of this is specially easy if we express the transition algorithm in terms of bases of Z 2 . It will be presented in the forthcoming paper [MS15].
By construction both sequences are contained in the different equivalence classes of ∼ {x,ȳ} and two consecutive vertices in each of them are adjacent.
Verticesē A k andf B k , excludedȳ, will be called corner vertices. Note that by construction r − l ∈ {0, 1}.
Two sequences constructed in the above algorithm may be organized as a sequence of adjacent pairs of vertices. (2) To the set of vertices defined above addx andȳ. The resulting set with appropriate edges is an induced subgraph of the distant graph and will be called a Klein graph associated tox andȳ. Denote it by K(x,ȳ). If we consider only corner vertices in this graph we get an induced subgraph which we will call a corner graph and denote by K(x,ȳ).
The Klein graph is depicted in Fig. 2. All vertices of the corner graph are marked in black. The bolded edges are edges of the standard path to be defined in the beginning of Section 4.
3 Consistent paths Definition 1. A path connectingx andȳ in the distant graph is called consistent if all its elements butx andȳ are contained in the same equivalence classes of ∼ {x,ȳ} . The length of the shortest consistent path betweenx andȳ is denoted by d c (x,ȳ).
1. The union of every equivalence classes of ∼ {x,ȳ} and {x,ȳ} contains a unique consistent path connectingx andȳ. The lengths of those two paths are equal to where the numbers A r and B l are taken from the transition algorithm.
In particular the distant graph of P(Z) is connected.
2. There are at most two shortest consistent paths connectingx andȳ in the distant graph.
3. There is a unique consistent path connectingx andȳ in the distant graph if and only if Proof. Takex,ȳ ∈ P(Z). Consider the path where verticesē 1 , . . . ,ē Ar are taken from the transition algorithm described in the previous section. It is by construction consistent. Take another consistent pathp =p(x,ȳ) = {x =z 0 ,z 1 . . . ,ȳ} contained in the same equivalence class C of ∼ {x,ȳ} as p. We will show that p ⊂p. The set C \ {ē 1 , . . . ,ē Ar } is a disjoint union of equivalence classes It follows from the fact thatē 1 is the last vertex in the sequence of adjacent tox vertices contained in C and moreover by Lemma 2.2, all other vertices in this sequence contained in C belong to C 0 . We have eitherz 2 =ē 1 or, again by Lemma 2.2,z 2 ∈ C 0 . Eventually we getē 1 =z k ∈p ∩ p because we have to go out of C 0 in order to getȳ. Assumingz k =ē l we are able to show, by the same arguments as above, that e l+1 ∈p which shows that p ⊂p. Therefore p is a unique shortest consistent path betweenx andȳ contained in C. When computing the length of p we have to count steps betweenē 1 andē Ar whose number is A r − 1 and add one step betweenx andē 1 and another one betweenē Ar andȳ. We have finished the proof of 1. Now 2. and 3. immediately follows from 1. Definition 2. A Hamiltonian cycle p(x) containingx ∈ P(Z) is called consistent if there isȳ ∈ P(Z) such that p(x) is a union of two consistent paths connectingx andȳ.
Formally to run the transition algorithm we have to fix both verticesx andȳ. But actually we may fix onlyx and arbitrary finite sequences of positive integers (a n ) and (b m ) whose lengths differ by one. Then we may run the transition algorithm starting from the longer sequence. After using all numbers a n and b m we get two last corner verticesē Ar andf B l . Then let y be such that it forms a clique with these corner vertices andē Ar ∼ {x,ȳ}fB l . The above consideration gives the following.
Corollary 3.2. For everyx ∈ P(Z) and every positive integers d > 2, d a and d b with d = d a +d b there exists a Hamiltonian consistent cycle containinḡ x whose length is equal to d. Moreover there isȳ ∈ P(Z) such that In particular, G(P(Z), ) is of the infinite diameter.
Note that one can eliminateȳ from the cycle and get again a Hamiltonian one. In this way one is able to construct decreasing sequence of Hamiltonian cycles containingx that lengths decrease by one. Of course the shortest such a cycle has length 3 and form a clique. In the forthcoming paper it will be shown how to construct all such sequences of Hamiltonian cycles.

Non-consistent paths
While, as has been shown in the previous section, there are at most two shortest consistent paths between two vertices in the distant graph of projective line over Z, it turns out that in general you can find many shortest paths if we abandon the assumption of consistence.
In order to compute the length of a shortest path between two vertices x,ȳ ∈ P(Z) first run the transition algorithm described in Section 2 assuming the case (TR). Then it is convenient to consider the following path which exhaust all vertices of the corner path: depending on whether r = l or r = l + 1. Denote this path by p s (x,ȳ) and call it a standard path betweenx andȳ (see Fig. 2). Let us agree that the verticesē A k lie on the right side of the corner graph and the vertices off B k lie on its left side. The direct insight into the graph K(x,ȳ) gives the following result.
Lemma 4.1. The length of the standard path between not adjacentx andȳ is equal to r + l + 1 provided l > 0. If l = 0, then it is equal to 2.
The key observation of this section is the fact that if want to make a shortest walk fromx toȳ then we have to use only vertices of K(x,ȳ) but we may also use only vertices of K(x,ȳ).

Lemma 4.2. Every shortest path betweenx andȳ is a subgraph of K(x,ȳ).
Moreover among all the shortest paths at least one is a subgraph of K(x,ȳ).
Proof. We intend to show that having a pathp fromx toȳ one can find a path fromx toȳ contained in K(x,ȳ) which is not longer thanp.
Let thenz ∈p \ K(x,ȳ). We have eitherz ∼ {x,ȳ}ē1 orz ∼ {x,ȳ}f1 . Assuming the former case we can find precisely one k withz ∈ C k , where C k are taken from the proof of Theorem 3.1. By Lemma 2.1 all vertices adjacent toz belong to C k ∪ {ē k ,ē k+1 }. Therefore the predecessor as well as the successor ofz inp are contained in the same set, hence {ē k ,ē k+1 } ⊂p. Sinceē k ē k+1 , we may shortenp rejecting all vertices fromp ∩ C k . We argue analogically in the latter case.
Assume now thatp is one of the shortest paths betweenx andȳ. We already know thatp ⊂ K(x,ȳ). Let 1 ≤ m ≤ r and A m < k < A m+1 be such thatē k ∈p. In general we have alwaysē Am+1 ∈p since we can not omit e Am+1 ∈p walking fromē k toȳ. Walking fromx toē k we must go through f Bm orē Am sof Bm ∈p orē Am ∈p. Sincef Bm ē Am+1 andp is one of the shortest paths,f Bm ∈p andē A m+1 ∈p. We know thatē Am f Bm ē A m+1 is a path in K(x,ȳ) of the length 2, hence there are no other vertices between e Am andē A m+1 butē k . We may replaceē We analogically considerf k ∈p instead ofē k which ends the proof. Now let us ponder the question when the standard path is one of the shortest betweenx andȳ. Let   (a 1 , b 1 , . . .) = (c 1 , c 2 , . . . , c r+l ).
The first obvious case is c 2 = 0. Indeed, if c 2 = b 1 = 0 then l = 0 and x f 1 ȳ is the standard path of the length 2. If additionally c 1 = a 1 = 0 then r = 0 andx ē 1 ȳ is the other shortest path. If c 2 = 0 and c 1 = 0 then r = 1 and the standard path is the only shortest one. The other case is if all numbers c k , k = 1, . . . , r + l, are distinct from 0 (which is equivalent to c 2 = 0) and all but c 1 or c r+l are greater then 1. In such a situation no pairs (ē A k ,ē A k+1 ), k = 1, . . . , l − 1, (f B k ,f B k+1 ), k = 0, . . . , r − 2, are adjacent. It means that the shortest walk fromē We have shown the following. Note that even c 1 = 1 or c r+l = 1 the standard path remains one of the shortest ones. Indeed, if c 1 = a 1 = 1 thenē 1 ē 2 , hence there are two shortest paths fromx toē 2 , namelyx f 1 ē 2 andx ē 1 ē 2 . Similarly if c r+l−2 = b l−1 = 1 thenf B l−1 f B l ȳ andf B l−1 ē Ar ȳ are two shortest walks fromf B l−1 toȳ and if c r+l−2 = a r−1 = 1 thenē A r−1 ē Ar ȳ and e A r−1 f B l ȳ are two shortest walks fromē A r−1 toȳ. One can ask what is the necessary and sufficient condition for the Klein graph K(x,ȳ) that the standard path is the only shortest one. The above considerations immediately convince us that first of all we must have c 1 > 1 and c r+l > 1. We must also have c k > 1 for k = 2, . . . , r + l − 1 to assure that the standard path is one of the shortest ones. Assume now that c k = 2 for some k ∈ {2, . . . , r We have just shown that the necessary and sufficient condition is the following. Let us now consider a case when the standard path is not the shortest one. We already know that this is equivalent to c 2 = b 1 = 0 and c k = 1 for some k ∈ {2, . . . , r + l − 1}.
On the other hand, by Lemma 4.2, to compute the length of the shortest path betweenx andȳ it is enough to find the shortest one contained in the corner graph associated with those two vertices.
The considerations similar to those above allow us to give a recipe for finding one of the shortest paths in K(x,ȳ). First assume the following convention: walking along the standard path we say that we meet the number a k+1 or b k+1 if we are in the vertexē A k orf B k , respectively. Then the recipe is the following: start fromx and walk along the standard path until you meet the number one. Then walk along the consecutive vertices on the same side of the corner graph. Once you meet the number different from one you come back to the standard path. Perform this procedure till you reachē Ar orf B l . Then make one step more to end atȳ. In the sequel the path we have just described is called a standard shortest path.
To compute the distance betweenx andȳ it is left to determine by how many steps we shortened the standard path. For the first observe that if r = l then we never meet a 1 nor b l and if r = l + 1 then we never meet a 1 nor a r . Every other appearance of the number one in the "proper" place results in shortening of the standard path by precisely one step. It possible to shorten the standard path by one step in precisely two cases: 2. b k > 1 and a k = 1.
The first case always works. To decide whether 2. works or not we must check if it satisfies some additional condition. Put if r = l. If r = l + 1 the former condition remains unchanged and the latter one becomesb k = b k for k = 1, . . . , l. Now remove from {1, . . . , l} those k's that satisfy 2. with s k > t k and denote received set by D = Dx ,ȳ . By the above consideration we see that we shorten the standard path by steps. The symbol · stends for the floor function.
Theorem 4.5. Assume thatx,ȳ ∈ P(Z) are not adjacent. Then the length of the shortest path connectingx andȳ is equal to

Uniqueness of the shortest paths
In this section we formulate necessary and sufficient conditions for existence of more than one shortest path between two vertices. In the previous section we described the construction of one of the shortest paths between two not adjacent vertices. This path may split, but need not to, into more shortest paths because of appearance of 1 or 2 in the sequence (c 1 , . . . , c r+l ). Two next lemmas explain the situation. First we deal with ones. We say the two blocks of 1's overlap if there are natural numbers 0 ≤ l 1 ≤ l 2 ≤ l + 1 and 0 ≤ r 1 ≤ r 2 ≤ r + 1 satisfying (o1) l 1 < r 1 ≤ l 2 + 1 ≤ r 2 with l 2 < l + 1 iff r = l + 1 or (o2) l 1 < r 1 ≤ l 2 = r 2 = r + 1 = l + 1 or (o3) 0 = r 1 = l 1 ≤ l 2 < r 2 or (o4) r 1 ≤ l 1 ≤ r 2 ≤ l 2 , where l 1 = 0 with an additional condition r 2 < r + 1 iff r = l or (o5) r 1 ≤ l 1 ≤ l 2 < r 2 = r + 1.
Lemma 5.1. Appearance of 1 in the sequence (c 1 , . . . , c r+l ) results in splitting the shortest path iff two blocks of 1's overlap or r = l and c i = 1 for all i's.
Proof. First note that 1 in (c 1 , . . . , c r+l ) causes splitting of any path p contained in the Klein graph iff it appears in one of the following configurations depicted in Fig. 3:

Figure 3
In particular to split the shortest path 1 has to appear in both sides of the Klein graph. Then fix some block B of 1's in the left side of the Klein graph: b l 1 = . . . = b l 2 = 1, where 0 < l 1 ≤ l 2 < l. Then imagine that we "shift" some block A of 1's in the right side: a r 1 = . . . = a r 2 = 1, where 0 < r 1 ≤ r 2 < r. We want to assure that meeting of those two blocs results in splitting the shortest path.
Indeed, if neither of the above conditions holds then there are three possibilities. Two of them are l 2 + 1 < r 1 or l 1 > r 2 . In this cases neither (s1) nor (s2) holds. The last case is r 1 > l 1 and l 2 ≥ r 2 . This forces |A| < |B| and appearance of (s1) and (s2). Nevertheless this does not cause splitting because the standard shortest path has as a part the pathf B l 1 −1 f B l 1 . . . f B l 2 . Walking along this part we do not "jump" onto the right side of the Klein graph although we meet 1's in configuration (s1) and (s2). Therefore we are not able to gain splitting. Together with |A| ≤ |B| the former condition gives (o1) and the latter one gives (o4).
Together with |A| ≥ |B| the former condition gives (o1) and the latter one gives (o4). Until now we have assumed that our blocks neither start nor end atx andȳ. Now we assume that.
Next let r = l and r 2 = l 2 = r. Then in order to have splitting we must have l 1 < r 1 which is (o2). If l 2 = l = r = r 2 then r 2 < r which is equivalent to r 2 < r + 1. Moreover we must have r 1 ≤ l 1 ≤ r 2 . This gives the additional condition in (o4). If l 2 = l = r = r 2 then l 2 + 1 ≤ r 2 and we must have l 1 < r 1 ≤ l 2 + 1 which is (o1). Now assume that r = l + 1. First assume that r 2 < r. Then r 2 < r = l + 1 = l 2 and in order to guarantee splitting we must have r 1 ≤ l 1 ≤ r 2 . This gives (o4). If r 2 = r + 1 then to obtain splitting the standard shortest path has to end in the right side of the Klein graph. Therefore if r 1 ≤ l 1 then l 2 ≤ l + 1 < r 2 = l + 2 and we get (o5). On the other hand if r 1 > l 1 then we must have r 1 ≤ l 2 + 1 and we have to "jump" into the right side of the Klein graph which forces l 2 < l + 1. This is the additional condition in (o1).
There is left one case. Namely, c 1 = . . . = c r+l = 1. In this case it obvious that one has splitting iff r = l.
We have considered all possible configurations of two blocks of 1' that result in splitting. Since we get all conditions (o1)-(o5) and each of them obviously forces splitting, we have finished the proof.
Another reason of splitting is appearance of 2 in this sequence. By direct insight into the graph K(x,ȳ) we get the following result.  (st1) there exists k ∈ {2, . . . , l} such that b k = 2, a k > 1, a k+1 > 1 or b 1 = 2 and a 2 > 1.
(st2) there exists k ∈ {2, . . . , l} such that a k = 2, b k > 1 and s k ≤ t k , where the numbers s k and t k in the above are defined in (3) and (4).
Proof. Note that if b k = 2 then necessary and sufficient condition to split the standard shortest path is that it contains verticesf B k−1 ,f B k andē A k (see the left side of Fig. 4). The standard shortest path containsf B k−1 iff k > 1 and a k > 1 or k = 1 even if a 1 = 1. It necessarily containsē A k since b k = 2 > 1. The standard shortest path containsf B k iff a k+1 > 1. Now assume that a k = 2. Then necessary and sufficient condition to split the standard shortest path is appearance of verticesē A k−1 ,f B k−1 andē A k (see the right side of Fig. 4). The vertexē A 0 =ē 1 is never contained in the standard shortest path so k must be greater than 1. The vertexē A k−1 appears in it iff s k ≤ t k . This path necessarily containsf B k−1 since a k = 2 > 1. Then we see thatē A k appears in the standard shortest path iff b k > 1.
Observe that in the both cases k must be less then r + 1. This gives range of k in the thesis of the lemma.
All discussion of this section and direct insight into the Klein graph convince us that the following statement is true.