Remove dependency on NetworkX.