我有一个叫做Node的类。
class Node:
def __init__(self,name, childList, parentList):
self.name = name
# a list of all nodes which are children of this node
# may have length 0 to many
self.childList = childList
# a list of all nodes which are parents of this node
# may have length 0 to many
self.parentList = parentList
我有一个节点列表(nodeList)。这些节点可能会在彼此的父节点列表或子节点列表中。我想能够将它们在子节点列表和父节点列表中的关系可视化到stdout上(以ASCII绘图方式呈现)。例如,下面的名称是节点列表中节点的名称。
Classifier
|
|
FeatureCombiner
/ \
/ \
/ \
FeatureGenerator1 FeatureGenerator2
\ /
\ /
\ /
\ /
\ /
\ /
\ /
Image Loader
分类器具有一个空的parentList和一个长度为1的childList,其中包含FeatureCombiner。FeatureGenerator1和2具有相同的parent和childList,分别包含FeatureCombiner和Image Loader。Image Loader具有一个空的childList和一个包含FeatureGenerator1和2的parentList。
提前感谢, Matt