You have $N$ wires that all extend from one location to a second distant location. The wire ends at both locations are unlabeled, and the goal is to label them all (on both ends) with distinct labels $1,2,\ldots, N$ so that the two ends of the same wire have the same label for every wire. I.e., the goal is to match every pair of wire ends.
The operations you can perform (on either end) are as follows: You can tie or untie any subset of wires together, and you can use a connectivity detector to tell if two wires are tied together on the other end. While on one of the two locations of wire ends, you can tie, untie, and test connectivity as much as you want. However, the goal is to minimize the number of trips between the two locations so that you can guarantee that you can label all the wire ends.
It seems like perhaps considering the case of even $N$ and odd $N$ separately may be a good idea, but still, is there an easy-to-describe strategy to minimize the number of trips? And prove the solution is optimal? If it helps, especially to prove optimality, we might assume that you only tie/untie wires at the starting location, and only test connectivity at the second location.
For $N=1$ You need no trips. For $N=2$ the operations are not enough to solve the problem in any way. For $N\geq3$, at least two one-way trips are necessary, because in the first trip, you can't distinguish a wire from the one(s) connected to it without separating them later. It can be shown that two one-way trips are sufficient to identify all the wire ends (but if you really need to "label" the wire ends, it's sufficient to travel once more, similar to $N=1$. It's easy to see that this "extra" trip is necessary too).
Let's first assume that $N$ is odd. Label the wires $1$ to $N$ at the first location. tie together wires in pairs: $(2,3),(4,5),\dots$. Travel to the other side. Determine all the pairs (call them twins) and identify wire $1$. Tie wire $1$ and another wire (call it $a$) together, Tie $a$'s twin and another wire (call it $b$) together, Tie $b$'s twin and another wire together, and so on. Travel back and separate the tied pairs. Check which wire is connected to wire $1$, that would be $a$; Then $a$'s twin is identified and $b$ will be the one connected to it, and so on.
Now assume that $N$ is even. Tie together wires in pairs: $(2,3),(4,5),\dots$, so wires $1$ and $N$ are not connected to any other wire. Travel to the other side. Determine all pairs and the two lonely ones. Let one of the lonely ones alone again and use the other one in the same way as the odd case. Travel back and identify the wire that was alone in both trips, and then identify the other wires similar to the odd case.