networkx/networkx — pull request #1081 by lamda (2014-03-20 15:44:01+00:00)
Title: Bug fix for the fast_gnp_random_graph() random graph generator

This fixes a bug in generators/random_graphs.py for the fast_gnp_random_graph() generator. This generator is a fast version of Erdős-Rényi graphs based on the pseudocode in [1]. However, for directed graphs this never generated edges adjacent to the first network node (index 0). A simple adaption of line 90 suffices to change this. I changed
v = 1
to
v = 0.

This has no influence on the undirected graph generator, where the first loop iteration will then simply increase 0 to 1. For the directed version, this allows for the possibility to attach edges to the first node (index 0).

I've also incorporated a probabilistic test case for this, as well as refactored the test cases and made some PEP 8 whitespace changes.

[1] Vladimir Batagelj and Ulrik Brandes, "Efficient generation of large random networks", Phys. Rev. E, 71, 036113, 2005.