如何在使用Python和xdot构建的图中标记边缘
我已经找到了一种使用dot语言在Python中构建图形的方法。
import sys
import threading
import time
import networkx as nx
import xdot
import gtk
class MyClass(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.graph = nx.DiGraph(name="my_tree")
self.xdot = xdot.DotWindow()
self.xdot.connect('destroy', gtk.main_quit)
def run(self):
gtk.main()
def add_node(self, parent, node):
self.graph.add_edge(parent, node)
self.xdot.set_dotcode(nx.to_agraph(self.graph).to_string())
self.xdot.show_all()
def main(argv=None):
gtk.gdk.threads_init()
my_class = MyClass()
my_class.start()
my_class.add_node('operating_system', 'file_mgmt')
time.sleep(1.5)
if __name__ == "__main__":
sys.exit(main())
上述程序将自动在操作系统和文件管理概念之间创建一条边,并在椭圆形中标记这些概念。
我的问题是如何使用Python语言在该边上标记“子类”标签,以便概念之间的关系更加清晰。
是否有可用的机制可以实现这一点?