requirement.txt
This commit is contained in:
		
							parent
							
								
									110ecf6e60
								
							
						
					
					
						commit
						a26b5baa34
					
				| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
 "cells": [
 | 
			
		||||
  {
 | 
			
		||||
   "cell_type": "code",
 | 
			
		||||
   "execution_count": 1,
 | 
			
		||||
   "execution_count": 2,
 | 
			
		||||
   "metadata": {},
 | 
			
		||||
   "outputs": [
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
# %%
 | 
			
		||||
import pandas as pd
 | 
			
		||||
import networkx as nx
 | 
			
		||||
import matplotlib.pyplot as plt
 | 
			
		||||
 | 
			
		||||
plt.rcParams['font.sans-serif'] = 'SimHei'
 | 
			
		||||
 | 
			
		||||
BomNodes = pd.read_csv('BomNodes.csv', index_col=0)
 | 
			
		||||
BomNodes.set_index('Code', inplace=True)
 | 
			
		||||
BomCateNet = pd.read_csv('BomCateNet.csv', index_col=0)
 | 
			
		||||
BomCateNet.fillna(0, inplace=True)
 | 
			
		||||
 | 
			
		||||
G = nx.from_pandas_adjacency(BomCateNet, create_using=nx.MultiDiGraph())
 | 
			
		||||
 | 
			
		||||
labels_dict = {}
 | 
			
		||||
for code in G.nodes:
 | 
			
		||||
    labels_dict[code] = BomNodes.loc[code].to_dict()
 | 
			
		||||
nx.set_node_attributes(G, labels_dict)
 | 
			
		||||
 | 
			
		||||
pos = nx.nx_agraph.graphviz_layout(G, prog="twopi", args="")
 | 
			
		||||
node_labels = nx.get_node_attributes(G, 'Name')
 | 
			
		||||
plt.figure(figsize=(12, 12), dpi=300)
 | 
			
		||||
nx.draw_networkx_nodes(G, pos)
 | 
			
		||||
nx.draw_networkx_edges(G, pos)
 | 
			
		||||
nx.draw_networkx_labels(G, pos, labels=node_labels, font_size=6)
 | 
			
		||||
plt.show()
 | 
			
		||||
 | 
			
		||||
# %%
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
agentpy==0.1.5
 | 
			
		||||
matplotlib==3.3.4
 | 
			
		||||
matplotlib-inline==0.1.6
 | 
			
		||||
networkx==2.5
 | 
			
		||||
numpy==1.20.3
 | 
			
		||||
numpydoc==1.1.0
 | 
			
		||||
pandas==1.4.1
 | 
			
		||||
pandas-stubs==1.2.0.39
 | 
			
		||||
pygraphviz==1.9
 | 
			
		||||
		Loading…
	
		Reference in New Issue