Modified the grapg layout and fixed a bug in the sweep phase