manual implementation of networkx functionality through custom graphs.