First build graph (as adjacency list) from the input data. To apply Hierholzer's algorithm , (1) start from any vertex v and follow a trail of edges until returning to v. The tour formed a closed tour. (2) If there is a vertex u that belongs to the current tour, but that has adjacent edges not part of the tour, start another trail from u, following unused edges until returning to u. (3) keep following unused edges and removing them when we get stuck. When stuck, backtrack to the nearest vertex in the current path that has unused edges. Repeat the process until all the edges have been used.