algorithm: a topological sort in a graph can be much simpler
There were three surprising things in the previous version: * the XXX mention: leafs can indeed be detected at construction time * the need to track both children and parents of a node: usually only one or the other is enough to work efficiently on a graph * the idiom: if n in list: list.remove(n) list.append(n) Replace it by a generic sort on node depth. A dictionary is used for lookups to avoid linear list lookups, and only the successor relation is kept (parent_dict) Also explicit in comments the graph we are building/the order expected for code clarity (ie avoid confusion wrt what is the parent/child of the graph node) git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31556 20353a03-c40f-0410-a6d1-a30d3c3de9de
Showing
Please register or sign in to comment