【发布时间】:2011-07-21 11:44:10
【问题描述】:
我有一个名为 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)。这些节点可能在彼此的父列表或子列表中。我希望能够将其 childLists 和 parentlists 中规定的节点之间的关系可视化到标准输出(作为 ASCII 绘图)。
例如,下面的名称是 nodeList 中节点的名称。
Classifier
|
|
FeatureCombiner
/ \
/ \
/ \
FeatureGenerator1 FeatureGenerator2
\ /
\ /
\ /
\ /
\ /
\ /
\ /
Image Loader
Classifier 有一个空的 parentList 和一个包含 FeatureCombiner 的长度为 1 的 childList。 FeatureGenerator1 和 2 具有相同的 parent 和 childList,分别包含 FeatureCombiner 和 Image Loader。 Image Loader 有一个空的 childList 和一个包含 FeatureGenerator1 和 2 的 parentList。
提前谢谢你, 马特
【问题讨论】:
标签: python graph ascii visualization