Added stack functionlaity to graphs