Affinity graph with Python and NetworkX