marking vertex as visited