4. Given a positive integer $n(n \geqslant 3)$. Label each side and each diagonal of the regular $n$-gon $P_{1} P_{2} \cdots P_{n}$ with a positive integer not exceeding $r$, and satisfy:
(1) Each positive integer $1,2, \cdots, r$ appears in the labels of the sides or diagonals;
(2) In each $\triangle P_{i} P_{j} P_{k}$, two sides are labeled with the same number, and this number is greater than the number on the third side.
Find: (1) The maximum positive integer $r$ that satisfies the above conditions;
(2) For this maximum value of $r$, how many labeling methods satisfy the above conditions?
4. A labeling that satisfies condition (2) is called "good", and a labeling that satisfies both conditions (1) and (2) is called "very good". The diagonals and sides of the polygon are collectively referred to as edges, and the numbers labeled on the edges are called the distances between two points.

Let the edge labeled with the maximum value $r$ be $A B$, and $C$ be a vertex different from $A$ and $B$.

By condition (2), one of $A C$ and $B C$ is labeled with $r$, and the other is labeled with a number less than $r$. Therefore, all vertices can be divided into two groups: the first group includes vertices whose distance to point $A$ is $r$ (point $B$ is in this group), and the second group includes vertices whose distance to point $B$ is $r$ (point $A$ is in this group).

Let $X$ be a vertex in the first group different from point $B$, and $Y$ be a vertex in the second group different from point $A$. In $\triangle A X Y$, since $A Y$ is not labeled with $r$ and $A X$ is labeled with $r$, $X Y$ is labeled with $r$, i.e., the edges connecting any vertex in the first group to any vertex in the second group are all labeled with $r$.

If $X$ and $Y$ are any two points in the first group, in $\triangle A X Y$, since $A X$ and $A Y$ are labeled with $r$, $X Y$ is labeled with a number less than $r$.

Similarly, the edges connecting any two points in the second group are all labeled with a number less than $r$.

A good labeling should meet the following requirements: the edges connecting any vertex in the first group to any vertex in the second group are labeled with the maximum value $r$, and the labeling within each group is a good labeling, and the numbers labeled on each edge are less than $r$.
(1) Use mathematical induction to prove: the maximum value of $r$ is $n-1$.
When $n=3$, it is easy to see that $r=2$, and the conclusion holds.
Assume the conclusion holds for integers less than $n (n>3)$.
For an $n$-sided polygon $P$, divide the vertices into two groups, and assume the first group has $k$ vertices, and the second group has $n-k$ vertices. By the induction hypothesis, the $k$ vertices in the first group form a $k$-sided polygon $P_{1}$, and the numbers labeled on each edge are at most $k-1$ (not necessarily from 1 to $k-1$).

Similarly, the $n-k$ vertices in the second group form an $(n-k)$-sided polygon $P_{2}$, and the numbers labeled on each edge are at most $n-k-1$ (not necessarily from 1 to $n-k-1$). The edges connecting the vertices in the first group to the vertices in the second group are all labeled with the same number, which is the maximum value, so there are at most
$$
(k-1) + (n-k-1) + 1 = n-1
$$
different numbers. For example, if an $(n-1)$-sided polygon has a very good labeling, the maximum value of $r$ is $n-2$, then labeling the edges connecting the $n$-th vertex to each vertex of the $(n-1)$-sided polygon with $n-1$ is a very good labeling that meets the conditions.
(2) Let $f(n)$ be the number of very good labelings of an $n$-sided polygon $P$ using $1, 2, \cdots, n-1$ to label each edge.
The following uses mathematical induction to prove: $f(n) = \frac{n!(n-1)!}{2^{n-1}}$. When $n=3$, $f(3)=3$, and the conclusion holds.
Assume for $k < n$, $f(k) = \frac{k!(k-1)!}{2^{k-1}}$.
For an $n$-sided polygon $P$, divide the $n$ vertices into two non-empty groups, the first group has $k$ vertices, and there are $\mathrm{C}_{n}^{k}$ ways to divide. Each vertex in the first group must be connected to each vertex in the second group with an edge labeled $n-1$, then select $k-1$ numbers from $1, 2, \cdots, n-2$ to label the edges of the $k$-sided polygon $P_{1}$ formed by the vertices in the first group, and there are $\mathrm{C}_{n-2}^{k-1}$ ways to select. The remaining $n-k-1$ numbers are used to label the edges of the $(n-k)$-sided polygon $P_{2}$ formed by the vertices in the second group, and $P_{1}$ has $f(k)$ very good labelings, and $P_{2}$ has $f(n-k)$ very good labelings. Since selecting $k$ vertices as the first group is equivalent to selecting the remaining $n-k$ vertices as the first group, each very good labeling is counted twice. Therefore,
$$
\begin{array}{l}
f(n) = \frac{1}{2} \sum_{k=1}^{n-1} \mathrm{C}_{n}^{k} \mathrm{C}_{n-2}^{k-1} f(k) f(n-k) \\
= \frac{n!(n-1)!}{2(n-1)} \sum_{k=1}^{n-1} \frac{f(k)}{k!(k-1)!} \cdot \frac{f(n-k)}{(n-k)!(n-k-1)!} \\
= \frac{n!(n-1)!}{2(n-1)} \sum_{k=1}^{n-1} \frac{1}{2^{k-1}} \cdot \frac{1}{2^{n-k-1}} = \frac{n!(n-1)!}{2^{n-1}}. \\
\end{array}
$$

In summary, $f(n) = \frac{n!(n-1)!}{2^{n-1}}$.