2023-02-13 17:52:58 +08:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2023-02-16 16:11:54 +08:00
|
|
|
"execution_count": 12,
|
2023-02-13 17:52:58 +08:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
2023-02-13 18:18:36 +08:00
|
|
|
{
|
|
|
|
"name": "stderr",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2023-02-16 16:11:54 +08:00
|
|
|
"C:\\Users\\25759\\AppData\\Local\\Temp\\ipykernel_20892\\1462409850.py:27: SettingWithCopyWarning: \n",
|
2023-02-13 18:18:36 +08:00
|
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
|
|
"\n",
|
|
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
|
|
" Firm_attr['Product_Code'] = firm_product\n"
|
|
|
|
]
|
|
|
|
},
|
2023-02-16 16:11:54 +08:00
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|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|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['1.3.2.1']\n",
|
|
|
|
"['1.3.4.1', '1.3.4.2', '1.3.4.3']\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['1.3.4.1', '1.3.4.2', '1.3.4.3']\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"['1.3.4.1', '1.3.4.2', '1.3.4.3']\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"['1.3.4.1', '1.3.4.2', '1.3.4.3']\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1', '2.1.2', '2.1.3', '2.1.4']\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['1.3.5.1']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['1.3.2.1']\n",
|
|
|
|
"['1.3.4.1', '1.3.4.2', '1.3.4.3']\n",
|
|
|
|
"['1.3.5.1']\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['1.3.2.1']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5']\n",
|
|
|
|
"['2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['1.3.5.1']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.4.1', '2.1.4.2']\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4']\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"[]\n",
|
|
|
|
"['2.3.1', '2.3.2', '2.3.3']\n",
|
|
|
|
"[]\n"
|
|
|
|
]
|
|
|
|
},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|
|
|
"<Figure size 3600x3600 with 1 Axes>"
|
2023-02-13 17:52:58 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
2023-02-13 18:18:36 +08:00
|
|
|
"output_type": "display_data"
|
2023-02-13 17:52:58 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"import pandas as pd\n",
|
2023-02-13 18:18:36 +08:00
|
|
|
"import networkx as nx\n",
|
|
|
|
"import matplotlib.pyplot as plt\n",
|
|
|
|
"\n",
|
|
|
|
"plt.rcParams['font.sans-serif'] = 'SimHei'\n",
|
2023-02-13 17:52:58 +08:00
|
|
|
"\n",
|
2023-02-16 16:11:54 +08:00
|
|
|
"# init graph bom\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_bom = nx.from_pandas_adjacency(BomCateNet, create_using=nx.MultiDiGraph())\n",
|
|
|
|
"\n",
|
|
|
|
"bom_labels_dict = {}\n",
|
|
|
|
"for code in G_bom.nodes:\n",
|
|
|
|
" bom_labels_dict[code] = BomNodes.loc[code].to_dict()\n",
|
|
|
|
"nx.set_node_attributes(G_bom, bom_labels_dict)\n",
|
|
|
|
"\n",
|
|
|
|
"# init graph firm\n",
|
|
|
|
"Firm = pd.read_csv(\"Firm_amended.csv\")\n",
|
2023-02-13 17:52:58 +08:00
|
|
|
"Firm.fillna(0, inplace=True)\n",
|
2023-02-13 18:18:36 +08:00
|
|
|
"Firm_attr = Firm[[\"Code\",\"Name\",\"Type_Region\"]]\n",
|
|
|
|
"firm_product = []\n",
|
|
|
|
"for _, row in Firm.loc[:,'1':].iterrows():\n",
|
|
|
|
" firm_product.append(row[row==1].index.to_list())\n",
|
|
|
|
"Firm_attr['Product_Code'] = firm_product\n",
|
|
|
|
"Firm_attr.set_index('Code')\n",
|
|
|
|
"\n",
|
2023-02-16 16:11:54 +08:00
|
|
|
"G_Firm =nx.MultiDiGraph()\n",
|
|
|
|
"G_Firm.add_nodes_from(Firm[\"Code\"])\n",
|
2023-02-13 18:18:36 +08:00
|
|
|
"\n",
|
2023-02-16 16:11:54 +08:00
|
|
|
"firm_labels_dict = {}\n",
|
|
|
|
"for code in G_Firm.nodes:\n",
|
|
|
|
" firm_labels_dict[code] = Firm_attr.loc[code].to_dict()\n",
|
|
|
|
"nx.set_node_attributes(G_Firm, firm_labels_dict)\n",
|
2023-02-13 18:18:36 +08:00
|
|
|
"\n",
|
2023-02-16 16:11:54 +08:00
|
|
|
"# add edge to G_firm according to G_bom\n",
|
|
|
|
"product_codes = nx.get_node_attributes(G_Firm, 'Product_Code')\n",
|
|
|
|
"for node in nx.nodes(G_Firm):\n",
|
|
|
|
" # print(product_codes[node])\n",
|
|
|
|
" for product_code in product_codes[node]:\n",
|
|
|
|
" # print(product_code)\n",
|
|
|
|
" print(list(G_bom.neighbors(product_code)))\n",
|
|
|
|
"\n",
|
|
|
|
"# print graph\n",
|
|
|
|
"pos = nx.nx_agraph.graphviz_layout(G_Firm, prog=\"twopi\", args=\"\")\n",
|
|
|
|
"node_labels = nx.get_node_attributes(G_Firm, 'Name')\n",
|
2023-02-13 18:18:36 +08:00
|
|
|
"plt.figure(figsize=(12, 12), dpi=300)\n",
|
2023-02-16 16:11:54 +08:00
|
|
|
"nx.draw_networkx_nodes(G_Firm, pos)\n",
|
|
|
|
"nx.draw_networkx_edges(G_Firm, pos)\n",
|
|
|
|
"nx.draw_networkx_labels(G_Firm, pos, labels = node_labels, font_size=6)\n",
|
2023-02-13 18:18:36 +08:00
|
|
|
"plt.show()"
|
2023-02-13 17:52:58 +08:00
|
|
|
]
|
|
|
|
},
|
2023-02-16 16:11:54 +08:00
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 7,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"NodeView(('1', '1.1', '1.1.1', '1.1.2', '1.1.3', '1.2', '1.2.1', '1.2.2', '1.2.3', '1.3', '1.3.1', '1.3.1.1', '1.3.1.2', '1.3.1.3', '1.3.1.4', '1.3.1.5', '1.3.1.6', '1.3.1.7', '1.3.2', '1.3.2.1', '1.3.3', '1.3.3.1', '1.3.3.2', '1.3.3.3', '1.3.3.4', '1.3.3.5', '1.3.3.6', '1.3.3.7', '1.3.4', '1.3.4.1', '1.3.4.2', '1.3.4.3', '1.3.5', '1.3.5.1', '1.4', '1.4.1', '1.4.1.1', '1.4.1.2', '1.4.1.3', '1.4.1.4', '1.4.1.5', '1.4.2', '1.4.2.1', '1.4.2.2', '1.4.2.3', '1.4.2.4', '1.4.2.5', '1.4.2.6', '1.4.2.7', '1.4.3', '1.4.3.1', '1.4.3.2', '1.4.3.3', '1.4.3.4', '1.4.3.5', '1.4.3.6', '1.4.4', '1.4.4.1', '1.4.4.2', '1.4.4.3', '1.4.4.4', '1.4.4.5', '1.4.5', '1.4.5.1', '1.4.5.2', '1.4.5.3', '1.4.5.4', '1.4.5.5', '1.4.5.6', '1.4.5.7', '1.4.5.8', '1.4.5.9', '2', '2.1', '2.1.1', '2.1.1.1', '2.1.1.2', '2.1.1.3', '2.1.1.4', '2.1.1.5', '2.1.2', '2.1.2.1', '2.1.2.2', '2.1.2.3', '2.1.2.4', '2.1.3', '2.1.3.1', '2.1.3.2', '2.1.3.3', '2.1.3.4', '2.1.3.5', '2.1.3.6', '2.1.3.7', '2.1.4', '2.1.4.1', '2.1.4.1.1', '2.1.4.1.2', '2.1.4.1.3', '2.1.4.1.4', '2.1.4.2', '2.1.4.2.1', '2.1.4.2.2', '2.2', '2.3', '2.3.1', '2.3.2', '2.3.3'))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 7,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"G_bom.nodes()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 10,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"['1.1', '1.2', '1.3', '1.4', '2']"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 10,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"list(G_bom.neighbors('1'))"
|
|
|
|
]
|
|
|
|
},
|
2023-02-13 17:52:58 +08:00
|
|
|
{
|
|
|
|
"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
|
|
|
|
}
|