Write pickRandomEdge and calculateNumberOfEdges