create networkx matrix