Add support for backedges.

This patch adds support for explicit backedges in PGM graphs.
Add test case for backedges.