Skip to content

Commit

Permalink
introduced sorting by 'result'
Browse files Browse the repository at this point in the history
  • Loading branch information
cnavacch committed Oct 29, 2020
1 parent 9f9db5c commit 1cb43cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/openeo_pg_parser/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,10 @@ def sort(self, by='dependency'):
----------
by : str
Sorting strategy:
- 'dependency': Sorts graph by each node dependency,
- 'dependency': Sorts graph by each processing dependency,
i.e., nodes being dependent on another node come after this node.
- 'result': Sorts the graph also by processing dependency, but this time it puts the node order
following the result data flow.
- 'depth': Sorts graph by the depth level of the nodes, from lower to higher depth.
Returns
Expand All @@ -607,6 +609,10 @@ def sort(self, by='dependency'):
# use internal algo and igraph for topological sorting
ordered_node_ids = self._linear_sorting()
nodes_ordered = [self[ordered_node_id] for ordered_node_id in ordered_node_ids]
elif by == "result":
# use internal algo and igraph for topological sorting
ordered_node_ids = self._linear_sorting(use_in_nodes=False)
nodes_ordered = [self[ordered_node_id] for ordered_node_id in ordered_node_ids]
elif by == "depth":
depths = [node.depth for node in self.nodes]
node_order = np.argsort(depths)
Expand Down

0 comments on commit 1cb43cc

Please sign in to comment.