JOURNAL
OF COMBINATORIAL
B 34, 165-176 (1983)
THEORY,!&T~~S
Existence of Graphs with a Given Set of r-Neighborhoods M.
PETER Department
WINKLER
of Mathematics and Computer Emory University, Atlanta, Georgia 30322 Communicated Received
Science,
by the Editors
September 14, 1981
The problem of whether there exists a graph satisfying a particular set of local constraints can often be reduced to questions of the following sort: given a finite collection @ of graphs, is there a graph G such that the set of r-neighborhoods of the vertices of G is precisely @? It is shown that, although such a question is in general recursively unsolvable, it becomes solvable when a bound on cycle length is imposed on G, even when G is required to be connected or arbitrarily large. This result is used to demonstrate the solvability of a problem from hypergraph theory involving degree sets of k-trees.
1.
INTR~OUCTI~N
Let u and u be two vertices in the same connected component of a graph G; the distance p(u, V) between u and u is defined to be the number of edges in a shortest path from u to u. The r-neighborhood N,(v) of u is the subgraph induced by the set of vertices of distance at most r from u. N,.(v) is regarded as a rooted graph with root (i.e., distinguished vertex) u. The r-neighborhood set ,4:(G) of a graph G is the set of isomorphism classes of r-neighborhoods of vertices in G. Often the question of whether there exists a graph with particular “local” properties can be reduced to a finite set of questions of the following form: given a finite set @ of rooted graphs, is there a graph G whose r-neighborhood set is @? Unfortunately these questions are in general recursively unanswerable, as we shall demonstrate; but if a bound is imposed on the maximum cycle length allowed in G, the situation changes. We provide an algorithm which, given integers r and c and a finite set @ of rooted graphs, will determine in a finite number of steps whether there exists a connected graph G satisfying ,&i(G) = @ and having no cycles of length greater than c. Different versions of the algorithm answer the same question with the word “connected” omitted or supplemented by “arbitrarily large.” 165 0095-8956/83 $3.00 Copyright 0 1983 by Academic Press, Inc. All rights of reproduction in any form reserved.
166
PETER M.WINKLER
The algorithms remain effective when the graphs involved are adorned in various ways, i.e., with loops, multiple edges, colored vertices, colored or directed edges,etc.; however, all graphs are assumedthroughout to befinite. The colored+dge version is applied to a problem in hypergraph theory.
2. SHADOWS AND TRANSPLANTS Let G be a connected graph with no cycles of length greater than c, and let u and x be vertices of G. The shadow S(u, x) of u from x is the subgraph of G induced by the set of all vertices z such that some minimal-length path from z to x passesthrough u. S(U, x) is regarded as a rooted graph with root U. For a nonnegative integer n, S,,(U, x) is the n-neighborhood of u in S(u, x). (See Fig. 1.) The first lemma shows that the cycle condition forces all connections between a shadow and the rest of the graph to be near the tip of the shadow. LEMMA 1. Let (w, z} be an edge of G, where z is a vertex of S(u, x) but w is not. Then z E S&u, x).
Proof: Let P,, P, and P, be minimal-length paths from z to u, u to x, and x to w, respectively. It follows from the definition of shadow that P, is contained in S(u, x), P, meets S(u, x) only at u, and P, is disjoint from S(u, x); thus if P is the closed path formed by P, , P,, P, and the edge (w, z}, then the cycle in P which contains {w, z) also contains all of P, . (See Fig. 2.) If pi is the length of P, , then the length of this cycle must be at least 1 + 2p,, else there is a shorter path than P, UP, from z to x. Hence 2p, < c and the lemma follows. I
FIGURE
1
GRAPHS
WITH
GIVEN
FIGURE
r-NEIGHBORHOODS
167
2
The primary tool in what follows is the transplant operation, in which one shadow in a graph is replaced by another. As before let G be a connected graph with no cycles of length greater than c, and let r > 0. Let U, v, x, and J’ be vertices of G having the property that S,(u, x) is isomorphic to S,(U, y), where q = max(c, 2r + [c/2]); I‘f z is a vertex in S,(u, x) we denote its image in S,(u, y) under the isomorphism by Q(z). Let S’ be an isomorphic copy of S(u, x); the vertex in S’ corresponding to a vertex z in S(u, x) will be called I Z. The transplant graph G(u, x; v, y) is defined as follows: let G’ be the disjoint union of S’ and the subgraph of G induced by the vertices of G which are not in S(v, y); G( U, x; u, y) is obtained from G’ by adding all edges (w, z’}, where w is a vertex of G’ not in S’, and the edge (w, 4(z)} is in G. Thus S’ is joined to the rest of G(u, x; U, y) in the same manner that S(v, y) was joined to the rest of G. The transplant operation is illustrated in Fig. 3 in the case where S(U, x) and S(U, y) are disjoint. LEMMA
2.
G(u, x; v, y) has no cycles of length greater than c.
FIGURE
3
168
PETER M. WINKLER
ProoJ If C were such a cycle, it would have to contain both a vertex w in G’ - S’ and a vertex z’, where z E S(u, x) - S&u, x), else C would already have existed in G. Let C’ be the image of C n S’ in S(U, x), and let P be the component of C’ which contains z. By Lemma 1, the endpoints z, , z2 of P lie in S,,,,,( u, x); by adjoining to P minimal-length paths from z1 to u and from u to z2, a closed path P’ is created. The cycle of P’ containing z has two segments leading from z to a point in Stc12,(u, x), each necessarily of length greater than q - [c/2]; since q > c, this cycle has length greater than c and cannot have existed in G. I LEMMA 3. The r-neighborhood set of G(u, x; v, y) is contained in the rneighborhood set of G.
Proof: Let w be a vertex of G(u, x; v, y); we must show that there is a vertex z of G such that N,.(z) is isomorphic to N,(w). First suppose w E G’ - S’; although the r-neighborhood of w may intersect S’, any vertex in S’ n N,(w) must lie within distance r + [c/2] of U’ in view of Lemma 1. But q > r + [c/2] and the q-neighborhood of U’ in S’ is isomorphic to S&v, y), so w had the same r-neighborhood in G and we can take z = W. Next suppose w E S’ and p(w, u’) < q - r; here we take z to be the vertex in S&v, y) corresponding to W. Again N,(z) n S(v, y) c S,(v, y), so N,.(z) N,(w). Lastly, suppose w E S’ and p(w, u’) > q - r; let z be the vertex of S(u, x) corresponding to w. Since q - r > r + [c/2], Lemma 1 implies that the rneighborhood of z in G lies completely in S(u, x); thus N,(z) - N,.(w) as required. I
Lemma 4 is an immediate
consequence of the foregoing proof:
LEMMA 4. Zf N E Lh;(G) -L +;(G(u, x; v, y)), then every vertex z in G for which N,(z) - N lies in S(v, y) - S(u, x).
3. THE MAIN THEOREMS
Henceforth let r, c, and @ be fixed, where @ is a set of n rooted graphs. Let d be the largest number occurring as the degree of a root of an element of @, and let q = max(c, 2r + [c/2]) as above. Let g(q, d) be the number of nonisomorphic rooted graphs having radius at most q, and having no vertex of degree greater than d. LEMMA 5. Let G be a connected graph of minimal order (number of vertices) such that ,4(G) = CDand G has no cycles of length greater than c. Then the diameter of G is at most (n + 2) g(q, d).
GRAPHS WITH GIVEN T-NEIGHBORHOODS
169
Proof. Assume otherwise and let P be a minimal-length path in G through vertices v,,, u , ,..., U, from u,, to a,, where t > (n + 2) g(q, d). Then there must be a sequence i(1) < i(2) < ..a < i(n + 2) such that the graphs Sq(uiU), UJ are all isomorphic, for 1
there must be some j, 1
no v(N) is a vertex in we infer that G(viU,, L’(,; since G(viU,, uO; uici- ,), the cycle restriction, its
Finally: THEOREM 1. There is an algorithm which, given r, c, and #, will determine in a finite number of steps whether there exists a connected graph G, having no cycles of length greater than c, whoser-neighborhood set is @.
Proof.
construct maximum restriction is found,
Proceed as follows: determine n, d, and q; compute g(q, d); now every connected graph G of diameter at most (n + 2) g(q, d) and degree at most d, looking for one which satisfies the cycle and has the desired r-neighborhood set. By Lemma 5, if no such G then the existence question is answered in the negative. 1
Henceforth, for convenience, a graph that has r-neighborhood set @ and no cycles of length greater than c will be called a (c, r)-realization of @.The word “effectively” in succeeding theorems is used in the logical sense, that is, to mean “by a deterministic algorithm in finitely many steps.” The number of steps required for the procedure above is exponential in n, r, c, and d. THEOREM 2. The question of whether there exists a finite (but not necessarily connected) (c, r)-realization of @ can be eflectively answered.
Proof: If there subset of @. The which subsets of determine whether
is such a graph, then each of its components realizes a algorithm of the previous theorem is used to determine @ have connected (c, r)-realizations; it remains only to the union of those subsets is all of @. I
We can always take unions of disjoint copies to make larger (c, r)realizations, but there may not be arbitrarily large connected realizations; fortunately we can tell when this is the case. THEOREM 3. The question of whether there are arbitrarily connected (c, r)-realizations of @ is eflectively answerable.
large
170
PETER M.WINKLER
Proof: We claim that the answer is in the affirmative if and only if there is a connected (c, r)-realization whose diameter lies between (n + 2) g(q, d) + 1 and 2(n + 2) g(q, d). For, let G be such a realization; as in the proof of Lemma 5, we can find vertices U, u, and x in G such that S(U, x) 1 S(V, x) and S,(u, x) - S&v, x). This time, however, we reverse the transplant; let G, = G(u, x; u, x). Then G, is a connected (c, r)-realization of @ which is larger than G; moreover G, contains copies U’ and v’ of u and u which can be used to iterate the construction, producing arbitrarily large connected realizations. Conversely, assumethat arbitrarily large connected realizations exist and let G be one whose diameter is larger than 2(n + 2) g(q, d). Let P' be a minimal-length path connecting two vertices x and y of maximal distance, and let vObe a vertex in P' halfway between x and y. Let P be the part of P' from v,, to ut =x, and repeat the construction in the proof of Lemma 5; the resulting graph will be smaller than G but will still contain the rest of P', thus its diameter is more than half the diameter of G. Repeating this procedure must eventually lead to a connected realization whose diameter is in the above range. 1 4.
SOME OBSERVATIONS
AND AN APPLICATION
It was remarked in the introduction that these theorems apply also when the graphs involved have colored vertices or edges, multiple edges, directed edges, and so forth; in fact, the only thing which changes in the proofs is the value of g(q, d). Note, however, that some care is neededin stating the cycle restriction. In the case of multiple edges, a “cycle” must still pass through distinct vertices as well as distinct edges; on the other hand, when directed edges are involved, a “cycle” must not be required to have consistently directed edges. In theory any application involving coloring could be coded into one to which the theorems are directly applicable, but such codings are likely to be cumbersome and unnatural. A chemist, for example, might wish to know whether there could exist a molecule in which all of the local configurations were of certain specified types; it might be natural in this situation to regard atoms as colored vertices and chemical bonds as colored edges in a connected graph. Perhaps more important than the extension to colored graphs is the observation that the members of @ need not represent neighborhoods of uniform radius. Suppose,for instance, that a collection @ of connected rooted graphs is given, and a graph G is required in which every vertex is contained in some subgraph isomorphic to a member of @. As long as somebound on the degrees of vertices in G is provided or implicit, the graphs in @ can be
GRAPHS
WITH
GIVEN
171
r-NEIGHBORHOODS
extended in every possible way to r-neighborhoods for suitably chosen r and the question thereby reduced to a series of questions of the form we have considered. We now consider a problem from the theory of hypergraphs. A k-uniform hypergruph is a finite set of points together with a collection of k-point subsets, called blocks. (We use the terms “point” and “block” to avoid confusion with the vertices and edges of ordinary graphs.) A set of k - 1 points which is a subset of a block is called a face. The class of k-trees is defined inductively as follows: the k-uniform hypergraph consisting of k points and a single block is a k-tree; if T is a ktree, then the result of adding to T one new point, and a new block containing that point and some face of a block in T, is again a k-tree. A 2tree is thus an ordinary tree from graph theory. Caution: what we call k-trees have been called (k - 1)trees in [ 1, 61, and (k - 2, k - 1)-trees in [2]; our “blocks” have been called both “edges” and “simplexes.” By the degree of a point in a hypergraph we mean the number of blocks which contain it; the degree set of a hypergraph is the set of numbers which occur as degrees of points in the hypergraph. The problem of characterizing the sets of numbers which can be realized as the degree set of a k-tree is studied in [3-51; we show below, using the characterization in [S], that the problem is recursively solvable. From any k-tree T a k-tree graph G(7) can be obtained in the following way: the points of T are colored with k colors in such a way that every block contains points of every color; a vertex u(B) in G(T) is created for each block B of T, an edge {v(A), v(B)} is created whenever the blocks A and B share a face, and that edge is colored with the unique color not found in the shared face. It turns out that G(T) is uniquely determined by T up to
1 2
c 1
1
2
3 1
1
1
1
2
3
3
3
2
3
t
2 FIGURE
4
172
PETER MWINKLER
permutation of the colors. Figure 4 shows a colored 3-tree (with blocks represented by triangles and colors by numbers) together with its 3-tree graph. In [8] the following facts are established, for any positive integer d: (1) It can effectively be decided whether a rooted, edge-colored graph N belongs to the set 9 of d-neighborhoods of vertices of k-tree graphs of ktrees which have no points of degree greater than d. (2) If the degree of a point p in a block B of a k-tree T is not greater than d, then the degree of p is determined by the d-neighborhood of v(B) in G(T). (3) A graph G is the k-tree graph of a k-tree whose maximum degree is at most d if and only if: (a) G is connected; (b) G is edge-colored by at most k colors; (c) the d-neighborhood set of G is contained in 9; and (d) G has no cycles of length greater than d. From this we may obtain 4. There is an algorithm which, given k and a fmite set D of positive integers, will determine in finitely many steps whether there is a ktree whosedegree set is D. THEOREM
Proof: Each NE .R is itself the k-tree graph of some k-tree; let B be the block such that v(B) is the root of N, and let D(N) be the set of degrees of points in B. Let @i, Gz ,..., CD,,,be an enumeration of all the subsets of .R having the property that u {D(N): NE Qi} = D;
for each Qi, apply Theorem 1 to decide whether there is a connected (d, d)realization of Qi. The desired k-tree exists if and only if one of these applications results in a success. I 5. COUNTEREXAMPLE
We show in this section that the cycle restriction cannot be removed from the statement of Theorem 1 (or Theorem 2). THEOREM
5.
The problem of determining, from a given number r and a given j?nite set @ of rooted graphs, whether there exists a connected graph whose r-neighborhood set is Qi, is recursively unsolvable. Proof.
We assume otherwise and show that in that case, there would be
GRAPHS
WITH
GIVEN
173
T-NEIGHBORHOODS
an algorithm for solving the classical “Post correspondence problem”which is known to be recursively unsolvable [7]. Let S be the set of finite strings of a’s and b’s; if s, , s, E S, we denote the concatenation of s, and s2 by s,s,. A Post correspondence system (PCS) is a finite set Q = {(s,, s;), (~2, s;),..., (snr s:)} of pairs of elements of S. A solution of Q consists of a number k and a sequence i(l), i(2),..., i(k) such that
The Post correspondence problem for Q is to determine whether Q has a solution; in general, however, assuming the correctness of Church’s thesis (every effective algorithm is recursive), there is no algorithm which can solve the post correspondence problem in finitely many steps for any given PCS. Now let Q be an arbitrary but fixed PCS. We associate with Q a set of local conditions on a graph with colored and directed edges, in such a way that each connected graph satisfying the conditions corresponds to a solution of Q. The conditions will be expressed informally, but it should be clear that they can be transformed into a collection of potential r-neighborhood sets for suitable r. Thus, a series of applications of Theorem l-minus the cycle restriction-would solve the Post correspondence problem for Q, contradicting Post’s result. The available edge-colors will be the symbols a, a’, 6, b’, c, and d. The first condition is that every vertex must correspond to a circled vertex in an induced subgraph isomorphic to one in Fig. 5. Each dotted edge may be present or absent, and we allow the possibility that an upper dotted arrow and a lower one may be parts of the same edge. However, no unpictured
c
c
b’ J----+
FIGURE
5
174
PETER
M. WINKLER
FIGURE
6
edge may be incident to any vertex in the diagram. The unlabelled solid edges may have any color, although the condition in fact forces their colors to be a, a’, b or b’ in matched pairs. The second condition requires that in addition, every vertex correspond to one of the circled vertices in an induced subgraph isomorphic to that in Fig. 6, where the string pair (x,x, . . . xi, y, y, . . - yj) ranges over the members of Q. Here again a vertical arrow at the top of the diagram and another at the bottom may represent the same edge. The third and last condition is that the subgraph in Fig. 7 occurs at least once. The construction of a graph satisfying these conditions from a solution to Q is best seen by example. Let Q = {(a, au), (aba, b)}; then 1, 2, 1 is a solution to Q, since s, s,s, = aabaa = s; s; s{ . The graph corresponding to this solution is shown in Fig. 8. Conversely, let G be a connected graph satisfying the conditions and let u and U’ be the upper and lower vertices, respectively, of a subgraph
FIGURE
7
GRAPHS
WITH
GIVEN
t--NEIGHBORHOODS
17.5
b
FIGURE 8
isomorphic to the graph depicted in Fig. 7; then there is an {a, b)-colored directed cycle through u and an {a’, b’ }-colored directed cycle through u’. Ignoring the primes, each cycle spells out a string in S; the c-colored links between the cycles guarantee that the two strings are identical, and the dcolored links mark the division of the pair of strings into pairs from Q. 1 Note that even if G is not connected, any component containing a copy of the graph in Fig. 7 satisfies all the required conditions, and thus still yields a solution to Q. It follows that the cycle restriction is necessary also for Theorem 2. It may also be worth remarking that a necessary factor in the unsolvability of the Post correspondence problem is the fact that in writing a solution to Q, one string may have to get unpredictably far ahead of the other before they can be “evened up.” This results in unpredicably large cycles in the corresponding graph, of the sort which consist of a segmentof P or of P’, one c-colored edge and one d-colored edge. These cycles are, in some sense, the “crucial” cycles whose lengths cannot be bounded in advance.
REFERENCES
I. L. W. BEINEKE AND R. E. PIPPERT, Properties and characterizations of k-trees. Mathematika 18 (1971). 141-151. 2. A. K. DEWDNEY, Higher dimensional tree structures, J. Combin. Theory Ser. B 17 (1974). 160-164.
176
PETER M. WINKLER
3. R. A. DUKE AND P. M. WINKLE& Degree sets of k-trees: Small degrees. Ufilitas Math., in press. 4. R. A. DUKE AND P. M. WINKLER. Degree sets of k-trees: Small k, Israel J. Math. 40 (3-4) ( 198 I), 296-306. 5. R. A. DUKE AND P. M. WINKLER, Realizability of almost all degree sets by k-trees. Gong. Numer. 35 (1982), 261-273. 6. F. HARARY AND E. M. PALMER, On acyclic simplicial complexes. Mathemafika 15 (1968). 155-162. 7. E. L. POST. A variant of a recursively unsolvable problem. Bull. Amer. Math. Sot. 52 ( 1946), 264-268. 8. P. M. WINKLER. Graphic characterization of k-trees. C&g. Numer. 33 (1981). 349-357.