fixed graph swapping bug