Skip to content

Commit c22e442

Browse files
committed
let networkx deal with keys in multigraphs
1 parent 03e84c7 commit c22e442

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

momepy/utils.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,19 @@ def _generate_primal(graph, gdf_network, fields, multigraph, oneway_column=None)
7171
stacklevel=3,
7272
)
7373

74-
key = 0
7574
for row in gdf_network.itertuples():
7675
first = row.geometry.coords[0]
7776
last = row.geometry.coords[-1]
7877

7978
data = list(row)[1:]
8079
attributes = dict(zip(fields, data, strict=True))
8180
if multigraph:
82-
graph.add_edge(first, last, key=key, **attributes)
83-
key += 1
81+
graph.add_edge(first, last, **attributes)
8482

8583
if oneway_column:
8684
oneway = bool(getattr(row, oneway_column))
8785
if not oneway:
88-
graph.add_edge(last, first, key=key, **attributes)
89-
key += 1
86+
graph.add_edge(last, first, **attributes)
9087
else:
9188
graph.add_edge(first, last, **attributes)
9289

0 commit comments

Comments
 (0)