// if there are more than 2 edges here, make sure to compare all
li = group["geometry"].tolist()
li.append(li[0])
geom_pairs = list(zip(li[:-1], li[1:]))
else:
// otherwise, just compare the first edge to the second edge
geom_pairs = [(group["geometry"].iloc[0], group["geometry"].iloc[1])]
After Change
set_different_streets = set(different_streets)
utils.log(f"Found {len(set_different_streets)} different streets")
for u, v, k in set(different_streets):
new_key = max(list(G[u][v]) + list(G[v][u])) + 1
G.add_edge(u, v, key=new_key, **G.get_edge_data(u, v, k))
G.remove_edge(u, v, key=k)
return G