Given a directed graph, what is an algorithm I can use to find a random subset of its edges so that every node has exactly one incoming and exactly one outgoing edge?
For example, this could be the graph I am given:

And this would be a valid output graph:

This is valid because:
If there is no possible solution that should be detected.
Is there an efficient algorithm to solve this?
Thanks!
It's a node cycles coverage problem. It can be solved as Maximum matchings in bipartite graphs.
In short:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With