Count each node's connections
Write degrees(edges) that, for a two-way graph given as a list of (a, b) pairs,
returns a dictionary from each node to how many edges touch it.
degrees([("A", "B"), ("A", "C"), ("B", "C"), ("C", "D")]) -> {"A": 2, "B": 2, "C": 3, "D": 1}
degrees([]) -> {}
The point is to practise reading an edge list with a Counter.
def degrees(edges):
...