Deterministic Graph Exploration with Advice

We consider the task of graph exploration. An $n$-node graph has unlabeled nodes, and all ports at any node of degree $d$ are arbitrarily numbered $0,\dots, d-1$. A mobile agent has to visit all nodes and stop. The exploration time is the number of edge traversals. We consider the problem of how much knowledge the agent has to have a priori, in order to explore the graph in a given time, using a deterministic algorithm. This a priori information (advice) is provided to the agent by an oracle, in the form of a binary string, whose length is called the size of advice. We consider two types of oracles. The instance oracle knows the entire instance of the exploration problem, i.e., the port-numbered map of the graph and the starting node of the agent in this map. The map oracle knows the port-numbered map of the graph but does not know the starting node of the agent. We first consider exploration in polynomial time, and determine the exact minimum size of advice to achieve it. This size is $\log\log\log n -\Theta(1)$, for both types of oracles. When advice is large, there are two natural time thresholds: $\Theta(n^2)$ for a map oracle, and $\Theta(n)$ for an instance oracle, that can be achieved with sufficiently large advice. We show that, with a map oracle, time $\Theta(n^2)$ cannot be improved in general, regardless of the size of advice. We also show that the smallest size of advice to achieve this time is larger than $n^\delta$, for any $\delta<1/3$. For an instance oracle, advice of size $O(n\log n)$ is enough to achieve time $O(n)$. We show that, with any advice of size $o(n\log n)$, the time of exploration must be at least $n^\epsilon$, for any $\epsilon<2$, and with any advice of size $O(n)$, the time must be $\Omega(n^2)$. We also investigate minimum advice sufficient for fast exploration of hamiltonian graphs.


Introduction
Exploration of networks by visiting all of their nodes is one of the basic tasks performed by a mobile agent in networks. In applications, a software agent may need to collect data placed at nodes of a network, or a mobile robot may need to collect samples of air or ground in a contaminated mine whose corridors form links of a network, with corridor crossings represented by nodes.
The network is modeled as a simple connected undirected graph G = (V, E) with n nodes, called graph in the sequel. Nodes are unlabeled, and all ports at any node of degree d are arbitrarily numbered 0, . . . , d − 1. The agent is initially situated at a starting node v of the graph. When the agent located at a current node u gets to a neighbor w of u by taking port i, it learns the port j by which it enters node w and it learns the degree of w. The agent has to visit all nodes of the graph and stop.
The time of the exploration is the number of edge traversals. We consider the problem of how much knowledge the agent has to have a priori, in order to explore the graph in a given time, using a deterministic algorithm. It is well-known that some information is necessary, as witnessed even by the class of rings in which ports at all nodes are numbered 0,1 in clockwise order. Navigating in such a ring, the agent cannot learn its size. If there existed an exploration algorithm not using any a priori knowledge, then it would have to stop after some t steps in every ring, and hence would fail to explore a (t + 2)-node ring.
Following the paradigm of algorithms with advice [1,13,17,18,19,20,21,23,24,25,27,28,29], this a priori information (advice), needed for exploration, is provided to the agent by an oracle, in the form of a binary string, whose length is called the size of advice. We consider two types of oracles. An instance oracle knows the entire instance of the exploration problem, i.e., the portnumbered map of the graph and the starting node of the agent in this map. A map oracle knows the port-numbered map of the graph but does not know the starting node of the agent. Formally, a map oracle is a function f : G −→ S, where G is the set of graphs and S is the set of finite binary strings. An instance oracle is a function f : I −→ S, where I is the set of couples (G, v), with G ∈ G and v being the starting node of the agent in graph G. The advice s is an input to an exploration algorithm. We say that exploration in time t with advice of size x given by an instance oracle is possible, if there exists advice of length x depending on the instance (G, v), and an exploration algorithm using this advice, which explores every graph in time t, starting from node v. Likewise, we say that exploration in time t with advice of size x given by a map oracle is possible, if there exists advice of length x depending on the graph G, and an exploration algorithm using this advice, which explores every graph in time t, starting from any node. (Integers x and t depend on the size of the graph.) Proving that such an exploration is possible consists in showing an oracle of the appropriate type giving advice of size x, and an exploration algorithm using this advice and working in time t, for any graph and any starting node. Proving that such an exploration is impossible consists in showing that, for any oracle of the appropriate type giving advice of size x, and for any exploration algorithm using it, there exists a graph and a starting node for which this algorithm will exceed time t.
The central question studied in this paper is: What is the minimum size of advice that has to be given to the agent by an instance oracle (resp. by a map oracle) to permit the agent to explore any graph in a given time?
Our main contribution are negative results of two types: • impossibility results showing that the less powerful map oracle cannot help to achieve the same exploration time as the more powerful instance oracle, regardless of the size of advice; • lower bounds showing that the size of some natural advice leading to a simple exploration in a given time cannot be improved significantly.
While in most cases our bounds on the size of advice are asymptotically tight, in one case the remaining gap is cubic.

Our results
We first consider exploration in polynomial time, and determine the exact minimum size of advice to achieve it. Indeed, we prove that some advice of size log log log n − c, for any constant c, is sufficient to permit polynomial exploration of all n-node graphs, and that no advice of size log log log n−φ(n), where φ is any function diverging to infinity, can help to do this. Both these results hold both for the instance and for the map oracles.
On the other side of the spectrum, when advice is large, there are two natural time thresholds: Θ(n 2 ) for a map oracle, and Θ(n) for an instance oracle. This is because, in both cases, these time benchmarks can be achieved with sufficiently large advice (advice of size O(n log n) suffices). We show that, with a map oracle, time Θ(n 2 ) cannot be improved in general, regardless of the size of advice. What is then the smallest advice to achieve time Θ(n 2 ) with a map oracle? We show that this smallest size of advice is larger than n δ , for any δ < 1/3.
For large advice, the situation changes significantly when we allow an instance oracle instead of a map oracle. In this case, advice of size O(n log n) is enough to achieve time O(n). Is such a large advice needed to achieve linear time? We answer this question affirmatively. Indeed, we show more: with any advice of size o(n log n), the time of exploration must be at least n , for any < 2, and with any advice of size O(n), the time must be Ω(n 2 ).
We finally look at hamiltonian graphs, as for them it is possible to achieve the absolutely optimal exploration time n − 1, when sufficiently large advice (of size O(n log n)) is given by an instance oracle. We show that a map oracle cannot achieve this: regardless of the size of advice, the time of exploration must be Ω(n 2 ), for some hamiltonian graphs. On the other hand, even for an instance oracle, with advice of size o(n log n), optimal time n − 1 cannot be achieved: indeed, we show that the time of exploration with such advice must sometimes exceed the optimal time n − 1 by a summand n , for any < 1.
Our results permit to compare advice of different size and of different quality. The size is defined formally, and for quality we may say that advice given by an instance oracle is superior to advice given by a map oracle, because an instance oracle, seeing not only the graph but also the starting node of the agent, can use the allowed bits of advice in a better way. Looking from this perspective it turns out that both size and quality of advice provably matter. The fact that quality of advice matters is proved by the following pair of results: for a map oracle, time Θ(n 2 ) cannot be beaten, regardless of the size of advice, while for an instance oracle time O(n) can be achieved with O(n log n) bits of advice. The fact that the size of advice matters (with the same quality) is proved by the following pair of results: for an instance oracle, time O(n) can be achieved with O(n log n) bits of advice, but with o(n log n) bits of advice time must be at least n , for any < 2.

Related work
The problem of exploration and navigation of mobile agents in an unknown environment has been extensively studied in the literature for many decades (cf. the survey [33]). The explored environment has been modeled in two distinct ways: either as a geometric terrain in the plane, e.g., an unknown terrain with convex obstacles [9], or a room with polygonal [12] or rectangular [5] obstacles, or as we do in this paper, i.e., as a graph, assuming that the agent may only move along its edges. The graph model can be further specified in two different ways: either the graph is directed, in which case the agent can move only from tail to head of a directed edge [2,6,7,13], or the graph is undirected (as we assume) and the agent can traverse edges in both directions [4,8,16,30,31]. The efficiency measure adopted in most papers dealing with exploration of graphs is the time (or cost) of completing this task, measured by the number of edge traversals by the agent. Some authors impose further restrictions on the moves of the agent. It is assumed that the agent has either a restricted tank [4,8], and thus has to periodically return to the base for refueling, or that it is attached to the base by a rope or cable of restricted length [16].
Another direction of research concerns exploration of anonymous graphs. In this case it is impossible to explore arbitrary graphs and stop after exploration, if no marking of nodes is allowed, and if nothing is known about the graph. Hence some authors [6,7] allow pebbles which the agent can drop on nodes to recognize already visited ones, and then remove them and drop them in other places. A more restrictive scenario assumes a stationary token that is fixed at the starting node of the agent [11,32]. Exploring anonymous graphs without the possibility of marking nodes (and thus possibly without stopping) is investigated, e.g., in [14,22]. The authors concentrate attention not on the cost of exploration but on the minimum amount of memory sufficient to carry out this task.
In the absence of marking nodes, in order to guarantee stopping after exploration, some knowledge about the graph is required, e.g., an upper bound on its size [11,34].
Providing nodes or agents with arbitrary kinds of information that can be used to perform network tasks more efficiently has been previously proposed in [1,13,17,18,19,20,21,23,24,25,27,28,29] in contexts ranging from graph coloring to broadcasting and leader election. This approach was referred to as algorithms with advice. The advice is given either to nodes of the network or to mobile agents performing some network task. In the first case, instead of advice, the term informative labeling schemes is sometimes used, if different nodes can get different information.
Several authors studied the minimum size of advice required to solve network problems in an efficient way. In [28], given a distributed representation of a solution for a problem, the authors investigated the number of bits of communication needed to verify the legality of the represented solution. In [19], the authors compared the minimum size of advice required to solve two information dissemination problems using a linear number of messages. In [21], it was shown that advice of constant size given to the nodes enables the distributed construction of a minimum spanning tree in logarithmic time. In [17], the advice paradigm was used for online problems. In [18], the authors established lower bounds on the size of advice needed to beat time Θ(log * n) for 3-coloring cycles and to achieve time Θ(log * n) for 3-coloring unoriented trees. In the case of [29], the issue was not efficiency but feasibility: it was shown that Θ(n log n) is the minimum size of advice required to perform monotone connected graph clearing. In [27], the authors studied radio networks for which it is possible to perform centralized broadcasting in constant time. They proved that constant time is achievable with O(n) bits of advice in such networks, while o(n) bits are not enough. In [24], the authors studied the problem of topology recognition with advice given to nodes. The topic of [26] and [15] was the size of advice needed for fast leader election, resp. in anonymous trees and in arbitrary anonymous graphs. Exploration with advice was previously studied only for trees [20], and algorithm performance was measured using the competitive approach. In the present paper, the performance measure of an algorithm is the order of magnitude of exploration time, and hence the case of trees is trivial, as they can be explored in linear time without any advice.

Exploration in polynomial time
As a warm-up, we first consider the following question: What is the minimum size of advice permitting the agent to explore any graph in time polynomial in the size of the graph? In this section we give the exact answer to this question, both for the instance oracle and for the map oracle.
It is well-known that, if the agent knows an upper bound n on the number n of nodes of the graph, then exploration in time polynomial in n is possible, starting from any node of the graph. The first result implying this fact was proved in [3]. The exploration proposed there works in time O(n 5 log n ), and is based on Universal Traversal Sequences (UTS). Later on, an exploration algorithm working in time polynomial in n based on Universal Exploration Sequences (UXS) was established in [34]. While the polynomial in the latter paper has much higher degree, the solution from [34] can be carried out in logarithmic memory. Both UTS and UXS permit to find a sequence of port numbers to be followed by the agent, regardless of the topology of the graph and of its starting node. In the case of UTS, the sequence of port numbers to be followed is the UTS itself, and in the case of UXS it is constructed term by term, on the basis of the UXS and of the port number by which the agent entered the current node. Regardless of which solution is used, we have the following proposition: [3,34] If the agent knows an upper bound n on the number n of nodes of the graph, there exists an algorithm with input n that permits the agent starting at any node of the graph to explore the graph and stop after P (n ) steps, where P is some polynomial.
The positive part of our result on minimum advice is formulated in the following lemma. Its proof is based on Proposition 2.1. The advice given to the agent is some prefix of the binary representation of the number log log n , on the basis of which the agent computes a rough but sufficiently precise upper bound on the size of the graph which permits it to explore the graph, in time polynomial in its size.

Lemma 2.1
For any positive constant c, there exists an exploration algorithm using advice of size log log log n − c , that works in time polynomial in n, for any n-node graph.
Proof. Let A be an algorithm and let P be a polynomial such that, if the agent knows an upper bound n of the number n of nodes of a graph G, then it can explore G in time P (n ), starting from any node, using algorithm A with input n . Without loss of generality suppose P (m) = m a for some constant a ∈ N. We will show that there exists a binary string s of length log log log n − c such that if s is given to the agent as advice, the agent can explore all nodes of G in time polynomial in n. To show the existence of such a string s, let X be the binary representation of log log n . Let s be the string obtained from X by deleting the last c + 1 bits of X. The length of s is at most log log log n − c . This string s is given to the agent as the advice.
Let s 1 be string resulting from s by adding (c + 1) 1's at the end of s. Let n 1 be the integer whose binary representation is s 1 . Let N = 2 2 n 1 +1 . By definition, we have n 1 ≥ log log n . Hence, n 1 + 1 ≥ log log n, and thus N ≥ n.
After receiving the string s, the agent computes the integer N and performs algorithm A with input N . Since N ≥ n, the agent correctly explores the graph in time P (N ).
To prove that the exploration time is polynomial in n, let s 0 be the string which is obtained from s by adding c + 1 0's at the end of s. Let n 0 be the integer whose binary representation is s 0 . We have n 1 = n 0 + (2 c+1 − 1). Therefore, Let m = 2 2 n 0 . Then m ≤ n ≤ m 2 c+1 . Also, P (n) ≥ P (m). Hence, the time taken by the agent is at most The next result shows that the upper bound from the previous lemma is tight. Indeed, the following lower bound holds even for oriented rings, i.e., rings in which ports 0 and 1 are in clockwise order at every node.
Lemma 2.2 For any function φ : N → N such that φ(n) → ∞ as n → ∞, it is not possible to explore an n-node oriented ring in polynomial time, using advice of size at most log log log n − φ(n).
Proof. The proof is by contradiction. Suppose that there exists an algorithm Ring, permitting the agent to explore an n-node oriented ring with at most log log log n − φ(n) bits of advice, in time f (n), where f is a polynomial. Without loss of generality assume that f (n) = n a − 2 for some constant a ∈ N. Since φ diverges to infinity, there exists some n 0 ∈ N such that 2 φ(n)−2 > log a, for all n ≥ n 0 . There are at most log log n 2 φ(n)−2 binary strings of length at most log log log n − φ(n) . Define Take a family of ( log log n 2 φ(n)−2 + 1) oriented rings C t i with t i nodes, for 0 ≤ i ≤ log log n 2 φ(n)−2 , where t i = n (log n) iz and n ≥ n 0 . By the pigeonhole principle, there exist indices i, j such that C t i and C t j must have the same advice string, with t i < t j . The correctness of Ring implies that the agent explores all the nodes of C t i and stops after f (t i ) steps. Since the agent has the same advice for C t j , it also stops after f (t i ) steps in C t j .
. This implies that the agent stops after fewer than t j − 1 steps in C t j , but it is not possible to explore C t j in fewer than t j − 1 steps, which is a contradiction. Therefore, there does not exist any algorithm that can explore an n-node oriented ring with advice of size at most log log log n − φ(n). 2 Notice that Lemmas 2.1 and 2.2 hold both for the instance oracle and for the map oracle. The positive result from Lemma 2.1 holds even for the map oracle, as the advice concerns the size of the graph and does not require knowing the starting node of the agent. The negative result from Lemma 2.2 holds even for the instance oracle, as it is true even in oriented rings, where knowledge of the starting node does not provide any insight, since all nodes look the same. Hence Lemmas 2.1 and 2.2 imply the following theorem that gives a precise answer to the question stated at the beginning of this section.
Theorem 2.1 The minimum size of advice permitting the agent to explore any graph in time polynomial in the size n of the graph is log log log n − Θ(1), both for the instance oracle and for the map oracle.

Fast exploration
When advice given to the agent can be large, there are two natural time thresholds: Θ(n 2 ) for a map oracle, and Θ(n) for an instance oracle. This is because, in both cases, these time benchmarks can be achieved with sufficiently large advice. Indeed, we have the following proposition.
Proposition 3.1 1. There exists an exploration algorithm, working in time O(n 2 ) and using advice of size O(n log n), provided by a map oracle, for n-node graphs.
2. There exists an exploration algorithm, working in time O(n) and using advice of size O(n log n), provided by an instance oracle, for n-node graphs.
Proof. In order to guarantee exploration time O(n 2 ), it is enough to provide the agent with some port-numbered spanning tree T of the graph. Given such a tree T , the agent identifies an Euler tour E(u) of T starting at u, for any node u of T . (The tour is coded as a sequence of port numbers, including both the outgoing port and the incoming port at every step.) Let E(u) be the reverse string of E(u), and let F (u) be the concatenation of E(u) and E(u). The agent performs each F (u) one after another. If some tour is impossible to continue, because the required outgoing port is not available, or the incoming port is not matched (which can happen, if u is not the starting node of the agent), the tour is simply aborted, and the agent backtracks to its starting node. The tour where v is the starting node of the agent, must succeed, and this tour visits all nodes of T , and hence explores the graph. Since there are n tours, each of length O(n), this gives time O(n 2 ).
In order to guarantee exploration time O(n), it is enough to provide the agent with some rooted port-numbered spanning tree T of the graph, where the root is the starting node of the agent. The agent performs an Euler tour of this rooted tree in time 2n − 2.
It remains to show that a port-numbered spanning tree can be given by a map oracle, and a portnumbered spanning tree rooted at the starting node of the agent can be given by an instance oracle, in both cases using O(n log n) bits. This can be done as follows. Consider the DFS tree T rooted at some arbitrary node in the case of a map oracle, and rooted at the starting node of the agent, in the case of an instance oracle, where neighbors of a node are explored in order of increasing port numbers. Give the shape of T as a binary sequence of length 2n − 2, where a 0 means "go down the tree" and 1 means "go up the tree", in this DFS exploration. Moreover, give the sequence of all port numbers, as they are encountered in order during this DFS exploration. This is a sequence of O(n) terms each of which is a number smaller than n. Hence, both sequences can be given to the agent using O(n log n) bits. On their basis, the agent first reconstructs the shape of T , and then puts the port numbers in appropriate places. 2 In the rest of this section we prove negative results indicating the quality of the natural solution given in Proposition 3.1. For the map oracle, we show that quadratic exploration time cannot be beaten, and we give a lower bound on the size of advice sufficient to guarantee this time. For the instance oracle, we show that Proposition 3.1 gives optimal advice for linear exploration time.

Map oracle
Our first result for the map oracle shows that, regardless of the size of advice, exploration time Θ(n 2 ) cannot be beaten, for some n-node graphs.
We will use the following construction from [10] of a family G X of graphs.
Let H be an m 2 -regular graph with m nodes, where m is even, e.g., the complete bipartite graph. Let T be the set of edges of any spanning tree of H. Let S be the set of edges of H outside T . Let s = |S| = m 2 4 − m + 1 and S = {e 1 , e 2 , · · · , e s }. For x ∈ {0, 1} s \ {0 s }, the (2m)-node graph H x is constructed from H by taking two disjoint copies H and H of H, and crossing some pairs of edges from one copy to the other. For i = 1, · · · , s, if the i−th bit of x is 1, then the edge e i = (u i , v i ) is deleted from both copies of H and two copies of e i are crossed between the two copies of H. More precisely, let {v 1 , · · · , v m } be the set of nodes of H and let v i and v i be the nodes corresponding to v i , in H and H , respectively. Let V and V be the sets of nodes of H and H , respectively. Define H According to the result from [10], for every node v ∈ H, there exists some sequence x(v) ∈ {0, 1} s \ {0 s } such that if an exploration of H performed according to some sequence W of port numbers, starting from node v 1 , visits node v at most s times, then in one of the copies H or H in H x(v) the node v or v is not visited at all, if the same sequence W is used to explore the graph H x(v) starting from v 1 . Intuitively, the result from [10] shows a class of graphs with the property that if some node in one of these graphs is not visited many times, then the exploration algorithm fails in some other graph of this class. There is no control in which graph of the class this will happen. We use the graphs from [10] as building blocks to prove a different kind of lower bound. Indeed, we construct a single graph having the property that if some of its nodes is not visited many times, then exploration must fail in this graph. This will prove a lower bound on exploration time for some graph, even if the agent knows the entire graph.
Using the graphs H x ∈ H X from [10] we construct the graph G as follows. For any 1 ≤ i ≤ m, let v 1 (i) be the node corresponding to node v 1 from H in the graph H x(v i ) . Connect the graphs H x(v i ) , for 1 ≤ i ≤ m, and an oriented cycle C with nodes {y 1 , · · · , y m } (port numbers 0,1 are in clockwise order at each node of the cycle), by adding edges (y i , v 1 (i)), for 1 ≤ i ≤ m. The port numbers corresponding to these edges are: 2 at y i and m 2 at v 1 (i). See Fig. 1. The cycle C is called the main cycle of G.  By the construction of G, any exploration algorithm with the agent starting from any node of the main cycle, has the following obliviousness property. For any step i of the algorithm, if the agent is at some node v in this step, and the algorithm prescribes taking some port p at this node, then the port q through which the agent enters the adjacent node w in the (i + 1)-th step, and the degree of the node w are predetermined (i.e., they are independent of the starting node in the main cycle). Intuitively, the agent does not learn anything during the algorithm execution. Therefore, every exploration algorithm with the agent starting from any node of the main cycle can be uniquely coded by a sequence of port numbers which the agent takes in consecutive steps of its exploration.
Let A be any exploration algorithm for G, and suppose that the agent starts from some node of the main cycle. We use · for concatenation of sequences.
Lemma 3.1 Let U be the sequence of port numbers corresponding to the movement of the agent according to algorithm A, starting at some node of the main cycle C of G .
, where each B j is a sequence of port numbers corresponding to the movement of the agent along C and each B j is a sequence of port numbers corresponding to the movement of the agent inside some H x(v i ) .
Proof. Let the agent start from y i 0 . Let y i 1 be the first node where the agent takes the port 2. Let B 1 be the sequence of port numbers corresponding to the movement from y i 0 to y i 1 . At y i 1 , the agent takes the port 2. Let B 1 be the sequence of port numbers corresponding to the movement of the agent after it takes the port 2 and before it takes the port m 2 at v 1 (i 1 ). Therefore the sequence of port numbers until this moment can be written as B 1 · (2) · B 1 · ( m 2 ). Continuing in this way, the sequence U of port numbers can be written as Call an exploration algorithm of G non-repetitive, if the agent, starting from the main cycle, enters each H x(v i ) , for 1 ≤ i ≤ m, exactly once. By definition, the sequence of port numbers corresponding to a non-repetitive algorithm can be written as , where each D j is a sequence of port numbers corresponding to the movement of the agent along C and each D j is a sequence of port numbers corresponding to the movement of the agent inside some H x(v i ) . Notice that since the algorithm is non-repetitive, the number of blocks D j is exactly m.
The following lemma proves that to show a lower bound on the exploration time in G, it is enough to consider only the class of non-repetitive algorithms.
Lemma 3.2 If the agent starts from some node of the main cycle of G and executes any exploration algorithm A of G, then there exists a non-repetitive algorithm A for this agent, such that the time of A is at most the time of A.
be the sequence of port numbers corresponding to the algorithm A, represented as in Lemma 3.1. For any 1 ≤ j ≤ m, consider all the blocks B i corresponding to moves of the agent inside H x(v j ) , and let D j be the concatenation of all these blocks. Delete all these blocks together with the preceding (2) and succeeding ( m 2 ) for each block. Put (2) · D j · ( m 2 ) at the position of the first deleted block. Consider the sequence U , which results from this operation performed for all 1 ≤ j ≤ m. By definition, the sequence U of port numbers corresponds to a non-repetitive algorithm, and the length of U is less or equal to the length of U . Hence the lemma follows. 2 The next lemma implies that the sequence U corresponding to a correct non-repetitive exploration algorithm must be long.
be the sequence of port numbers corresponding to a non-repetitive algorithm. If there exists some D i such that the agent following D i in H starting from node v 1 visits some node v j of H at most s times, then there exists a starting node in the main cycle of G, such that the agent starting at this node and following U does not visit all the nodes of G.
Proof. Suppose that there exists some D i such that the agent following D i in H starting from node v 1 visits some node v j of H at most s times. Choose the starting node of the agent in the main cycle of G, so that the part of its trajectory corresponding to D i visits H x(v j ) . Then by the property of H x(v j ) , at least one copy of v j in H x(v j ) will not be explored by the agent. Since H x(v j ) is visited by the agent only when it follows D i , some node in G is not explored by the agent following U . 2 Theorem 3.1 Any exploration algorithm using any advice given by a map oracle must take time Ω(n 2 ) on graph G, for some starting node in the main cycle, for arbitrarily large n.
Proof. By Lemma 3.2, it is enough to consider only non-repetitive algorithms.
be the sequence of port numbers corresponding to such an algorithm. Then by Lemma 3.3, for each i, 1 ≤ i ≤ m, the agent following D i in H starting from node v 1 visits each node v j of H, for 1 ≤ j ≤ m, at least s+1 times. Therefore the length of D i is at least (s + 1)m. Hence, the length of U is at least m i=1 (s + 1)m = (s + 1)m 2 = m 2 ( m 2 4 − m + 1). Since n = 2m 2 + m, the length of U is in Ω(n 2 ). 2 Theorem 3.1 shows that, for some n-node graph, no advice given by a map oracle can help to explore this graph in time better than Θ(n 2 ). It is then natural to ask what is the minimum size of advice to achieve time Θ(n 2 ) with a map oracle, for every n-node graph. Our next result shows that any exploration algorithm using advice of size n δ for δ < 1 3 , must take time ω(n 2 ), on some n-node graph.
Fix a constant < 1 2 . Let H be an m 2 -regular graph with m nodes, where m is even. Let {v 1 , · · · , v m } be the set of nodes of H. Consider a subset Z ⊂ {1, 2, · · · , m} of size m . Let p = m and n = 2mp. We construct an n-node graph G Z from H. The construction of G Z is similar to the construction of G at the beginning of this section. Let Z = {z 1 , z 2 , · · · , z p }. To construct G Z , connect the (previously described) graphs H x(vz i ) , for 1 ≤ i ≤ p, and an oriented cycle C (called the main cycle) with nodes {y 1 , · · · , y p }, by adding edges (y i , v 1 (z i )), for 1 ≤ i ≤ p. The port numbers corresponding to these edges are: 2 at y i and m 2 at v 1 (z i ). Note that the same obliviousness property applies to exploration algorithms in graphs G Z , when the agent starts from a node of the main cycle.
Let G Z be the set of all possible graphs G Z constructed from H. We have | G Z | = m p .
Theorem 3.2 For any < 1 2 , any exploration algorithm using advice of size o(n 1+ log n) must take time ω(n 2 ) on some graph of the class G Z and for some starting node in the main cycle of this graph, for arbitrarily large n.
Proof. Since < 1 2 , there exists an integer c such that < c−1 2c−1 . We show that if the size of the advice is at most 1 2c m log(m 1− ) = 1− 2c(1+ ) n 1+ log n 2 , then there exists a graph in G Z for which the time required for exploration is ω(n 2 ). We have | G Z | = Define F ( G) = {v z 1 , v z 2 , · · · , v zp } : Z = {z 1 , z 2 , · · · , z p } and G Z ∈ G . Intuitively, F ( G) is the subset of nodes of H, such that for each v ∈ F ( G), there exists some graph in G that contains H x(v) as a subgraph.
We prove the claim by contradiction. Suppose that |F ( G)| < | G| This contradiction proves the claim.
Consider the exploration of some graph G Z ∈ G starting from the main cycle.
be the sequence of port numbers corresponding to a non-repetitive algorithm exploring G Z . Then for each i, 1 ≤ i ≤ p, the agent following D i in H starting from node v 1 must visit each node v ∈ F ( G) at least s + 1 times. (Otherwise, there would exist a graph in G and a starting node in the main cycle, for which one node would not be explored by U ). Hence, for sufficiently large m, the length of D i is at , because s ≥ m 2 5 . Therefore, the length of U is at least Therefore, the length of U is in ω(m 2+2 ) = ω(n 2 ), and hence exploration time is in ω(n 2 ). 2 Since < 1 2 implies 1+ < 1 3 , Theorem 3.2 yields the following corollary.
Corollary 3.1 For any δ < 1 3 , any exploration algorithm using advice of size o(n δ ) must take time ω(n 2 ) on some n-node graph, for arbitrarily large n.

Instance oracle
For the instance oracle we show a general lower bound on the size of advice needed to achieve a given exploration time. The main corollaries of this lower bound are: • the size of advice Θ(n log n) from Proposition 3.1, sufficient to achieve linear exploration time, cannot be beaten; • for advice of linear size, exploration time must be quadratic.
To prove our lower bound we will use the following construction.
Let G be an n 4 -regular n 2 -node graph, where n is divisible by 4. We can use, for example the complete bipartite graph with n 2 nodes. Let m = n 2 . Let v 1 , v 2 , · · · , v m be the nodes of G. Let x = (x 1 , x 2 , · · · , x m ) be a sequence of m integers where 0 ≤ x i ≤ m 2 − 1, for i = 1, · · · , m. Let X be the set of all such sequences.
We construct an n-node graph G x as follows. For each i = 1, · · · , m, add a new node v i of degree 1 to G. Replace the port number x i at v i by port number m 2 . Add the edge (v i , v i ) with the port  Fig. 2. Let G X be the set of all possible graphs G x constructed from G.

Theorem 3.3
For any function φ : N −→ N, and for any exploration algorithm using advice of size o(nφ(n)), this algorithm must take time Ω( n 2 2 φ(n) ) on some n-node graph from the family G X , for arbitrarily large integers n.
Proof. Let n be divisible by 4. We show that if the size of the advice is at most nφ(n) 4 −1, then there exists an n-node graph in the family G X , for which the time required for exploration is Ω( n 2 2 φ(n) ). We have |G X | = |X| = ( m 2 ) m . There are fewer than 2 mφ(2m) 2 = (2 φ(2m) ) m 2 different binary strings of length at most 2mφ(2m) 4 − 1 = nφ(n) 4 − 1. By the pigeonhole principle, there exists a family of graphs G ⊂ G X , of size at least , such that all the graphs in G get the same advice. Let Y = {x ∈ X : G x ∈ G}. Let z = m 2 φ(2m)+2 and let J = {j : |{x j : x ∈ Y | ≥ z}. Intuitively, J is the set of indices, for which the set of terms of sequences x that produce graphs from G is large. Let p = |J|.
Claim: p > m 2 . We prove the claim by contradiction. Suppose that p ≤ m 2 . Since p ≤ m 2 and z < m 2 , we have Note that for all i ∈ {1, 2, · · · , m} \ J, we have |{x i : x ∈ Y }| < z, and for j ∈ J, we have |{x j : < |G|, which is a contradiction. This proves the claim.
Consider any exploration algorithm for the class G. There exists a graph G x ∈ G, such that, at each node v j of G x , for j ∈ J, the agent must take all the ports in {x j : x ∈ Y }. Indeed, suppose that the agent does not take some port x j , where j ∈ J and x ∈ Y . Consider the exploration of any graph G x ∈ G, where x j = x j . Since the agent can visit v j only coming from v j , using port x j in G x , the node v j remains unexplored, as the port x j at v j is never used, which is a contradiction.
Hence, the agent must visit at least m 2 φ(2m)+2 ports at each node v j for j ∈ J. Since |J| > m 2 , the time required for exploration is at least m 2 2 φ(2m)+3 , i.e., it is at least n 2 2 φ(n)+5 . 2 If φ(n) = c where c is a constant, then Theorem 3.3 implies that any exploration algorithm using advice of size at most cn 2 , must take time at least n 2 2 c+3 . This implies that, if the size of advice is at most c n, for any constant c , then exploration time is Ω(n 2 ). Hence we have the following corollary.
Corollary 3.2 Any exploration algorithm using advice of size O(n) must take time Ω(n 2 ) on some n-node graph, for arbitrarily large n.
For φ(n) ∈ o(log n), Theorem 3.3 implies an exploration time ω(n) which shows that the upper bound on the size of advice from Proposition 3.1 is asymptotically tight for exploration in linear time. The following corollary improves this statement significantly, showing that exploration time is very sensitive to the size of advice at the threshold Θ(n log n) of the latter.

Exploration of hamiltonian graphs
In this section we turn attention to hamiltonian graphs. These graphs have a special feature from the point of view of exploration: with sufficiently large advice of appropriate type, the agent can explore a hamiltonian graph without any loss of time, visiting each node exactly once, i.e., in time n − 1, for n-node graphs. Indeed, an instance oracle can give as advice the sequence of port numbers along a hamiltonian cycle, from the starting node of the agent, and then the agent takes the prescribed ports in n − 1 consecutive steps. Since it is enough to give n − 1 port numbers, and the binary representation of each port number uses O(log n) bits, advice of size O(n log n), given by an instance oracle, suffices.
We show that neither the quality nor the size of advice can be decreased to achieve the goal of optimal exploration of hamiltonian graphs. To prove the first statement, we show a graph which is impossible to explore in time n − 1 when advice of any size is given by a map oracle. Indeed, we construct an n-node hamiltonian graph for which even knowing the entire map of the graph (but not knowing its starting node) an agent must use time Ω(n 2 ) to explore it. To prove the second statement, we construct a class of n-node hamiltonian graphs for which advice of size o(n log n), even given by an instance oracle, is not enough to permit exploration of graphs in this class in time n − 1. Indeed, we show more: any exploration algorithm using such advice must exceed the optimal time n − 1 by a summand n , for any < 1, on some graph of this class. Figure 3: The construction ofG from G In order to prove the first result, we construct a (3n)-node hamiltonian graphG from the n-node graph G described in Section 3.1. First, we consider an m 2 -regular m-node hamiltonian graph H (for example, the complete bipartite graph). Let v 1 , v 2 , · · · , v m be the nodes of H along a hamiltonian cycle. The graph G is constructed from H as described in Section 3.1, where the hamiltonian path (v 1 , v 2 , · · · , v m ) is taken as the spanning tree T . We construct the hamiltonian graphG from the graph G as follows. Denote by d(v) the degree of node v in G. For each node v in G, consider a cycle of three nodes v(1), v(2), and v(3), inG, with port numbers 3d(v), 3d(v)+1 in clockwise order at each of these three nodes. For each edge (u, v) in G, such that the port numbers corresponding to this edge are p at u and q at v, add, inG, the edges (u(i), v(j)), for 1 ≤ i, j ≤ 3, with the following port numbers. The port numbers corresponding to edge (u(i), v(j)) are: p + (j − 1)d(u) at u(i) and q + (i − 1)d(v) at v(j), see Fig. 3.

Lemma 4.1 The graphG is hamiltonian.
Proof. According to the definition of H x(v i ) in Section 3.1, this graph has a spanning tree T i that contains two copies of T , corresponding to H and H , and an edge which crosses from H to H . Consider the spanning tree T of G that contains all T i , for 1 ≤ i ≤ m, a spanning path (y 1 , · · · , y m ) of the main cycle, and the set of edges (y i , v 1 (i)). See Fig. 4. Note that the maximum degree of a node in T is three. Since each node in G is replaced by a cycle of three nodes inG, an Euler tour of the tree T yields a hamiltonian cycle inG. Therefore,G is hamiltonian. 2 Let A be an exploration algorithm forG starting from node y i (1), for some i ≤ m. We describe the following algorithm A * on G, starting from node y i . Ignore all moves of A taking port 3d(v) or 3d(v)+1 at a node v(j), for 1 ≤ j ≤ 3, ofG. Replace every move of A taking port r = p+(i−1)d(v), at node v(j), for 1 ≤ j ≤ 3, inG, where 0 ≤ p ≤ d(v) − 1, by a move taking port p in G.
Then the agent executing A * in G, starting from the main cycle, explores all the nodes. The time used by A * in G does not exceed the time used by A inG. Since, by Theorem 3.1, any exploration algorithm for G, starting from the main cycle, must take time Ω(n 2 ), algorithm A must take time Ω(n 2 ) to exploreG. Replacing 3n by n we have the following theorem.
Theorem 4.1 Any exploration algorithm using any advice given by a map oracle must take time Ω(n 2 ) on some n-node hamiltonian graph, for arbitrarily large n. Our last result shows that advice of size o(n log n) causes significant increase of exploration time for some hamiltonian graphs, as compared to optimal time n − 1 achievable with advice of size O(n log n), given by an instance oracle.
Theorem 4.2 For any constant < 1, and for any exploration algorithm using advice of size o(n log n), this algorithm must take time n + n , on some n-node hamiltonian graph, for arbitrarily large n.
Proof. Fix a constant < 1. We show that if the size of the advice is at most n(1− ) 4 log( n 8 ), then there exists an n-node graph, for which the time required for exploration is n + Ω(n ). The construction of the graphs is similar as in Section 3.2. Now, we start with a n 4 -regular n 2 -node hamiltonian graph G, for n divisible by 4. We can use the complete bipartite graph with n 2 nodes, which is hamiltonian. We construct G x from G as in Section 3.2. Let v 1 , v 2 , · · · , v n 2 be the nodes of G along a hamiltonian cycle. Let G x be the graph which is obtained from G x by adding the set of edges {(v 2i−1 , v 2i ) : 1 ≤ i ≤ n 2 }. Each of these edges is given port number 2 at both its endpoints. An example of the construction of G x from G is shown in Fig. 5. Since G is hamiltonian, G x is also hamiltonian, as (v 1 , v 1 , v 2 , v 2 , v 3 , v 3 , v 4 , v 4 , · · · , v n 2 , v 1 ) is a hamiltonian cycle in G x . Let G X be the set of all possible graphs G x constructed from G. Then |G X | = ( m 2 ) m , where m = n 2 . There are fewer than ( , such that all the graphs in G get the same advice. Let Y = {x ∈ X : G x ∈ G }. Let z = m 4 and let J = {j : |{x j : x ∈ Y | ≥ z}. Let p = |J|. By similar arguments as in the proof of Theorem 3.3, we have p > m 2 . Therefore there exists some i, 1 ≤ i ≤ m for which both v 2i−1 and v 2i belong to J. (b) G x for the sequence x = (2, 1, 2, 0, 0, 1) Figure 5: The construction of G x from G Consider any exploration algorithm for the class G . Let the agent start from some node v k , 1 ≤ k ≤ m. The agent must traverse one of the edges (v 2i−1 , v 2i−1 ) or (v 2i , v 2i ) in order to visit the nodes v 2i−1 and v 2i . Hence, by a similar argument as in the proof of Theorem 3.3, the agent must take at least m 4 ports at the node v 2i−1 or v 2i , on some graph G x ∈ G . To visit the remaining (n − 1) nodes, the agent needs time at least n − 2. Hence, the time required for visiting all the nodes of G x is at least n − 2 + m 4 , i.e., the time required for exploration is n + Ω(n ). Since this holds for any < 1, the simpler lower bound n + n , for any < 1, holds as well, for arbitrarily large n. 2

Conclusion
Most of our lower bounds on the size of advice are either exactly or asymptotically tight. The lower bound log log log n − Θ(1) on the size of advice sufficient to explore all n-node graphs in polynomial time is exactly tight: with advice of any such size, polynomial exploration is possible, and with advice of any smaller size it is not. For an instance oracle, the lower bound Ω(n log n) on the size of advice sufficient to explore n-node graphs in O(n) time is asymptotically tight, as we gave a linear time exploration algorithm using advice of size O(n log n). An exception to this tightness is the lower bound on the size of advice given by a map oracle, permitting exploration in time O(n 2 ). While the natural upper bound is O(n log n), our lower bound is only n δ for any δ < 1 3 . Hence the main remaining question is: What is the smallest advice, given by a map oracle, permitting exploration of n-node graphs in time O(n 2 )?