2023-02-12 21:44:08 +08:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-02-12 22:19:13 +08:00
|
|
|
"execution_count": 2,
|
2023-02-12 21:44:08 +08:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAACyIAAAsQCAYAAABS037aAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOz9d5hdZbk//r/3nl7SAwkESGKQFoogICIIClg4J1ZUwIJYDtajWFD5Wjge9WA74u9jQQ8gIGABAVHpiiAlFAmBBAgoJAQIkF6mz97798ckA8NMQjYShujrdV1zzey1nvU891p7ryU477kpVCqVSgAAAAAAAAAAAAAAqlAc7gIAAAAAAAAAAAAAgM2PIDIAAAAAAAAAAAAAUDVBZAAAAAAAAAAAAACgaoLIAAAAAAAAAAAAAEDVBJEBAAAAAAAAAAAAgKoJIgMAAAAAAAAAAAAAVRNEBgAAAAAAAAAAAACqJogMAAAAAAAAAAAAAFRNEBkAAAAAAAAAAAAAqJogMgAAAAAAAAAAAABQNUFkAAAAAAAAAAAAAKBqgsgAAAAAAAAAAAAAQNUEkQEAAAAAAAAAAACAqgkiAwAAAAAAAAAAAABVE0QGAAAAAAAAAAAAAKomiAwAAAAAAAAAAAAAVE0QGQAAAAAAAAAAAAComiAyAAAAAAAAAAAAAFA1QWQAAAAAAAAAAAAAoGqCyAAAAAAAAAAAAABA1QSRAQAAAAAAAAAAAICqCSIDAAAAAAAAAAAAAFUTRAYAAAAAAAAAAAAAqiaIDAAAAAAAAAAAAABUTRAZAAAAAAAAAAAAAKiaIDIAAAAAAAAAAAAAUDVBZAAAAAAAAAAAAACgarXP94IrVqzItdde2/962223TUNDw/Nd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AQAAAAAAAAAAAIC
|
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 3600x3600 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"import pandas as pd\n",
|
|
|
|
"import networkx as nx\n",
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
"\n",
|
|
|
|
"plt.rcParams['font.sans-serif'] = 'SimHei'\n",
|
|
|
|
"\n",
|
|
|
|
"BomNodes = pd.read_csv('BomNodes.csv', index_col=0)\n",
|
|
|
|
"BomNodes.set_index('Code', inplace=True)\n",
|
|
|
|
"BomCateNet = pd.read_csv('BomCateNet.csv', index_col=0)\n",
|
|
|
|
"BomCateNet.fillna(0, inplace=True)\n",
|
|
|
|
"\n",
|
|
|
|
"G = nx.from_pandas_adjacency(BomCateNet, create_using=nx.MultiDiGraph())\n",
|
|
|
|
"\n",
|
|
|
|
"labels_dict = {}\n",
|
|
|
|
"for code in G.nodes:\n",
|
|
|
|
" labels_dict[code] = BomNodes.loc[code].to_dict()\n",
|
|
|
|
"nx.set_node_attributes(G, labels_dict)\n",
|
|
|
|
"\n",
|
|
|
|
"pos = nx.nx_agraph.graphviz_layout(G, prog=\"twopi\", args=\"\")\n",
|
|
|
|
"node_labels = nx.get_node_attributes(G, 'Name')\n",
|
|
|
|
"plt.figure(figsize=(12, 12), dpi=300)\n",
|
|
|
|
"nx.draw_networkx_nodes(G, pos)\n",
|
|
|
|
"nx.draw_networkx_edges(G, pos)\n",
|
|
|
|
"nx.draw_networkx_labels(G, pos, labels = node_labels, font_size=6)\n",
|
|
|
|
"plt.show()\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "base",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.8.8"
|
|
|
|
},
|
|
|
|
"orig_nbformat": 4,
|
|
|
|
"vscode": {
|
|
|
|
"interpreter": {
|
|
|
|
"hash": "bcdafc093860683ffb58d6956591562b7f8ed5d58147d17d71a5d4d6605a08df"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|