Utility function to look up degree of a node. This is inefficient (O(|E|)).

This is inefficient (O(|E|) for each node) and could be replaced by
storing the degree when we first build the edge list.