Coloring Graphs to Produce Properly Colored Walks

Abstract: For a connected graph, we define the proper-walk connection number as the minimum number of colors needed to color the edges of a graph so that there is a walk between every pair of vertices without two consecutive edges having the same color. We show that the proper-walk connection number is at most three for all cyclic graphs, and at most two for bridgeless graphs. We also characterize the bipartite graphs that have proper-walk connection number equal to two, and show that this characterization also holds for the analogous problem where one is restricted to properly colored paths.

\section{Introduction}

We consider the problem of coloring the edges of a graph so that
it is possible to get between every pair of vertices without
two consecutive edges having the same color.
Obviously, this can be achieved by
giving every edge a different color, and indeed by
any proper coloring of the edges. So the real question is
what is the minimum number of colors one needs.

Borozan et al.~\cite{BFGMMMT12proper} introduced this problem
for paths. In particular, for a connected graph $G$, they defined
the \emph{proper connection number} as the
minimum number of colors that one needs so that there is
a properly colored path between every two vertices. For example,
they showed that the parameter is at most $3$ for any block.
Also, if a graph has a Hamiltonian path,
then the parameter is at most $2$~\cite{ALLZ16proper},
and thus almost surely this holds for a random graph~\cite{GLQ16random}.
For a recent survey, see~\cite{LM15survey}.

We consider here the analogous concept for walks.
For a connected graph $G$, we define
the \emph{proper-walk connection number} $\mathop{\mathit{pW}}(G)$ as the
minimum number of colors if one is allowed any
properly colored walk. For symmetry, we will use $\mathop{\mathit{pP}}(G)$ to
denote the proper connection number.
Trivially, $\mathop{\mathit{pW}}(G) \le \mathop{\mathit{pP}}(G)$.

We proceed as follows.
In Section~\ref{s:three} we show that for any connected cyclic graph the proper-walk
connection number is at most three, and
in Section~\ref{s:bipartite} we characterize the bipartite graphs that
have proper-walk and proper connection numbers two. Thereafter,
we show in Section~\ref{s:twoOdd} that the parameter is two
for any graph with two disjoint odd cycles
and in Section~\ref{s:bridgeless} that the parameter is two for
any bridgeless graph. In Section~\ref{s:forward}
we provide some thoughts on the general case.
We conclude with a comment
about the directed version and some
thoughts for future work.

\section{An Upper Bound} \label{s:three}

It is immediate that a properly colored walk cannot
use the same edge twice in succession. It follows that, in a
tree, every properly colored walk is a path. As
observed in~\cite{ALLZ16proper}, for the property in trees, one needs the edges
of the tree to be properly colored, and thus:

\begin{OBS}
If $T$ is  a tree with maximum degree $\Delta$, then
 $\mathop{\mathit{pW}}(T)=\mathop{\mathit{pP}}(T)=\Delta$.
 \end{OBS}

We present next a general upper bound on the proper-walk connection
number of cyclic graphs.

\begin{THM}
Let $G$ be a connected graph that is not a tree.
Then $\mathop{\mathit{pW}}(G) \le 3$.
\end{THM}
\begin{Proof}
We may assume that $G$ is unicyclic (else take suitable spanning subgraph).
Consider the cycle $C$.  Take any proper
coloring of the cycle $C$. For every vertex $v$ of the cycle,
it is incident with two colors in the cycle; so let
all other edges incident with $v$ have the third color. Color
the remaining edges so that for every vertex $w$ not on the cycle,
the path $J_w$ from $w$ to the closest vertex of $C$ is properly colored.

There is a properly colored walk between every pair $u$ and $v$ of vertices.
For example, if both $u$ and $v$ are off the cycle, then use $J_u$ to
get to the cycle, go around the cycle to the vertex closest to $v$, and then
use $J_v$ in reverse to get to~$v$.
\end{Proof}

Figure~\ref{f:pw3} gives an example of a graph $G$ where $\mathop{\mathit{pW}}(G)=3$.
(For a proof of this, see Theorem~\ref{t:cycleFeet}.)

\begin{myFigure}
\includegraphics{properColor-11.pdf}
\\
\caption{A graph $G$ such that $\mathop{\mathit{pW}}(G)=3$}
\label{f:pw3}
\end{myFigure}

Note that the complete graph has $\mathop{\mathit{pW}}(G)  = \mathop{\mathit{pP}}(G)=1$,
while noncomplete graphs have $\mathop{\mathit{pW}}(G)\ge 2$.
So the big question is: for which graphs is $\mathop{\mathit{pW}}(G)=2$?

\section{Bipartite Graphs}  \label{s:bipartite}

We next determine which bipartite graphs $G$ have $\mathop{\mathit{pW}}(G)=2$.

For graph $G$, define $M(G)$ as the spanning subgraph
that results if one removes all the bridges of $G$.
Note that each component of $M(G)$ is either an isolated
vertex or is $2$-edge-connected.

\begin{THM} \label{t:bipartite}
Let $G$ be a connected bipartite graph with order at least $3$. Then $\mathop{\mathit{pW}}(G)=2$
if and only if every component of $M(G)$ is
incident with at most two bridges.
\end{THM}
\begin{Proof}
(1)
Assume that every component of $M(G)$ is
incident with at most two bridges. We will color the edges of $G$ with two colors.

We first color the edges of $M(G)$.
Let $H$ be a nontrivial component of $M(G)$.
Then $H$ is $2$-edge connected.
By Robbins' Theorem~\cite{Robbins39traffic},
such a graph has a strongly connected
orientation, say~$\vec{H}$. (That is, an orientation such that one can get
from every vertex to every other vertex respecting the orientation.)
Give the vertices of the subgraph $H$ their bipartite coloring;
then color each arc of~$\vec{H}$ by the color of the head. It follows that
all directed walks in the orientation~$\vec{H}$ alternate colors.
And within the undirected $H$, each pair of vertices is joined by a properly colored
walk that starts with any designated color or that ends with any
designated color, by either following the arcs or going against the arcs.
Do this process for all nontrivial components $H$ in $M(G)$.

We next color the bridges of $G$. We will color them such that
two bridges incident with the same component $H$ of $M(G)$
have the same color if and only if their ends in $H$ are in different
partite sets.  This can be achieved by
considering the graph $F$ obtained from $G$ by contracting each
(nontrivial) component $H$ of~$M(G)$ to a single vertex $c_H$.
Note that
$F$ is acyclic, has maximum degree at most $2$, and is connected, so that
$F$ is a path. Each edge in $F$ corresponds to a bridge in $G$;
for each bridge $e$ of $G$, let $e'$ be the corresponding
edge in~$F$.

We color $F$ as follows. Start at a leaf-edge
and color it arbitrarily. For subsequent edges, suppose that edge $e'$ is
colored and we need to color adjacent edge $f'$. Say
edges $e'$ and $f'$ have common end $c_H$ in $F$. Then let $v_e$ be the end of $e$ in $H$
and similarly with $v_f$. If $v_e$ and $v_f$ are in the same partite
set of $G$, then give edges $e$ and $f$ different colors; and
if $v_e$ and $v_f$ are in different partite
sets of $G$, then give edges $e'$ and $f'$ the same color.
Finally, transfer the coloring of $F$ to $G$; that is, give each bridge $e$ of $G$ the color of its
corresponding edge $e'$ in $F$.

We claim the above coloring has the desired property; that is, there is a properly colored
walk between every two vertices $u$ and $v$ of $G$.

Every path from $u$ to $v$ uses the same set of bridges in the
same order. So consider two consecutive of these bridges, say
$b_1$ and $b_2$. Then there is a component of $M(G)$, say $H$,
to which they are both incident.
By the way we colored the bridges, if $b_1$ and $b_2$ have the
same color, say red, then their ends in~$H$ are in different partite
sets and so every path between them finishes with the same
color it starts with. By above there
is a path between those two ends starting and finishing with a
blue edge. On the other hand, if $b_1$ and $b_2$ have different
colors, say the former is red and the latter is blue, then these
ends are in the same partite set, and so every path between them finishes
with color different to its start.
By above there is a path between these ends starting with
a blue edge (and necessarily ending with a red edge).
Thus we can piece together the bridges with suitable paths in $M(G)$
to obtain the alternating $u$--$v$-walk

(2) Assume that $G$ has a suitable $2$-coloring.
Since $G$ is bipartite, every closed walk has
the same parity. So assume a properly colored walk enters a subgraph~$H$ of
$M(G)$ along bridge $b_1$ to vertex~$v_1$ and exits
$H$ along bridge $b_2$ from vertex~$v_2$ (with $v_1=v_2$ allowed). Then
$b_1$ and~$b_2$ must have color determined by
the parity of the distance between $v_1$ and~$v_2$. That is, bridges $b_1$ and $b_2$ have the same color
if and only if $v_1$ and $v_2$ are in different partite sets in $G$.

So suppose there are three bridges $b_1,b_2,b_3$ incident with
(not necessarily distinct) vertices $v_1,v_2,v_3$ of
$H$. Without loss of generality, $v_1$ and $v_2$ are in the same
partite set~$X$. Thus $b_1$ and $b_2$ need different colors.
But then if $v_3$ is in~$X$, the bridge $b_3$
needs a color different from both $b_1$ and $b_2$; and if
$v_3$ is in the other partite set, then $b_3$ needs to be
the same as both $b_1$ and $b_2$; in each case an impossibility.
\end{Proof}

It turns out that the above characterization also holds
for the proper connection number.
For,
 in a bipartite graph, all closed walks have even length. Thus, if the edges
are $2$-colored, then there is a properly colored walk between two vertices
if and only if there is a properly colored path between them.  That is:

\begin{THM}
Let $G$ be a connected bipartite graph of order at least $3$. Then $\mathop{\mathit{pP}}(G)=2$
if and only if every component in $M(G)$ is
incident with at most two bridges.
\end{THM}
\noindent
It was known that $\mathop{\mathit{pP}}(G)=2$ for bridgeless bipartite graphs~\cite{BFGMMMT12proper}.

\section{Disjoint Odd Cycles}  \label{s:twoOdd}

We now consider the general problem of which graphs $G$ have $\mathop{\mathit{pW}}(G)=2$.

\begin{THM} \label{t:twoOddCycles}
If a connected noncomplete graph $G$ has two edge-disjoint odd cycles, then $\mathop{\mathit{pW}}(G)=2$.
\end{THM}
\begin{Proof}
Since the graph is noncomplete, we need at least two colors.

Let $C_1$ and $C_2$ be edge-disjoint odd cycles.
 If they are also
vertex-disjoint, let $P$ be a shortest path joining them; say $P$ starts with vertex $u_1$
in $C_1$ and ends at $u_2$ in $C_2$. If the cycles have a vertex in common, then let
$u_1=u_2$ be such a vertex. Let $H$ be the subgraph consisting of $C_1$, $C_2$, and
$P$ if needed.

Now, color the two edges of $C_1$ incident with~$u_1$ red; then color
the remaining edges of $C_1$ alternating red and blue so that $u_1$ is
the only vertex not incident with an edge of each color.
Further, if $P$ exists, color the edges of $P$ alternating colors so that the edge incident with $u_1$ is blue.
Now, if $P$ has even length or the cycles had a vertex in common,
color the two edges of $C_2$ incident with~$u_2$ blue; then color
the remaining edges of $C_2$ alternating red and blue so that $u_2$ is
the only vertex not incident with an edge of each color.
On the other hand,
if $P$ has odd length, then proceed similarly, except that the two edges of $C_2$
incident with $u_2$ are colored red.

We claim that this coloring has the property that between every pair $u$ and~$u'$ of (not
necessarily distinct) vertices in $H$, there is a properly colored walk that starts and finishes
with any prescribed colors. To see this, first note that every vertex of $H$ is incident
with at least one edge of each color. Thus one can start walking from $u$ with any prescribed color.
Then one can extend this alternating walk indefinitely such that eventually one traverses $P$ in both
directions (if it exists), and goes around both $C_1$ and $C_2$ in both directions. Using this, one can arrive at vertex $u'$
having just traversed any designated incident edge.

Now consider the vertices not in $H$.
By choosing a spanning subgraph if needed,
one may assume that for each vertex $v$ not in $H$ there is a unique
path~$J_v$ from $v$ to $H$.
Color the remaining edges such that each $J_v$
is properly colored. See Figure~\ref{f:twoOddCycles}.

\begin{myFigure}
\includegraphics{properColor-1.pdf}
\\
\caption{A coloring of a graph with two disjoint odd cycles}
\label{f:twoOddCycles}
\end{myFigure}

We claim that the coloring has the desired property.
To get between any two vertices $v$ and $w$ in $G$, use the alternating path $J_v$
to get to $H$ if necessary, go around $H$ in the appropriate direction, and
then use the alternating path $J_{w}$ in reverse if needed.
\end{Proof}

Our focus is on simple graphs, but we consider in passing
what happens if the graph has loops. It is immediate
from the above that if the graph has two loops
then $\mathop{\mathit{pW}}(G)=2$, as one can treat the loops as odd cycles.
But actually, $\mathop{\mathit{pW}}(G)=2$ for any graph with a loop. For,
one can color the loop blue say, the edges incident with the
loop red, and then alternate colors away from the loop.
There is a properly colored walk between every pair of vertices
by going via the loop.

\section{Bridgeless Graphs}  \label{s:bridgeless}

In this section, we show that $\mathop{\mathit{pW}}(G) \le 2$ for all connected
graphs $G$ without
bridges.

\subsection{Preliminaries}

We will need the following simple observation.

\newpage

\begin{OBS} \label{ob:inverterOdd}
Let $P$ be an induced path. (That is, the subgraph induced by the
vertices of $P$ is a path.)
If there is an odd cycle that shares at least one edge with the path $P$,
then there exists a nontrivial path $S$ that is internally disjoint from~$P$
and creates an odd cycle with~$P$.
\end{OBS}
\begin{Proof}
Let $C$ be any odd cycle that shares an edge with $P$.
Consider the vertices of $C\cap P$. Since $P$ is induced,
there must be at least one vertex in $C$ not on $P$. Since
$C$ and $P$ share an edge, there are at least two
vertices in $C\cap P$.
Now, partition the edges of $C$ not in $P$ into segments, where the ends of a segment
are in $P$ and internal vertices of each segment are not in $P$.
If every segment creates an even cycle with $P$, then the result is
bipartite, a contradiction. So some segment creates an odd
cycle with $P$, as required.
\end{Proof}

We will also need the following result.

\begin{LEM} \label{l:orientable}
Let $P$ be a path in a graph $G$ from vertex
$u$ to vertex $v$ such that for every vertex $w$ not on $P$ there are
two internally disjoint paths from $w$ to $P$ ending at different vertices.
Then one can orient $G$ such that: \\
(a) $P$ is oriented from $u$ to $v$; \\
(b) one can get from $u$ to every other vertex $w$ by a directed walk; and \\
(c) for all vertices $w_1$ and $w_2$ there is a directed walk between
them in at least one direction.
\end{LEM}
\begin{Proof}
We will create a spanning oriented subgraph $\vec{H}$ such that
for each vertex $w$ not on $P$:
there exist distinct vertices $q_w$ and $r_w$ on $P$,
with $q_w$ nearer to $v$, such that there is a directed walk from $q_w$ to $w$
and a directed walk from~$w$ to $r_w$.

Start with $\vec{H}$ as the path $P$ oriented from $u$ to $v$.
We will grow $\vec{H}$ to contain all the vertices.
Let $w$ be any vertex not on $P$.
Since $P$ contains all the cut-vertices of $G$, there are
two internally disjoint paths from $w$ to $P$.
Say these paths end at vertices $h_1$ and~$h_2$, where $h_1$ is nearer to $v$.
Add all the vertices of both these paths to $H$, and
orient the path between $w$ and $h_1$ towards $w$ while orienting the path between $w$ and $h_2$
away from $w$. For all newly added vertices, $h_1$ is the $q$-vertex and $h_2$ the $r$-vertex.

If there is still a vertex not in $H$, let $w'$ be such a vertex.
Take the two internally
disjoint paths from~$w'$ to $P$ and cut each when it reaches a vertex that is
already in $H$. Say we have internally disjoint paths $L_1$ and $L_2$ from~$w'$ to
vertices $k_1$ and $k_2$. For convenience, if vertex $k$ is on $P$ then we define
$r_k = q_k = k$.
By reordering $k_1$ and $k_2$ if necessary, it follows that we may assume
$q_{k_1}$ is strictly nearer to~$v$ than~$r_{k_2}$.

Add all the vertices of both paths $L_1$ and $L_2$ to $H$.
Then orient $L_1$ towards $w'$ and orient $L_2$ away from $w'$.
For all newly added vertices, $q_{k_1}$ is the $q$-vertex and $r_{k_2}$ the $r$-vertex.
Repeat this procedure until $H$ contains all the vertices.

We claim this orientation $\vec{H}$ has the desired three properties. The first property was explicitly
satisfied. For a directed walk from $u$ to $w$, go along $P$ to~$q_w$ and then along the
walk to $w$.
Further, without loss of generality, we may assume that
$r_{w_2}$ is not farther from $v$ than $r_{w_1}$;
this means that $q_{w_2}$ is nearer to~$v$ than~$r_{w_1}$. So one can
get from $w_1$ to $w_2$ by going to $r_{w_1}$, going along $P$ to $q_{w_2}$,
and thence to $w_2$.
\end{Proof}

\subsection{Main Result}

We define a \dd{theta-graph} as a graph that is formed by taking
a cycle $C$ of even length (called the outer cycle) and a path
$P$ (called the inverter) and identifying the ends of the path $P$
with two vertices $u$ and $v$ of the cycle $C$ such that the
result is nonbipartite. See Figure~\ref{f:theta} for an example.

\begin{myFigure}
\includegraphics{properColor-9.pdf}
\\
\caption{A theta-graph}
\label{f:theta}
\end{myFigure}

\newpage

\begin{THM}
There does not exist a $2$-connected graph $G$ such that $\mathop{\mathit{pW}}(G)=3$.
\end{THM}
\begin{Proof}
Suppose block $G$ has $\mathop{\mathit{pW}}(G)=3$.
We saw above (Theorem~\ref{t:bipartite}) that $G$ cannot be bipartite.
Also, we saw (Theorem~\ref{t:twoOddCycles}) that $G$ does not contain two
edge-disjoint odd cycles.

Consider some odd cycle of the graph $G$. If it is a hamilton cycle,
then it is easily seen that $\mathop{\mathit{pW}}(G)=2$. So assume there is a vertex not on this cycle.
By $2$-connectedness, we can find two disjoint paths from this vertex
to the cycle, ending at vertices $u$ and $v$ say. That is, we have three internally
disjoint $u$--$v$ paths such that the result is not bipartite. Two of
these paths have the same parity; choose them to be the outer cycle,
and the other path to be the inverter. That is, the result is a theta-graph.

Out of all theta-subgraphs,
\begin{quote} \slshape
choose the theta-subgraph where the inverter $P$ is as short as
possible.
\end{quote}
Let $C$ be the outer cycle of the chosen theta-graph.

\begin{claim} \label{c:isBipartite}
The graph $G-C$ is bipartite.
\end{claim}
\begin{Proof}
Suppose there is an odd cycle in $G-C$. Since there are not
two edge-disjoint odd cycles in $G$, that odd cycle must share an edge with (the interior of)
$P$. Then by Observation~\ref{ob:inverterOdd}, there is segment $S$ in $G-(C\cup P)$
that joins two vertices of the interior of $P$ but is otherwise disjoint from $P$ and
creates an odd cycle with $P$. This segment $S$ combined
with $P$ and either half of $C$ provides a theta-graph with a shorter
inverter, which contradicts our choice of theta-subgraph.
\end{Proof}

Let $P'$
be the path $P$ minus $u$ and $v$.
Partition the vertices not in the theta-graph into two sets: let $A$
be those vertices that can
reach the outer cycle $C$ without going through $P'$,
and let~$B$ be those that cannot.

Now, color the graph $G$ as follows. Color the theta-graph such that
the outer cycle $C$ is properly colored, as is the inverter $P$.
Without loss of generality, assume that $C$ is drawn so that
every properly colored walk leaving the inverter proceeds clockwise on the outer
cycle.

For each vertex $w$ of $A$, retain one path $J_w$ to $C$ that does not intersect $P'$.
Color the edge of $J_w$ incident with $C$
such that one can go across that edge and proceed counter-clockwise
around the outer cycle.
Color the remaining edges of the path $J_w$ so that it is properly colored.

Finally, consider the set $B$.
By Claim~\ref{c:isBipartite}, the graph  $H$ induced by $P' \cup B$ is bipartite.
Since the graph $G$ is $2$-connected, there are two internally disjoint
paths from every vertex $w\in B$ to the theta-graph. By the definition of $B$,
these paths must meet the theta-graph on $P'$. Thus we can apply Lemma~\ref{l:orientable}
to $H$ and~$P'$ to obtain an orientation $\vec{H}$ with the properties listed in that lemma.
Give each vertex of $H$ its bipartite coloring; then color each arc of
$\vec{H}$ by the color of its head.
As we used in the proof of Theorem~\ref{t:bipartite},
in such a coloring every walk that respects the orientation automatically alternates
colors.

See Figure~\ref{f:theta-graph} for an example, where
the vertices of $A$ are drawn outside the outer cycle and the vertices of~$B$ are
drawn inside the outer cycle.

\begin{myFigure}
\includegraphics{properColor-4.pdf}
\\
\caption{Coloring of theta-graph and a spanning subgraph}
\label{f:theta-graph}
\end{myFigure}

We claim that the resultant coloring of $G$ has a properly colored walk between any pair of
vertices. For example, to get from a vertex $w_1$ of $A$ to another vertex $w_2$ of $A$,
follow $J_{w_1}$, go counter-clockwise around the outer cycle, over the inverter, clockwise
around the outer cycle, and then use $J_{w_2}$ in reverse.
To get from a vertex $w_1$ of $A$ to a vertex $w_3$ of $B$,
follow $J_{w_1}$, go counter-clockwise around the outer cycle to $u$, and then
over the inverter to the first vertex of $P'$, and then use the directed walk in $\vec{H}$
to $w_3$. And, to get between vertices $w_3$ and $w_4$ of $B$, use the
directed walk in $\vec{H}$.
\end{Proof}

From the above result, the question of bridgeless graphs is easily resolved:

\begin{THM} \label{t:bridgeless}
If $G$ is a connected bridgeless graph, then $\mathop{\mathit{pW}}(G)\le 2$.
\end{THM}
\begin{Proof}
Assume $G$ is bridgeless but not $2$-connected. Consider the blocks
of~$G$. If any two of these are nonbipartite, then there
are two edge-disjoint odd cycles, and the result follows
from Theorem~\ref{t:twoOddCycles}.
If all the blocks are bipartite, then
the result follows from Theorem~\ref{t:bipartite}.
So assume that exactly one block, say~$H$, is not bipartite.

By the above theorem, that block $H$ can be colored with two colors to have
a properly colored walk between every pair of vertices in $H$.
Color all remaining blocks properly, as in Theorem~\ref{t:bipartite}.
We claim the resultant coloring has the desired property. To find a properly
colored walk between vertices $u$ and $v$, let $u'$ be the vertex of $H$
nearest to $u$ and $v'$ the vertex of $H$ nearest to $v$. Then find
the properly colored walk between $u'$ and $v'$. This can be extended
to a properly colored walk between $u$ and $v$, since there is a walk from $u$ to $u'$
ending with any prescribed color, and a walk from $v'$ to $v$ starting with
any desired color.
\end{Proof}

\section{Unicyclic Graphs} \label{s:forward}

It is unclear what happens in general in graphs with bridges. The precise placement
of bridges seems to matter. For example, consider
the collection $\mathcal{G}$ of graphs formed by taking an odd cycle and adding
feet to some of the vertices of the cycle. (By adding a foot we mean
adding a new vertex and joining it to exactly one vertex of the cycle.)

\begin{THM} \label{t:cycleFeet}
Let $G$ be a graph of $\mathcal{G}$. Then $\mathop{\mathit{pW}}(G)=2$ if and only
if there are three consecutive vertices $u,v,w$ on the cycle
such that $u$ is adjacent to at most one foot, $w$ is adjacent to at most
one foot, and all vertices other than $u,v,w$ are  incident with no feet.
\end{THM}

\begin{myFigure}
\begin{center}
\includegraphics{properColor-16.pdf}
\\
\caption{A graph in $\mathcal{G}$ with $\mathop{\mathit{pW}}=2$}
\label{f:calGPW2}
\end{center}
\end{myFigure}

\begin{Proof}
(1) We first prove that the conditions are necessary for the graph to have $\mathop{\mathit{pW}}=2$.
That is, assume the graph has a $2$-coloring
such that every vertex can reach every other vertex by a properly colored
walk.

\textit{Case~A: Assume the odd cycle has length at least $5$.}\\
Call a vertex of the cycle a break if the two cycle edges incident with it have the same
color. The number of breaks has the same parity as the number of vertices;
that is, there is an odd number of breaks. Suppose there are
at least three breaks, say vertices $v_1$, $v_2$, and $v_3$. These divide
up the cycle into three paths, at least one of which must have more than one edge,
say the $v_1$--$v_2$ path. Then there is no alternating walk between $v_3$ and an interior
vertex of that path, a contradiction. That is, there is exactly one break.

So let $v$ be the unique vertex on the cycle incident
with two edges of the same color, with neighbors $u$ and $w$ on the cycle.
Suppose there is a foot attached to a vertex $x$
that is neither $u$, $v$, nor $w$. Then the two edges of
the cycle incident with $x$ have different colors, and so any
walk from the foot can proceed in only one direction around the
cycle, and gets stopped at $v$ without reaching all the vertices.
Thus, all feet must be attached to one of $u$, $v$, or $w$.

Consider a foot incident with $u$. In order for it to reach all
vertices, the edge incident with it must have the same color as the $uv$ edge.
It follows that the foot is unique, since otherwise the two feet would not be able
to reach each other.

\textit{Case~B: Assume the odd cycle is a triangle.}\\
If the triangle has
exactly one break, then
by the same argument as Case~A, the other two vertices of the triangle can
be incident with at most one foot each. Further, if the triangle is monochromatic,
then it is easy to see that each vertex of the cycle is incident with at most one foot.
\smallskip

(2) We second prove that the conditions are sufficient.
Color the cycle such that $v$ is incident with two edges of the same color
and every other vertex sees both colors. Color the leaf incident
with $u$ and/or $w$ with the same color as the $uv$ edge;
color all leaves incident with $v$ with the other color.
It is easily checked that this coloring has the desired property.
\end{Proof}

\section{Directed Graphs} \label{s:digraph}

For a strongly connected digraph, one can define the proper-walk
connection number as in the undirected case.
 This idea was recently
introduced for paths by Magnant et al.~\cite{MMPSW16directed}.
They showed that:

\begin{THM} \cite{MMPSW16directed}
Let $D$ be a strongly-connected digraph.
Then $\mathop{\mathit{pP}}(D) \le 3$.
\end{THM}

This is sharp, even for the proper-walk case, since
an odd cycle needs three colors; that is, $\mathop{\mathit{pW}}(D)=
\mathop{\mathit{pP}}(D) = 3$ if $D$~is an odd cycle.

We note that the two parameters can be different. That is,
there are digraphs
with $\mathop{\mathit{pW}}(D)=2$ and $\mathop{\mathit{pP}}(D)=3$.
For example, take two disjoint directed triangles and identify one vertex
of each. See Figure~\ref{f:bowTie}.

\begin{myFigure}
\includegraphics{properColor-8.pdf}
\\
\caption{A graph where $\mathop{\mathit{pW}}( D) = 2$ and $\mathop{\mathit{pP}}(D) = 3 $}
\label{f:bowTie}
\end{myFigure}

Another direction is to add loops. If one adds loops
at all vertices, then one needs only two colors  (color all original
arcs one color and all loops a second color).

\section{Conclusion} \label{s:conclusion}

We proved that every connected graph has proper-walk connection number
at most three, and showed that it is two for some families.
One natural
open problem is the complexity of recognizing which
graphs have the parameter $2$. Is there a polynomial-time algorithm,
or is it NP-hard? Note that it is easy to check using a breadth-first-search
whether a given coloring
has a properly colored walk  between two vertices.

Other directions of interest include the question where some of the
edges of the graph are already colored. For example, K\'{e}zdy and Wang
\cite{KW99alternating} asked when one could complete a $2$-coloring
such that there is an alternating path between two specified vertices.
One could also insist on stronger properties; for example, that every pair
of vertices is in a properly colored cycle,
or closed walk.

\section*{Acknowledgements}

We thanks the referees for their thoughtful comments that improved the paper.


Packing Ferrers Shapes

Abstract: Answering a question of Wilf, we show that if $n$ is sufficiently large, then one cannot cover an $n \times p(n)$ rectangle using each of the $p(n)$ distinct Ferrers shapes of size $n$ exactly once. Moreover, the maximum number of pairwise distinct, non-overlapping Ferrers shapes that can be packed in such a rectangle is only $\Theta(p(n)/ \log n).$

\section{Introduction}
A {\em partition} $p$ of a positive integer $n$ is an  array $p=(x_1,x_2,\cdots
,x_k)$ of positive integers so that
$x_1\geq x_2 \geq \cdots \geq x_k$ and
 $n=\sum_{i=1}^k x_i$. The $x_i$
are called the {\em parts} of $p$. The total number of distinct partitions
of $n$ is denoted by $p(n)$. A {\em Ferrers shape} of a partition
$p=(x_1,x_2,\cdots,x_k)$ is a set of $n$ square boxes with sides parallel
to the
coordinate axes so that in the $i$th row we have $x_i$ boxes and all rows
start at the same vertical line. The Ferrers
shape of the partition $p=(4,2,1)$ is shown in Figure 1. Clearly, there is
an obvious bijection between partitions of $n$ and Ferrers shapes of size $n$.

If we reflect a Ferrers shape of a partition $p$ with respect
to its main diagonal,
we get another shape, representing the {\em conjugate} partition of $p$.
Thus, in our example, the conjugate of (4,2,1) is (3,2,1,1).

\begin{center}

 \setlength{\unitlength}{0.00030000in}%
\begingroup\makeatletter\ifx\SetFigFont\undefined
\def\x#1#2#3#4#5#6#7\relax{\def\x{#1#2#3#4#5#6}}%
\expandafter\x\fmtname xxxxxx\relax \def\y{splain}%
\ifx\x\y
\gdef\SetFigFont#1#2#3{%
  \ifnum #1<17\tiny\else \ifnum #1<20\small\else
  \ifnum #1<24\normalsize\else \ifnum #1<29\large\else
  \ifnum #1<34\Large\else \ifnum #1<41\LARGE\else
     \huge\fi\fi\fi\fi\fi\fi
  \csname #3\endcsname}%
\else
\gdef\SetFigFont#1#2#3{\begingroup
  \count@#1\relax \ifnum 25<\count@\count@25\fi
  \def\x{\endgroup\@setsize\SetFigFont{#2pt}}%
  \expandafter\x
    \csname \romannumeral\the\count@ pt\expandafter\endcsname
    \csname @\romannumeral\the\count@ pt\endcsname
  \csname #3\endcsname}%
\fi
\fi\endgroup
\begin{picture}(5124,4074)(2389,-5323)
\thicklines
\put(2401,-2611){\framebox(1275,1350){}}
\put(3676,-2611){\framebox(1275,1350){}}
\put(4951,-2611){\framebox(1275,1350){}}
\put(6226,-2611){\framebox(1275,1350){}}
\put(2401,-3961){\framebox(1275,1350){}}
\put(3676,-3961){\framebox(1275,1350){}}
\put(2401,-5311){\framebox(1275,1350){}}
\end{picture}
\end{center}
\centerline{Figure 1: The Ferrers shape of (4,2,1)}

Recently, Herb Wilf \cite{wilf} has asked the following intriguing question:
consider all distinct Ferrers shapes consisting of $n$ boxes.
 Is it true that  for $n$ sufficiently large, one can always
 tile a rectangle of side lengths $p(n)$ and $n$ using each of these shapes
 exactly once ? Obviously, in such a tiling, if one exists, the shapes cannot
overlap each other. For small values of $n$, one gets mixed answers:
for $n=1,2,4$ such a tiling exists, however, for $n=3$ there is no such
tiling.

In this short paper we  answer Wilf's question in the negative by showing
that for $n$ sufficiently large no such tiling exists. In fact, we prove
the following stronger statement.
\begin{theorem}
\label{t1}
If $n$ is sufficiently large, then one cannot cover an
$n \times  p(n)$ rectangle by using each of the $p(n)$
distinct Ferrers
shapes of size $n$ exactly once. Moreover, the maximum fraction
of the area of this rectangle that can be covered by non-overlapping
distinct Ferrers shapes of size $n$ is   at most
$\frac{c}{\log n}$, for some absolute constant $c$.
\end{theorem}

The $c/\log n$ upper bound
is tight, up to the constant $c$, and shows that
as $n$ grows we cannot even cover
a fixed fraction of the area by non-overlapping distinct shapes.

To prove the result, we use some geometric properties that are shared
by the vast majority of the Ferrers shape of size $n$ and imply that
these shapes cannot be packed in an efficient way.
The geometric properties we need can probably be derived from
the extensive available information
on the typical form of a Ferrers shape, given, for example, in
 \cite{pittel}, and partly also in several earlier papers including
 \cite{szt1},  \cite{szt2},
 \cite{szt3}.
However,
since we need an explicit estimate of the number of shapes that
do not satisfy the required properties, and in order to make the paper
self-contained, we prefer to derive all of them directly from the
Hardy-Ramanujan asymptotic formula for $p(n)$.
This is done in the next section. In Section 3, we apply the geometric
properties to prove our main result. Throughout the paper we assume,
whenever this is needed, that the size $n$ of the Ferrers shapes
considered is sufficiently large.

\section{Some geometric properties of typical Ferrers shapes }

The corner of the
first row and first column of a Ferrers shape will be called
the {\em apex} of that shape.
In this section we prove
some asymptotic geometric properties of Ferrers shapes of size $n$.
Our basic tool is the well-know
 Hardy-Ramanujan asymptotic formula for the number of shapes of size
$n$, see, e.g., \cite{andrews}.
It asserts that
\begin{equation} \label{rama}
p(n) =(1+o(1)) \frac{e^{C\sqrt{n}}}{4n\sqrt{3}}, \end{equation}
where $C=\pi \sqrt{\frac{2}{3}}$, and the $o(1)$-term tends to
$0$ as $n$ tends to infinity.

\begin{lemma}
\label{l1}
Let $x_1 \geq x_2 \geq \ldots \geq x_k$ denote the parts of
the partition corresponding to the Ferrers shape $F$, and let
$y_1 \geq y_2 \ldots \geq y_s$ denote  the parts of the
conjugate partition.
The following hold for  all but $p(n)/n^{0.48}$
Ferrers shapes $F$ of  size $n$.
\begin{itemize}
\item{I.} There exist absolute constants $c_1$ and $c_2$ so that for $n$
sufficiently large, we
 have $c_1 \sqrt n \log n < x_1 < c_2 \sqrt n \log n,$ and also,
$c_1 \sqrt n \log n < y_1 < c_2 \sqrt n \log n $.
\item{II.}
For every $\epsilon >0$ there exists a $\delta>0$ such that the
following holds.
Let $Q$ be a square of side length $\epsilon \sqrt n \log n$ whose
 apex is that of $F$ and whose sides are adjusted to the border of $F$,
(see Figure 2). Then
$F - Q$ contains at most $n^{1-\delta}$ boxes.
\item{III.} There exists $c_3>0$ so that
 $F$ has at least $c_3\sqrt n$ parts of size at least $c_3\sqrt n$ each.
\end{itemize}
\end{lemma}
\begin{proof}
\begin{itemize}
\item{I.}
The inequalities for $x_1$ and $y_1$ are clearly equivalent by taking
conjugates. Thus it suffices to prove the statements for $x_1$.
\begin{itemize}
\item We first bound the number of partitions with a large value of
$x_1$. To do so,
consider a partition with
$x_1 > c_2 \sqrt n \log n$ and remove its first part. This way
we get a partition of an integer smaller than $n-c_2 \sqrt n \log n$.
There are (less than) $n$ ways to choose the first part, and by the
obvious monotonicity of $p(n)$ there are at most
$p(n-c_2 \sqrt{n} \log n)$ ways to choose the remaining partition.
Therefore, the number of partitions of $n$ with $x_1 > c_2 \sqrt n \log n$
does not exceed
$n\cdot p(n-c_2 \sqrt{n} \log n)$.
By (\ref{rama}) this yields
\[n\cdot p(n-c_2 \sqrt n \log n)\leq n
\frac{e^{C\sqrt{n-c_2 \sqrt n \log n}}}{4n\sqrt 3}<n \frac{p(n)}{n^{0.5Cc_2}},
 \]
as $\sqrt{n-c_2 \sqrt n \log n}\leq \sqrt{n}-\frac{1}{2}c_2 \log n$.
Since $C=\pi \sqrt {2/3}$ this implies that by choosing,
for example,
$c_2$ to be $4$, we conclude that the number of partitions of $n$
that do not satisfy
$x_1 \leq c_2 \sqrt n \log n$ is smaller than $p(n)/n$.

\item Next we prove that for almost all partitions we also have
$x_1 \leq  c_1 \sqrt n \log n$, for some positive constant $c_1$.
 Let $S$ be the set of partitions of $n$ violating this
constraint, and attach two additional
parts $x_0$ and $x_{-1}$ in
all possible ways to all partitions in $S$ so that the following hold:
\[x_0+x_{-1}=3\cdot[ c_1 \sqrt n \log n],\]
and
\[x_{-1}\geq x_{0}\geq c_1 \sqrt n \log n.\]
Let $S'$ be the set of partitions obtained this way. It then follows that
$x_{-1}$ and $x_{0}$ are the two largest parts in all partitions
in $S'$, and that $S'$ contains partitions of the integer
$n+3\cdot[ c_1 \sqrt n \log n]$.

As $x_{-1}\geq x_0$, we must have $1.5\cdot c_1 \sqrt n \log n
\leq x_{-1} \leq 2\cdot c_1 \sqrt n \log n$, so we have
 $0.5\cdot c_1 \sqrt n \log n$ choices for $x_{-1}$.
This implies
\[|S'|= |S|\cdot 0.5\cdot c_1 \sqrt n \log n
 \leq p(n+3\cdot[ c_1 \sqrt n \log n]),\]
which yields
\[|S|=\frac{|S'|}{0.5\cdot c_1 \sqrt n \log n}
 \leq
\frac{p(n+3\cdot[ c_1 \sqrt n \log n])}{0.5\cdot c_1 \sqrt n \log n}\leq
\frac{p(n)\cdot e^{1.5Cc_1 \log n}}{0.5\cdot c_1 \sqrt n \log n} \leq
\frac{p(n)\cdot n^{1.5Cc_1}}{0.5\cdot c_1 \sqrt n \log n}, \]
as $\sqrt{n+3c_1 \sqrt n \log n}< \sqrt n +1.5c_1\log n$. By
choosing a sufficiently small $c_1$
(e.g., $c_1=1/1000$), we see that  all but $p(n)/n^{0.49}$
 partitions satisfy $x_1 \geq c_1 \sqrt n \log n$.
(Note that it is not difficult to show that in fact for every fixed $r$
there is some $c_1>0$ so that for all but at most $p(n)/n^r$ partitions
of $n$, $x_1 \geq c_1 \sqrt n \log n$. This can be done by adding to
each partition that does not satisfy the above more than $2$ parts with
a prescribed sum, and by repeating the above argument. For our
purpose here, however, the above estimate suffices.)
\end{itemize}
\item{II.}  It suffices to prove that most partitions do not have
too many parts which are larger than $\epsilon \sqrt n \log n$,
as this would imply, by taking the conjugate,
that most partitions also do not have
too many columns larger than $\epsilon \sqrt n \log n$, either,
yielding that the total area outside the square $Q$ is small.
More precisely,
 we prove that for every $\epsilon>0$ there exists a $\delta>0$ so that
for all but at most $p(n)/n$ of the partitions of $n$,
$|\{i |x_i >\epsilon \sqrt n \log n\}|<n^{\frac{1}{2}-\delta}$.
\begin{center}
\setlength{\unitlength}{0.00027500in}%
\begingroup\makeatletter\ifx\SetFigFont\undefined
\def\x#1#2#3#4#5#6#7\relax{\def\x{#1#2#3#4#5#6}}%
\expandafter\x\fmtname xxxxxx\relax \def\y{splain}%
\ifx\x\y
\gdef\SetFigFont#1#2#3{%
  \ifnum #1<17\tiny\else \ifnum #1<20\small\else
  \ifnum #1<24\normalsize\else \ifnum #1<29\large\else
  \ifnum #1<34\Large\else \ifnum #1<41\LARGE\else
     \huge\fi\fi\fi\fi\fi\fi
  \csname #3\endcsname}%
\else
\gdef\SetFigFont#1#2#3{\begingroup
  \count@#1\relax \ifnum 25<\count@\count@25\fi
  \def\x{\endgroup\@setsize\SetFigFont{#2pt}}%
  \expandafter\x
    \csname \romannumeral\the\count@ pt\expandafter\endcsname
    \csname @\romannumeral\the\count@ pt\endcsname
  \csname #3\endcsname}%
\fi
\fi\endgroup
\begin{picture}(4524,4824)(3664,-6073)
\thicklines
\put(3676,-5236){\framebox(3900,3975){}}
\put(3676,-5236){\line( 0,-1){825}}
\put(3676,-6061){\line( 1, 0){750}}
\put(4426,-6061){\line( 0, 1){1425}}
\put(4426,-4636){\line( 1, 0){900}}
\put(5326,-4636){\line( 0, 1){975}}
\put(5326,-3661){\line( 1, 0){1350}}
\put(6676,-3661){\line( 0, 1){1575}}
\put(6676,-2086){\line( 1, 0){900}}
\put(7576,-1261){\line( 1, 0){600}}
\put(8176,-1261){\line( 0,-1){825}}
\put(7576,-2086){\line( 1, 0){600}}
\put(7276,-4936){\makebox(0,0)[lb]{\smash{\SetFigFont{7}{8.4}{rm}Q}}}
\put(4951,-4411){\makebox(0,0)[lb]{\smash{\SetFigFont{7}{8.4}{rm}F}}}
\end{picture}

\end{center}
\centerline{Figure 2: $Q$ contains most of $F$}

Let $S=\{p~:~\mbox{ $p=(x_1,\ldots ,x_k)$ is a partition of $n$ so
that } |\{i |x_i >\epsilon \sqrt n \log n
\}| \geq n^{1/2-\delta} \}$. As we have already proved statement I of the
lemma, we may and will assume that all parts of the members of $S$
are smaller than $c_2 \sqrt n \log n$, as this holds for all of them but
at most $p(n)/n$. Note, also, that if the maximum row and column length
of a partition is at most $c_2 \sqrt n \log n$, and it has at most
$n^{1/2-\delta}$ rows and at most that many columns of length
exceeding $\epsilon \sqrt n \log n$,  then the total area of its Ferrers
shape that is not covered by the square $Q$ is at most
$2c_2n^{1-\delta} \log n<n^{1-\delta'}$ for, say, $\delta'=\delta/2$,
as needed.

To obtain a partition in $S$,
we first need to choose $n^{\frac{1}{2}-\delta}$ parts,
each larger than $\epsilon \sqrt n \log n$ and smaller than
$c_2 \sqrt n \log n$. This can be done in at most
 ${{ c_2 \sqrt n \log n
+ n^{\frac{1}{2}-\delta}\choose n^{\frac{1}{2}-\delta} }}$ different ways.
Next, we choose
a partition of the remaining integer. This can be done  in at most
$p(n-\epsilon n^{1-\delta}\log n)$ ways. Therefore,
\begin{equation} \label{square} |S|\leq {{ c_2 \sqrt n \log n
+ n^{\frac{1}{2}-\delta}\choose n^{\frac{1}{2}-\delta} }} \cdot
p(n-\epsilon n^{1-\delta}\log n).\end{equation}
By Stirling's formula
\[{{a \choose b}} \leq (\frac{ea}{b})^b.\]
Thus inequality (\ref{square}) implies
\[|S|<(2ec_2n^{\delta}\log n )^{n^{0.5-\delta}} \cdot p(n)e^{-0.5C\epsilon
n^{0.5-\delta}\log n}= p(n)(\frac{2ec_2n^{\delta}\log n }{n^{0.5C\epsilon}})^
{n^{0.5-\delta}}.\]
 As $C>1$, choosing, e.g., $\delta= \epsilon /2$ gives the desired estimate.
\item{III.} Let $S=\{~p:~ p=(x_1,\ldots, x_k) \mbox { is a
partition of $n$ so that } |\{i|x_i\geq c_3\sqrt{n}\} |
<c_3 \sqrt n \}$.
Let $\cal F$ be a family of at least, say, $2^{0.1c_3 \sqrt n}$
subsets of a set of
cardinality $10c_3 \sqrt n$ in which the Hamming distance between any
two subsets is larger than $2c_3 \sqrt n$. (The existence of such  a family
is easy and follows from the Gilbert-Varshamov bound, see, e.g.,
\cite{MS}.)
Let the
underlying set of $\cal F$ be the set $\{c_3 \sqrt n+1,
c_3 \sqrt n +2, \cdots ,  11c_3\sqrt n\}$.

Define $S'=\{P\cup F | P\in S,
F\in \cal F\}$. It is not too difficult to check that all
$|S|\cdot |\cal F|$ partitions in $S'$ are pairwise distinct;
indeed, if two such unions have the same $P$ or the same $F$ then they
clearly differ. On the other hand, for distinct $P,P'$ in $S$ and distinct
$F,F'$ in ${\cal F}$, $P \cup F$ and $P' \cup F'$ do not have the same sets of
parts of size bigger than $c_3 \sqrt n$, by the definition of $S$ and the
choice of ${\cal F}$.
Therefore, we have
\[|S'|=|S|\cdot |\cal F| \]
which yields
\begin{equation}\label{third}
|S|\leq \frac{|S'|}{2^{0.1c_3 \sqrt n}}. \end{equation}
All the elements of $S'$
are partitions of integers not larger than $n+110c_3^2n$.
As these are all distinct it follows that
\[|S'|\leq \sum_{k\leq n+110c_3^2n}p(k)\leq
e^{C\sqrt{n(1+110c_3^2})}\leq e^{C\sqrt{n}+55C\cdot c_3^2\sqrt{n}},\]
and therefore, by inequality (\ref{third}),
\[|S|\leq \frac{e^{C\sqrt{n}}e^{55C\cdot c_3^2\sqrt{n}}}{2^{0.1c_3 \sqrt n}}\]
which completes the proof, as by choosing, say, $c_3=0.001$,
the second term of the
numerator becomes much smaller than the denominator.
\end{itemize}
This completes the proof of Lemma \ref{l1}.
\end{proof}

\section{The proof of the main result}

In this section we prove Theorem \ref{t1}. Consider a collection
of non-overlapping pairwise distinct Ferrers shapes of size $n$
contained in a given $n$ by $p(n)$ rectangle $R$. First,
omit  all shapes that do not satisfy the three conditions in
Lemma \ref{l1}, and call the remaining collection of shapes the
{\em reduced collection}. By the assertion of the lemma at most $p(n)/n^{0.48}
<p(n)/\log n$ shapes are deleted in this step, and we are now left
only with shapes satisfying all three
conditions of the lemma.

Let $A\subset R$ be a square of side length $0.8c_1 \sqrt n \log n$ where
$c_1$ is a constant satisfying condition I of lemma \ref{l1}.

\begin{lemma}
\label{l2}
There exists an absolute constant $\gamma$ so that the total area of $A$
covered by our reduced collection is at most $\gamma n\log n$.
\end{lemma}
\begin{proof} First note that we can suppose all of our shapes have their
apexes in their lower left corner. Indeed, by symmetry, we can assume at least
1/4 of all shapes are like that, and losing a constant factor does not
change the validity of the lemma.
Let us view $A$  as a center of a larger square $B$ of
$c_1\sqrt n \log n$ by
$ c_1\sqrt n \log n$, as shown in Figure 3.

\begin{center}
\setlength{\unitlength}{0.00030000in}%
\begingroup\makeatletter\ifx\SetFigFont\undefined
\def\x#1#2#3#4#5#6#7\relax{\def\x{#1#2#3#4#5#6}}%
\expandafter\x\fmtname xxxxxx\relax \def\y{splain}%
\ifx\x\y
\gdef\SetFigFont#1#2#3{%
  \ifnum #1<17\tiny\else \ifnum #1<20\small\else
  \ifnum #1<24\normalsize\else \ifnum #1<29\large\else
  \ifnum #1<34\Large\else \ifnum #1<41\LARGE\else
     \huge\fi\fi\fi\fi\fi\fi
  \csname #3\endcsname}%
\else
\gdef\SetFigFont#1#2#3{\begingroup
  \count@#1\relax \ifnum 25<\count@\count@25\fi
  \def\x{\endgroup\@setsize\SetFigFont{#2pt}}%
  \expandafter\x
    \csname \romannumeral\the\count@ pt\expandafter\endcsname
    \csname @\romannumeral\the\count@ pt\endcsname
  \csname #3\endcsname}%
\fi
\fi\endgroup
\begin{picture}(6099,6255)(1789,-6973)
\thicklines
\put(1801,-6961){\framebox(6075,6000){}}
\put(2476,-6361){\framebox(4800,4800){}}
\put(2176,-886){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{bf}B}}}
\put(2551,-1486){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{bf}A}}}
\end{picture}
\end{center}
\centerline{Figure 3}

First, note that  shapes
intersecting $A$ but having
their apexes outside $B$ cover very little of $A$. Indeed, by
Lemma \ref{l1}, I all their
 apexes lie in a square of $(c_2 +c_1)\sqrt n \log n \times
 (c_2+c_1) \sqrt n \log n$, hence there are only $(2c_2+c_1)^2
\cdot \log^2 n$ of
them, as they are
pairwise disjoint, the area of each of them is $n$,
and they all lie completely in a square of side length
$(2c_2+c_1)\sqrt n \log n$.
By Lemma \ref{l1}, II, each of them covers at most an area
$n^{1-\delta}$ in $A$, and hence their total contribution is
at most $O(n^{1-\delta} \log^2 n) < O(n)$.

Now consider the shapes whose apexes lie in $B$. Let
$F_1,F_2$ be two such shapes, let $(x_1,y_1)$
be the apex of $F_1$, and
 let $(x_2,y_2)$
be the apex of $F_2$,and suppose $x_1 \leq x_2$. Then by Lemma \ref{l1},I,
$y_2$ cannot satisfy $y_2 \leq y_1$ as otherwise the shapes $F_1$ and
$F_2$ would intersect.
Therefore, $y_2\geq y_1$ must hold.
 It follows that if we sort these shapes according to their increasing
$x$ coordinates, the order we
obtain is also an increasing order of their $y$ coordinates. Moreover, by
Lemma \ref{l1}, III it follows
that $x_2+y_2 \geq x_1+y_1+c_3\sqrt n$, and a similar inequality holds
for each consecutive pair of
shapes with apexes in $B$ in the above sorted order.
Hence, if $(x_i,y_i)$ is the apex of shape number $i$ in this
order,
$x_i+y_i\geq x_1+y_1+ (i-1) c_3\sqrt n$. Thus the total number of
apexes in $B$ is at most $2 c_1\log n/c_3+1$, and therefore the
total area of $A$ covered is not more than
$\gamma n \log n$, for, say  $\gamma=3c_1/c_3$, completing the proof
of the lemma.
\end{proof}

Theorem \ref{t1} is an immediate consequence of
Lemma \ref{l2}, as one can essentially tile the $n$ by $p(n)$ rectangle
with squares of side length $0.8 c_1 \sqrt n \log n$.
It is not difficult to  see that the assertion of the theorem is
tight, up to the multiplicative constant $c$. Indeed, one can first omit
all shapes violating the condition in Lemma \ref{l1}, I, and then pack
the shapes along diagonals, where the apex of each shape touches
the furthest point on the main diagonal of the previous shape.

\begin{center}
\setlength{\unitlength}{0.00033300in}%
\begingroup\makeatletter\ifx\SetFigFont\undefined
\def\x#1#2#3#4#5#6#7\relax{\def\x{#1#2#3#4#5#6}}%
\expandafter\x\fmtname xxxxxx\relax \def\y{splain}%
\ifx\x\y
\gdef\SetFigFont#1#2#3{%
  \ifnum #1<17\tiny\else \ifnum #1<20\small\else
  \ifnum #1<24\normalsize\else \ifnum #1<29\large\else
  \ifnum #1<34\Large\else \ifnum #1<41\LARGE\else
     \huge\fi\fi\fi\fi\fi\fi
  \csname #3\endcsname}%
\else
\gdef\SetFigFont#1#2#3{\begingroup
  \count@#1\relax \ifnum 25<\count@\count@25\fi
  \def\x{\endgroup\@setsize\SetFigFont{#2pt}}%
  \expandafter\x
    \csname \romannumeral\the\count@ pt\expandafter\endcsname
    \csname @\romannumeral\the\count@ pt\endcsname
  \csname #3\endcsname}%
\fi
\fi\endgroup
\begin{picture}(7299,6549)(2464,-7273)
\thicklines
\put(2476,-736){\line( 0,-1){2400}}
\put(2476,-3136){\line( 1, 0){225}}
\put(2701,-3136){\line( 0, 1){1200}}
\put(2701,-1936){\line( 1, 0){225}}
\put(2926,-1936){\line( 0, 1){825}}
\put(2926,-1111){\line( 1, 0){675}}
\put(3601,-1111){\line( 0, 1){150}}
\put(3601,-961){\line( 1, 0){1200}}
\put(4801,-961){\line( 0, 1){225}}
\put(4801,-736){\line(-1, 0){2325}}
\put(2476,-736){\line( 0, 1){  0}}
\put(2926,-1111){\line( 0,-1){2400}}
\put(2926,-3511){\line( 1, 0){225}}
\put(3151,-3511){\line( 0, 1){1200}}
\put(3151,-2311){\line( 1, 0){225}}
\put(3376,-2311){\line( 0, 1){825}}
\put(3376,-1486){\line( 1, 0){675}}
\put(4051,-1486){\line( 0, 1){150}}
\put(4051,-1336){\line( 1, 0){1200}}
\put(5251,-1336){\line( 0, 1){225}}
\put(5251,-1111){\line(-1, 0){2325}}
\put(2926,-1111){\line( 0, 1){  0}}
\put(3376,-1486){\line( 0,-1){2400}}
\put(3376,-3886){\line( 1, 0){225}}
\put(3601,-3886){\line( 0, 1){1200}}
\put(3601,-2686){\line( 1, 0){225}}
\put(3826,-2686){\line( 0, 1){825}}
\put(3826,-1861){\line( 1, 0){675}}
\put(4501,-1861){\line( 0, 1){150}}
\put(4501,-1711){\line( 1, 0){1200}}
\put(5701,-1711){\line( 0, 1){225}}
\put(5701,-1486){\line(-1, 0){2325}}
\put(3376,-1486){\line( 0, 1){  0}}
\put(3826,-1861){\line( 0,-1){2400}}
\put(3826,-4261){\line( 1, 0){225}}
\put(4051,-4261){\line( 0, 1){1200}}
\put(4051,-3061){\line( 1, 0){225}}
\put(4276,-3061){\line( 0, 1){825}}
\put(4276,-2236){\line( 1, 0){675}}
\put(4951,-2236){\line( 0, 1){150}}
\put(4951,-2086){\line( 1, 0){1200}}
\put(6151,-2086){\line( 0, 1){225}}
\put(6151,-1861){\line(-1, 0){2325}}
\put(3826,-1861){\line( 0, 1){  0}}
\put(4276,-2236){\line( 0,-1){2400}}
\put(4276,-4636){\line( 1, 0){225}}
\put(4501,-4636){\line( 0, 1){1200}}
\put(4501,-3436){\line( 1, 0){225}}
\put(4726,-3436){\line( 0, 1){825}}
\put(4726,-2611){\line( 1, 0){675}}
\put(5401,-2611){\line( 0, 1){150}}
\put(5401,-2461){\line( 1, 0){1200}}
\put(6601,-2461){\line( 0, 1){225}}
\put(6601,-2236){\line(-1, 0){2325}}
\put(4276,-2236){\line( 0, 1){  0}}
\put(4726,-2611){\line( 0,-1){2400}}
\put(4726,-5011){\line( 1, 0){225}}
\put(4951,-5011){\line( 0, 1){1200}}
\put(4951,-3811){\line( 1, 0){225}}
\put(5176,-3811){\line( 0, 1){825}}
\put(5176,-2986){\line( 1, 0){675}}
\put(5851,-2986){\line( 0, 1){150}}
\put(5851,-2836){\line( 1, 0){1200}}
\put(7051,-2836){\line( 0, 1){225}}
\put(7051,-2611){\line(-1, 0){2325}}
\put(4726,-2611){\line( 0, 1){  0}}
\put(5176,-2986){\line( 0,-1){2400}}
\put(5176,-5386){\line( 1, 0){225}}
\put(5401,-5386){\line( 0, 1){1200}}
\put(5401,-4186){\line( 1, 0){225}}
\put(5626,-4186){\line( 0, 1){825}}
\put(5626,-3361){\line( 1, 0){675}}
\put(6301,-3361){\line( 0, 1){150}}
\put(6301,-3211){\line( 1, 0){1200}}
\put(7501,-3211){\line( 0, 1){225}}
\put(7501,-2986){\line(-1, 0){2325}}
\put(5176,-2986){\line( 0, 1){  0}}
\put(5626,-3361){\line( 0,-1){2400}}
\put(5626,-5761){\line( 1, 0){225}}
\put(5851,-5761){\line( 0, 1){1200}}
\put(5851,-4561){\line( 1, 0){225}}
\put(6076,-4561){\line( 0, 1){825}}
\put(6076,-3736){\line( 1, 0){675}}
\put(6751,-3736){\line( 0, 1){150}}
\put(6751,-3586){\line( 1, 0){1200}}
\put(7951,-3586){\line( 0, 1){225}}
\put(7951,-3361){\line(-1, 0){2325}}
\put(5626,-3361){\line( 0, 1){  0}}
\put(6076,-3736){\line( 0,-1){2400}}
\put(6076,-6136){\line( 1, 0){225}}
\put(6301,-6136){\line( 0, 1){1200}}
\put(6301,-4936){\line( 1, 0){225}}
\put(6526,-4936){\line( 0, 1){825}}
\put(6526,-4111){\line( 1, 0){675}}
\put(7201,-4111){\line( 0, 1){150}}
\put(7201,-3961){\line( 1, 0){1200}}
\put(8401,-3961){\line( 0, 1){225}}
\put(8401,-3736){\line(-1, 0){2325}}
\put(6076,-3736){\line( 0, 1){  0}}
\put(6526,-4111){\line( 0,-1){2400}}
\put(6526,-6511){\line( 1, 0){225}}
\put(6751,-6511){\line( 0, 1){1200}}
\put(6751,-5311){\line( 1, 0){225}}
\put(6976,-5311){\line( 0, 1){825}}
\put(6976,-4486){\line( 1, 0){675}}
\put(7651,-4486){\line( 0, 1){150}}
\put(7651,-4336){\line( 1, 0){1200}}
\put(8851,-4336){\line( 0, 1){225}}
\put(8851,-4111){\line(-1, 0){2325}}
\put(6526,-4111){\line( 0, 1){  0}}
\put(6976,-4486){\line( 0,-1){2400}}
\put(6976,-6886){\line( 1, 0){225}}
\put(7201,-6886){\line( 0, 1){1200}}
\put(7201,-5686){\line( 1, 0){225}}
\put(7426,-5686){\line( 0, 1){825}}
\put(7426,-4861){\line( 1, 0){675}}
\put(8101,-4861){\line( 0, 1){150}}
\put(8101,-4711){\line( 1, 0){1200}}
\put(9301,-4711){\line( 0, 1){225}}
\put(9301,-4486){\line(-1, 0){2325}}
\put(6976,-4486){\line( 0, 1){  0}}
\put(7426,-4861){\line( 0,-1){2400}}
\put(7426,-7261){\line( 1, 0){225}}
\put(7651,-7261){\line( 0, 1){1200}}
\put(7651,-6061){\line( 1, 0){225}}
\put(7876,-6061){\line( 0, 1){825}}
\put(7876,-5236){\line( 1, 0){675}}
\put(8551,-5236){\line( 0, 1){150}}
\put(8551,-5086){\line( 1, 0){1200}}
\put(9751,-5086){\line( 0, 1){225}}
\put(9751,-4861){\line(-1, 0){2325}}
\put(7426,-4861){\line( 0, 1){  0}}
\put(2476,-3136){\line( 6,-5){4950}}
\put(4801,-736){\line( 6,-5){4950}}
\put(2476,-7261){\framebox(7275,6525){}}
\put(2476,-5686){\line( 6,-5){1836.885}}
\put(7801,-736){\line( 5,-4){1957.317}}
\end{picture}
\end{center}
\centerline{Figure 4: An optimal tiling}

Packing Ferrers Shapes