Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions fixbikenet/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ def gap_declustering(gaps_df, G, ebc, contact_nodes):
]
selected_paths = []
selected_scores = []
selected_names = []

for comp in tqdm(
components,
Expand Down Expand Up @@ -741,10 +742,24 @@ def gap_declustering(gaps_df, G, ebc, contact_nodes):
best_path = path
if best_path is None:
break

# Store selected gap
selected_paths.append(best_path)
selected_scores.append(best_score)

# Walk through edges until finding a name
name = "n/a"
for i in [-1]+list(range(len(best_path))):
try:
name = G[best_path[i]][best_path[i+1]]['name']
except:
pass
if name != "" and name != "n/a":
break
if name == "":
name = "n/a"
selected_names.append(name)

# Remove selected path
edge_path = list(
zip(best_path[:-1], best_path[1:])
Expand All @@ -757,6 +772,7 @@ def gap_declustering(gaps_df, G, ebc, contact_nodes):
{
"path": selected_paths,
"benefit": selected_scores,
"name": selected_names
}
)
return result
Expand Down
Loading