Uses numpy matrices and networkx graphs.