Skip to content

Commit

Permalink
_generate_segments: return list of arrays in vanilla implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Jan 5, 2025
1 parent 65e7893 commit be82d6d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions navis/graph/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,17 @@ def _generate_segments(
lengths = [d[s[0]] - d[s[-1]] for s in sequences]
sequences = [x for _, x in sorted(zip(lengths, sequences), reverse=True)]

# Turn into list of arrays
sequences = [np.array(s) for s in sequences]

# Isolated nodes would not be included in the sequences(because they are treated
# as roots, not leafs. Let's add them manually here.
for node in nx.isolates(x.graph):
sequences.append([node])
sequences.append(np.array([node]))
lengths.append(0)

if return_lengths:
return sequences, sorted(lengths, reverse=True)
return sequences, np.array(sorted(lengths, reverse=True))
else:
return sequences

Expand Down

0 comments on commit be82d6d

Please sign in to comment.