Creating networks in Python