def countEdges(halfEdge):
    """Given a half-edge of a polygon, count the number of edges in this polygon."""
    numberOfEdges=1
    startingEdge=halfEdge
    edge=startingEdge.next

    while edge is not startingEdge:
        edge=edge.next
        numberOfEdges+=1 

    return numberOfEdges