networkx/networkx — pull request #1156 by chebee7i (2014-05-12 19:17:59+00:00)
Title: Add context manager for reversing a graph.

This PR adds a `reversed` context manager. It is not imported in the primary NetworkX namespace, but it is available at `networkx.utils`. The construct can be helpful when one needs to temporarily reverse the edges of a graph. The context manager aspect guarantees that the graph is restored even in the event of an exception. It is no-op for undirected graphs, as this simplifies code. I think it makes more sense to have `copy=False` as the default, but I kept it consistent with `networkx.reverse`.