Improve many-to-one by using reversed graph.

Instead of doing a one-to-one from every source, just do a one-to-many
from the target to all the sources, reversing the graph in the case of
directed graphs.