fixed bug in handling adjacency graph [to be improved]