mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-04-05 12:48:09 +08:00
Ensure outgoing edge map is sorted by upstream label
This commit is contained in:
parent
19f316e9c5
commit
926295449a
@ -2,7 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from ._utils import get_hash, get_hash_int
|
||||
from builtins import object
|
||||
from collections import namedtuple
|
||||
from collections import namedtuple, OrderedDict
|
||||
|
||||
|
||||
class DagNode(object):
|
||||
@ -157,7 +157,7 @@ def topo_sort(downstream_nodes):
|
||||
raise RuntimeError('Graph is not a DAG')
|
||||
|
||||
if downstream_node is not None:
|
||||
outgoing_edge_map = outgoing_edge_maps.get(upstream_node, {})
|
||||
outgoing_edge_map = outgoing_edge_maps.get(upstream_node, OrderedDict())
|
||||
outgoing_edge_infos = outgoing_edge_map.get(upstream_label, [])
|
||||
outgoing_edge_infos += [(downstream_node, downstream_label)]
|
||||
outgoing_edge_map[upstream_label] = outgoing_edge_infos
|
||||
@ -174,4 +174,10 @@ def topo_sort(downstream_nodes):
|
||||
while unmarked_nodes:
|
||||
upstream_node, upstream_label = unmarked_nodes.pop()
|
||||
visit(upstream_node, upstream_label, None, None)
|
||||
|
||||
# Sort outgoing edge maps by upstream label
|
||||
for map in outgoing_edge_maps.values():
|
||||
for label in sorted(map.keys()):
|
||||
map.move_to_end(label)
|
||||
|
||||
return sorted_nodes, outgoing_edge_maps
|
||||
|
Loading…
x
Reference in New Issue
Block a user