'Return the valency (degree) of a vertex in the graph.'

def valency_of(self, obj):

    try:
        l = [len(self[obj])]
    except KeyError:
        return 0
    for node in self[obj]:
        l.append(self.valency_of(node))
    return sum(l)
