Remove networkx dependency