基本上,对于每个节点,我都知道它的生成及其父节点.
我试图表示这个图表保持同一行中的同一代的节点.每一代都有10个节点,第一代除外.
到目前为止,我正在尝试“点”布局.当我只输入两代时它做得很好,但是当我输入3代时,它“太聪明”了,并以某种方式重新排列节点.
例如,以下数据代表3代:
[(的ObjectID( ‘530b2ad783a1a15e695c9711’),的ObjectID( ‘530b804883a1a15e695c972b’)),(的ObjectID( ‘530b2ad783a1a15e695c971c’),(的ObjectID( ‘530b2ad783a1a15e695c9709’),的ObjectID( ‘530b804883a1a15e695c9727’)),(的ObjectID( ‘530b2ad783a1a15e695c970a’),(的ObjectID( ‘530b2ad783a1a15e695c970b’),的ObjectID( ‘530b804883a1a15e695c9724’)),(的ObjectID( ‘530b2ad783a1a15e695c970f’),(的ObjectID( ‘530b2ad783a1a15e695c9714’),的ObjectID( ‘530b804883a1a15e695c9729’)),(的ObjectID( ‘530b2ad783a1a15e695c970e’),(的ObjectID( ‘530b2ad783a1a15e695c9711’),的ObjectID( ‘530b804883a1a15e695c9723’)),(的ObjectID(‘530b2ad783a1a15e695c970e ‘),的ObjectID(‘ 530b804883a1a15e695c9723 ‘)),(的ObjectID(‘ 530b2ad783a1a15e695c971c ‘),的ObjectID(‘ 530b804883a1a15e695c9728 ‘)),(的ObjectID(‘ 530b2ad783a1a15e695c9719 ‘),(的ObjectID(‘ 530b2ad783a1a15e695c9714’ ),ObjectID(‘530b804883a1a1 5e695c9726 ‘)),(的ObjectID(‘ 530b2ad783a1a15e695c9713 ‘),的ObjectID(‘ 530b804883a1a15e695c9726 ‘)),(的ObjectID(‘ 530b2ad783a1a15e695c9716 ‘),的ObjectID(‘ 530b804883a1a15e695c9722 ‘)),的ObjectID(‘ 530b804883a1a15e695c9722’ )),(的ObjectID( ‘530b2ad783a1a15e695c970d’),的ObjectID( ‘530b804883a1a15e695c9725’)),(的ObjectID( ‘530b2ad783a1a15e695c9715’),(的ObjectID( ‘530b804883a1a15e695c9724’),的ObjectID( ‘530ba27c83a1a15e695c972d’)),(的ObjectID( ‘530b2ad783a1a15e695c9713’),的ObjectID( ‘530ba27c83a1a15e695c972e’)),(的ObjectID( ‘530b804883a1a15e695c9727’),的ObjectID( ‘530ba27c83a1a15e695c972f’)),的ObjectID( ‘530ba27c83a1a15e695c9730’)),ObjectID(‘ 530ba27c83a1a15e695c9730 ‘)),的ObjectID(‘ 530ba27c83a1a15e695c9731 ‘)),(的ObjectID(‘ 530b804883a1a15e695c9725 ‘),(的ObjectID(‘ 530b804883a1a15e695c9722 ‘),的ObjectID(‘ 530ba27c83a1a15e695c9732’ )),的ObjectID( ‘530ba27c83a1a15e695c9732’)),的ObjectID( ‘530ba27c83a1a15e695c9733’)),(的ObjectID( ‘530b2ad783a1a15e695c971f’),(的ObjectID( ‘530b804883a1a15e695c972b’),的ObjectID( ‘530ba27c83a1a15e695c9734’)),的ObjectID( ‘530ba27c83a1a15e695c9735’)),的ObjectID( ‘530ba27c83a1a15e695c9736’)),(的ObjectID( ‘530b804883a1a15e695c9723’),(的ObjectID( “530b2ad783a1a15e695c9716 ‘),(的ObjectID(‘ 530b2ad783a1a15e695c9711 ‘),(的ObjectID(‘ 530b2ad783a1a15e695c970e’),的ObjectID ( ‘530b804883a1a15e695c9725’)),的ObjectID( ‘530b804883a1a15e695c9726’)),的ObjectID(” 530b804883a1a15e695c9726 ‘)),(的ObjectID(‘ 530b2ad783a1a15e695c9709 ‘),的ObjectID(‘ 530b804883a1a15e695c9727 ‘)),(的ObjectID(‘ 530b2ad783a1a15e695c970a ‘),的ObjectID(‘ 530b804883a1a15e695c9728’ )),(ObjectID(‘530b2ad783 a1a15e695c9719 ‘),(的ObjectID(‘ 530b2ad783a1a15e695c9714 ‘),的ObjectID(‘ 530b804883a1a15e695c9729 ‘)),(的ObjectID(‘ 530b2ad783a1a15e695c970e ‘),(的ObjectID(‘ 530b2ad783a1a15e695c9715’ ),的ObjectID( ‘530b804883a1a15e695c972a’)),的ObjectID( ‘530b804883a1a15e695c972b’))]
生产:
例如,所有“root”且因此不接收边缘的节点应放在第一行,但它将其中一些放在第二层.
一旦我尝试制作更大的图形,有10代,所有的层次都没有任何意义.
是否有任何参数或方法来指定节点的级别或层?在我提供的数据中,信息不存在,但我可以很容易地产生它,问题是我不知道如何将该信息发送到pygraphviz或networkx.
我也想用这个数据来生成像这样的一个像这样的两个图形的图形
其中图层以圆形方式表示.
解决方法 使用属性rank = same的Graphviz子图.例如
import networkx as nximport pygraphviz as pgv # pygraphviz should be availableG = nx.DiGraph()G.add_edge('a','aa')G.add_edge('a','ab')G.add_edge('a','bbc')G.add_edge('b','ab')G.add_edge('b','bb')G.add_edge('c','bbc')G.add_edge('bb','bba')G.add_edge('bb','bbc')A = nx.to_agraph(G)one = A.add_subgraph(['a','b','c'],rank='same')two = A.add_subgraph(['aa','ab','bb'],rank='same')three = A.add_subgraph(['bba','bbc'],rank='same')A.draw('example.png',prog='dot')总结
以上是内存溢出为你收集整理的python – Pygraphviz / networkx设置节点级别或层全部内容,希望文章能够帮你解决python – Pygraphviz / networkx设置节点级别或层所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)