graph should be ordered for consistency