removed an unnecessary list construction (at the cost of making the code slightly unsafe)
simplified Count by using itertools.groupby
fixed bug where edges in Graph are not properly reversed