Workaround for networkx bug with empty graphs.