@@ -320,6 +320,7 @@ def _layout_graph_up(graph):
320320
321321# topological_sort
322322
323+
323324def get_input_nodes (node ):
324325 """
325326 Get input nodes of node.
@@ -477,6 +478,14 @@ def dfs(start_node):
477478 return sorted_nodes
478479
479480
481+ def __remove_BackdropNode (nodes ):
482+ from .node import BackdropNode
483+ for node in nodes [:]:
484+ if isinstance (node , BackdropNode ):
485+ nodes .remove (node )
486+ return nodes
487+
488+
480489def topological_sort_by_down (start_nodes = [], all_nodes = []):
481490 """
482491 Topological sort method by down stream direction.
@@ -488,6 +497,10 @@ def topological_sort_by_down(start_nodes=[], all_nodes=[]):
488497 Returns:
489498 list[NodeGraphQt.BaseNode]: sorted nodes.
490499 """
500+ if start_nodes :
501+ start_nodes = __remove_BackdropNode (start_nodes )
502+ if all_nodes :
503+ all_nodes = __remove_BackdropNode (all_nodes )
491504
492505 if not start_nodes :
493506 start_nodes = [n for n in all_nodes if not _has_input_node (n )]
@@ -512,6 +525,10 @@ def topological_sort_by_up(start_nodes=[], all_nodes=[]):
512525 Returns:
513526 list[NodeGraphQt.BaseNode]: sorted nodes.
514527 """
528+ if start_nodes :
529+ start_nodes = __remove_BackdropNode (start_nodes )
530+ if all_nodes :
531+ all_nodes = __remove_BackdropNode (all_nodes )
515532
516533 if not start_nodes :
517534 start_nodes = [n for n in all_nodes if not _has_output_node (n )]
@@ -652,6 +669,10 @@ def auto_layout_up(start_nodes=[], all_nodes=[]):
652669 start_nodes (list[NodeGraphQt.BaseNode])(Optional): the end nodes of the graph.
653670 all_nodes (list[NodeGraphQt.BaseNode])(Optional): if 'start_nodes' is None the function can calculate start nodes from 'all_nodes'.
654671 """
672+ if start_nodes :
673+ start_nodes = __remove_BackdropNode (start_nodes )
674+ if all_nodes :
675+ all_nodes = __remove_BackdropNode (all_nodes )
655676
656677 if not start_nodes :
657678 start_nodes = [n for n in all_nodes if not _has_output_node (n )]
@@ -693,6 +714,10 @@ def auto_layout_down(start_nodes=[], all_nodes=[]):
693714 start_nodes (list[NodeGraphQt.BaseNode])(Optional): the start update nodes of the graph.
694715 all_nodes (list[NodeGraphQt.BaseNode])(Optional): if 'start_nodes' is None the function can calculate start nodes from 'all_nodes'.
695716 """
717+ if start_nodes :
718+ start_nodes = __remove_BackdropNode (start_nodes )
719+ if all_nodes :
720+ all_nodes = __remove_BackdropNode (all_nodes )
696721
697722 if not start_nodes :
698723 start_nodes = [n for n in all_nodes if not _has_input_node (n )]
0 commit comments