我正以这种方式处理一棵我所代表的通用树: """ A tree in which each node can have any number of children. Each node is linked to its parent and to its immediate sibling on the right def __init__(self, data): self._
我有以下DAG邻接列表表示: # this reads: b depends on a, c depends on a and d depends on b and c
graph = {'b': {'a'}, 'c': {'a'}, 'd': {'b', 'c'}} 我想要得到下面的反转表示: graph = {'a': {'b', 'c'}, 'b