'Computes Partial-order of the nodes with depth-first search'

def make_acyclic(self, parent, node, level, tree):

    if (node not in self.partial_order):
        self.partial_order[node] = {'level': level, 'mark': 0}
        if parent:
            tree.append((parent, node))
    if (self.partial_order[node]['mark'] == 0):
        self.partial_order[node]['mark'] = 1
        for sec_end in self.transitions.get(node, []):
            self.links.append((node, sec_end))
            self.make_acyclic(node, sec_end, (level + 1), tree)
    return tree
