当前位置:网站首页>Networkx drawing and common library function coordinate drawing
Networkx drawing and common library function coordinate drawing
2022-07-07 07:03:00 【lanmy_ dl】
explain : Not stitching , Mainly take notes by yourself , Recently learned about a process
1. The creation of a figure
G = nx.Graph() # Create an undirected graph
G = nx.DiGraph() # Create a directed graph
G = nx.MultiGraph() # Create multiple undirected graphs
G = nx.MultiDigraph() # Create multiple digraphs AttributeError: module ‘networkx’ has no attribute ‘MultiDigraph’
G.clear() # Empty map
2.Networkx Parameters of drawing and sorting function ,networkx, drawing , Function parameter
3.Networkx Library draws a directed graph , Customize and fix the coordinates of each node
If you want to use an undirected graph , When defining a graph, just change , Refer to below
Fixed coordinates
import networkx as nx
import matplotlib.pyplot as plt
def main():
G = nx.DiGraph()
# Add corresponding edges and points
for i in range(1, 10):
G.add_node(i, desc='v'+str(i)) # Node name cannot be str,desc Is the label, that is, the node name
G.add_edge(1, 2, name='6') # Add edge , Parameters name As the edge weights
G.add_edge(1, 3, name='4')
G.add_edge(1, 4, name='5')
G.add_edge(2, 5, name='1')
G.add_edge(3, 5, name='1')
G.add_edge(4, 6, name='2')
G.add_edge(5, 7, name='9')
G.add_edge(5, 8, name='7')
G.add_edge(6, 8, name='4')
G.add_edge(7, 9, name='2')
G.add_edge(8, 9, name='4')
pos = [(1, 3), (1, 3), (2, 4), (2, 2), (2, 1), (3, 3), (4, 1), (5, 4), (5, 2), (6, 3)] # pos The list starts at 0 Bit start , But my definition is from the node 1 Start , Here let the first two coordinates be the same
# Press pos Draw nodes at the specified position , No tag no value
nx.draw_networkx(G, pos, with_labels=None)
# Draw a label
node_labels = nx.get_node_attributes(G, 'desc')
nx.draw_networkx_labels(G, pos, labels=node_labels)
# Draw edge weights
edge_labels = nx.get_edge_attributes(G, 'name')
nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)
plt.title('AOE_CPM', fontsize=10)
plt.show()
if __name__ == '__main__':
main()
4.gephi、Graphviz And other drawing tools
The coder or the code draws points and lines according to the data , Tools are too troublesome , Never tried.
drawing tools
边栏推荐
- Abnova循环肿瘤DNA丨全血分离,基因组DNA萃取分析
- How DHCP router works
- 工具类:对象转map 驼峰转下划线 下划线转驼峰
- LM11丨重构K线构建择时交易策略
- .net core 访问不常见的静态文件类型(MIME 类型)
- Navicat importing 15g data reports an error [2013 - lost connection to MySQL server during query] [1153: got a packet bigger]
- How to share the same storage among multiple kubernetes clusters
- 中英文说明书丨ProSci LAG-3 重组蛋白
- Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
- 数据资产管理与数据安全国内外最新趋势
猜你喜欢
大促过后,销量与流量兼具,是否真的高枕无忧?
How to share the same storage among multiple kubernetes clusters
How can gyms improve their competitiveness?
What books can greatly improve programming ideas and abilities?
Navicat importing 15g data reports an error [2013 - lost connection to MySQL server during query] [1153: got a packet bigger]
After the promotion, sales volume and flow are both. Is it really easy to relax?
DHCP路由器工作原理
健身房如何提高竞争力?
JESD204B时钟网络
Abnova 体外转录 mRNA工作流程和加帽方法介绍
随机推荐
Problems and precautions about using data pumps (expdp, impdp) to export and import large capacity tables in Oracle migration
算法---比特位计数(Kotlin)
mysql查看bin log 并恢复数据
Leetcode t1165: log analysis
如何给目标机器人建模并仿真【数学/控制意义】
Prime partner of Huawei machine test questions
场馆怎么做体育培训?
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
Multithreading and high concurrency (9) -- other synchronization components of AQS (semaphore, reentrantreadwritelock, exchanger)
栈题目:有效括号的嵌套深度
Bus message bus
【mysqld】Can't create/write to file
2022年全国所有A级景区数据(13604条)
How to do sports training in venues?
Please ask a question, flick Oracle CDC, read a table without update operation, and repeatedly read the full amount of data every ten seconds
MOS tube parameters μ A method of Cox
从零到一,教你搭建「CLIP 以文搜图」搜索服务(二):5 分钟实现原型
Answer to the first stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
华为机试题素数伴侣
MYSQL----导入导出&视图&索引&执行计划