Preferential attachment algorithm via NetworkX