简体   繁体   English

如何根据节点的邻接关系使用NetworkX绘制图形

[英]How to draw a graph with NetworkX based on adjacency of nodes

I'm seeing in many research papers graphical representations of directed graphs where nodes seem to be placed depending on their adjacency rather than on features for the x and y axis.我在许多研究论文中看到有向图的图形表示,其中节点的放置似乎取决于它们的相邻性,而不是 x 和 y 轴的特征。 An example of it, from Conover, Michael D., et al. "Political polarization on twitter." Fifth international AAAI conference on weblogs and social media. 2011.一个例子,来自Conover, Michael D., et al. "Political polarization on twitter." Fifth international AAAI conference on weblogs and social media. 2011. Conover, Michael D., et al. "Political polarization on twitter." Fifth international AAAI conference on weblogs and social media. 2011.

在此处输入图片说明

How can I obtain such a representation from a pre constructed NetworkX DiGraph如何从预先构建的 NetworkX DiGraph 中获得这样的表示

NetworkX has built in functions to draw graphs (see here ). NetworkX 具有用于绘制图形的内置函数(请参阅此处)。 You can basically call them and pass the DiGraph you constructed.您基本上可以调用它们并传递您构造的有向图。 Copying from one of their own examples:从他们自己的例子之一复制:

G = nx.dodecahedral_graph()
nx.draw(G)
nx.draw(G, pos=nx.spring_layout(G))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM