We can think of this problem as a graph theory problem. The $n \times n$ matrix $A$ is the adjacency matrix of:
- an undirected graph $G$,
- with no self-loops,
- but allowing either single or double edges,
- and where each vertex has odd degree.
Our goal is to orient every edge of $G$ so that the resulting digraph $G'$ satisfies $|d_{\mathrm{in}}(v) - d_{\mathrm{out}}(v)| = 1$ for all vertices $v$. To make the matrix skew-symmetric, exactly one of $A_{ij}$ and $A_{ji}$ must be negative, which corresponds to choosing one of the orientations of the edge. The row sums of the final matrix $B$ are precisely the above in-degree/out-degree condition.
In general, this is an easy problem to solve (see, e.g., this question) but we have a further restriction: whenever we have a double edge, it must be ordered consistently. So we'll proceed differently here.
To orient $G$, we repeat a process of orienting and removing paths (not necessarily simple paths). To make the proof simpler, we'll classify the vertices into three types:
- Dangerous, if it is incident to an odd number of double edges and an odd number of single edges.
- Terminating, if it is incident to an even number of double edges, but an odd number of single edges.
- Safe, if it is incident to an even number of double edges and an even number of single edges.
The fourth case is a type of vertex we will never have in the graph. Initially, all vertices are either dangerous or terminating.
To pick a path to orient and remove, start with an arbitrary edge and extend it from either endpoint by the following rules:
- If we're at a dangerous vertex, make sure the path takes exactly one double edge: if we enter on a single edge, leave on a double edge, and vice versa. Removing the edges we took will make the dangerous vertex safe.
- If we're at a safe vertex, keep going along the same edge type. Removing the edges we took will keep the safe vertex safe.
- If we enter a terminating vertex along a double edge, keep going along a double edge. Removing the edges we took will keep the vertex terminating.
- If we enter a terminating vertex along a single edge, end the path there. Removing the one edge we took will make the terminating vertex safe.
Another thing that might happen is that in extending the path, both our endpoints are at the same vertex. In that case:
- If the two edges we took to get to that vertex are compatible with the rules above, stop there. The path we remove will actually be a cycle, but this changes nothing.
- If not, then keep extending the path first from one endpoint (which might change the vertex type) then the other, and ignore the self-intersection.
Once we can no longer extend the path further, we pick a direction along the path, orient all edges following that direction, and then remove them from consideration, since they've already been oriented. You can check that the statements in italics above will hold when we do this.
Also note that when we make a dangerous or terminating vertex safe, its value of $d_{\mathrm{in}} - d_{\mathrm{out}}$ is changed to $\pm 1$ among the oriented edges. In all other cases, the oriented edges coming in match the oriented edges coming out, and $d_{\mathrm{in}} - d_{\mathrm{out}}$ does not change.
As long as we have dangerous or terminating vertices in our graph, we must have edges, by parity. So when this algorithm terminates because there are no edges left, all the vertices have been made safe. This means that their total oriented degree satisfies $|d_{\mathrm{in}}(v) - d_{\mathrm{out}}(v)| = 1$, and we have found the desired orientation (or skew-symmetric matrix).