Cycles · Eulerian Graphs
Lesson 6
Problem. A snowplow must traverse all streets of a rectangular district of size \(5 \times 5\) and return to the starting position. What is the minimum distance it must travel? Try it!

Hint:
For the curious 🤓
import networkx as nx
grid = nx.MultiGraph(nx.grid_2d_graph(m=6, n=6))
grid = nx.eulerize(grid)
print(nx.number_of_edges(grid))
cycle = nx.eulerian_circuit(grid, source=(0, 0))
print('→'.join(str(edge[0]) for edge in cycle))68
(0, 0)→(0, 1)→(0, 2)→(0, 3)→(0, 4)→(0, 5)→(1, 5)→(2, 5)→(3, 5)→
(4, 5)→(5, 5)→(5, 4)→(5, 3)→(5, 4)→(4, 4)→(4, 5)→(3, 5)→(3, 4)→
(4, 4)→(4, 3)→(5, 3)→(5, 2)→(5, 1)→(5, 2)→(4, 2)→(4, 3)→(3, 3)→
(3, 4)→(2, 4)→(2, 5)→(1, 5)→(1, 4)→(2, 4)→(2, 3)→(3, 3)→(3, 2)→
(4, 2)→(4, 1)→(5, 1)→(5, 0)→(4, 0)→(4, 1)→(3, 1)→(3, 2)→(2, 2)→
(2, 3)→(1, 3)→(1, 4)→(0, 4)→(0, 3)→(1, 3)→(1, 2)→(2, 2)→(2, 1)→
(3, 1)→(3, 0)→(4, 0)→(3, 0)→(2, 0)→(2, 1)→(1, 1)→(1, 2)→(0, 2)→
(0, 1)→(1, 1)→(1, 0)→(2, 0)→(1, 0)