Okay, so I managed to fix the issue with the help of @5DN1L (thanks a lot!). It turns out that, at least with the algorithm I had, the order of the input of edges changed the output of the algorithm for reasons I am still not entirely sure of.
My algorithm worked like this:
When the agent is not on a vertex next to a gateway – if it’s next to a gateway then the edge linking them would have to be cut, obviously – my algorithm would look at all of the vertices with more than one gateway. If there is only one than its edges take priority, because if the agent reaches that vertex, it’s game over. For the case with more than one such vertex, BFS was used to determine the shortest path for each of them (you could use Dijkstra but there’s really no point since the graph is unweighted). My algorithm then used the # of vertices that aren’t attached in a gateway (“free” vertices) to determine which of the shortest paths was the most “dangerous” (the lower the # the more edges are attached to gateways, thus forcing more moves and making the path more “dangerous”).
For one of the validators a peculiar bug appeared, dependent on the ordering of the edges, as mentioned above. As shown in a post above, the test case worked, but the validation of it didn’t. I found it strange, because the shapes of both graphs were identical, just with the vertices relabelled; no part of my solution was hard-coded, either. This was especially weird when I put the graph into my IDE and it picked the correct first edge to sever, whereas with the validator case it didn’t.
It turns out that the validation case turned was one of ~5% of cases where the edges of that graph inserted in a particular order caused my algorithm to pick the incorrect first edge to cut. This was because for those cases, one of the shortest paths went through a gateway, causing the # of “free” vertices of that path to go above that of the other one (gateways aren’t connected to other gateways, so it would count as a free vertex). My algorithm would thus determine that the path to the other vertex with multiple gateways was more dangerous, and cut one of the edges of that vertex instead.
The solution to such a seemingly perplexing issue was, when building the path, to check if the next vertex of the path was a gateway. This fixed the bug I experienced, which in the end, turned out to be caused by an oversight in the pathfinding algorithm I had not considered before. I suspect that this might be the issue for some of the other people who posted on this thread about failing the validation checks.
Moral of the story: if it seems like something is wrong with the validator, it might just be a hidden bug in your code that you overlooked. Just debug (print the output of various parts your program to see if something is going wrong) and test until you fix it.