Let $P_n$ be a path with $n$ vertices. My question is as the title says: Determine all graphs that contain $P_4$ but not $P_5$.
The question is derived from the first exercise on page 115 of a book titled "Distances in Graphs" by Buckley and Harary, published in 1990.
I don't have any concrete ideas at the moment. The only thing I can come up with is that the diameters of these graphs are at most 3. However, there seem to be many graphs falling into this category.
The original text's "contain," I speculate, refers to including subgraphs rather than induced subgraphs. If changed to "contain induced subgraphs" as Mathieu Rundström and user14111 suggested, I think this question also intriguing. However, I cannot estimate the difficulty level.
It seems to me that connected graphs with this property can be given by three parameters $m\geq n>k\geq0$.
Let $u,u_1,\ldots,u_m,v,v_1,\ldots,v_n$ be pairwise different. Let $S_m(u)=\{u,u_1,\ldots,u_m\}$ and $S_n(v)=\{v,v_1,\ldots,v_n\}$ be stars with centres at $u$ and $v$, respectively. Let $G=S_m(u)\cup S_n(v)$ be supplemented with edges $uv$, $u_iv_i$, $i=1,\ldots,k$. The graph $G$ contains $P_4$ and does not contain $P_5$. The converse is also true.