finding degree of  a graph