sympy/sympy — pull request #1531 by scolobb (2012-09-14 21:59:04+00:00)
Title: Correct and improve the sympy.categories.Diagram class.

The pull request corrects two fundamental flaws of the original implementation of `Diagram`:

* the old `Diagram` gets split into `Diagram` and `Implication`, which reflects correctly the two different notions of a commutative diagram and commutative implication (see the code or comments for explanations);

* the old `Diagram` could not store infinite diagrams (diagrams with cycles and loops) correctly; the new `Diagram` can handle this task properly.

This pull request also adds a bunch of useful `Diagram` analysis tools from the point of view of graph theory, which includes the freshly-coined notion of expanded generators as well as the condensation of a directed multigraph. The comments in the code will hopefully be able to get the reader started with this notion.

While initially I thought that I would need the condensation of a `Diagram`, it turned out later that this was not the case. On the other hand, the notion of expanded generators, however unusual it may seem, is definitely crucial in the case of infinite diagrams, because looking at the (finite) set of expanded generators is in most cases enough to nicely handle diagrams with cycles and loops without thinking too much about the (potentially infinite) set of all morphisms.