{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-04-21T00:32:54.213154Z",
     "start_time": "2025-04-21T00:32:53.239675Z"
    }
   },
   "source": [
    "from wordcloud import WordCloud\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "with open('./resource/1.txt', 'r', encoding=\"UTF-8\") as f:\n",
    "    text = f.read()\n",
    "\n",
    "wordcloud = WordCloud().generate(text)\n",
    "\n",
    "plt.imshow(wordcloud, interpolation=\"bilinear\")\n",
    "\n",
    "plt.axis(\"off\")\n",
    "\n",
    "plt.show()"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 59076 characters]\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-04-21T00:33:12.990715Z",
     "start_time": "2025-04-21T00:33:12.840103Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from PIL import Image\n",
    "from wordcloud import WordCloud\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "image = np.array(Image.open(\"resource/3.png\"))\n",
    "\n",
    "with open('./resource/1.txt', 'r', encoding=\"UTF-8\") as f:\n",
    "    text = f.read()\n",
    "\n",
    "wordcloud = WordCloud(mask=image, background_color='white').generate(text)\n",
    "\n",
    "plt.imshow(wordcloud, interpolation=\"bilinear\")\n",
    "\n",
    "plt.axis(\"off\")\n",
    "\n",
    "plt.show()"
   ],
   "id": "fa45f7ee96bc1ef7",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 33336 characters]\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-04-21T00:33:54.593218Z",
     "start_time": "2025-04-21T00:33:54.085137Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from wordcloud import WordCloud\n",
    "import matplotlib.pyplot as plt\n",
    "import jieba\n",
    "\n",
    "with open('./resource/2.txt', 'r', encoding=\"UTF-8\") as f:\n",
    "    text = f.read()\n",
    "\n",
    "cut_text = \" \".join(jieba.cut(text))\n",
    "\n",
    "cloud = WordCloud(\n",
    "    background_color=\"white\",\n",
    "    max_words=100,\n",
    "    font_path=\"/System/Library/Fonts/STHeiti Light.ttc\",\n",
    "    min_font_size=40,\n",
    "    max_font_size=100,\n",
    "    width=800,\n",
    "    height=400\n",
    ")\n",
    "\n",
    "wCloud = cloud.generate(cut_text)\n",
    "\n",
    "plt.imshow(wCloud, interpolation=\"bilinear\")\n",
    "plt.axis(\"off\")\n",
    "plt.show()"
   ],
   "id": "cd013d0ade915b96",
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Building prefix dict from the default dictionary ...\n",
      "Dumping model to file cache /var/folders/d0/kmt7kgdx25z7rddmtqzq253w0000gn/T/jieba.cache\n",
      "Loading model cost 0.368 seconds.\n",
      "Prefix dict has been built successfully.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 53152 characters]\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-04-21T00:34:13.973612Z",
     "start_time": "2025-04-21T00:34:13.849073Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from wordcloud import WordCloud\n",
    "import matplotlib.pyplot as plt\n",
    "import jieba\n",
    "from PIL import Image\n",
    "\n",
    "image = np.array(Image.open(\"resource/4.png\"))\n",
    "\n",
    "with open('./resource/2.txt', 'r', encoding=\"UTF-8\") as f:\n",
    "    text = f.read()\n",
    "\n",
    "cut_text = \" \".join(jieba.cut(text))\n",
    "\n",
    "cloud = WordCloud(\n",
    "    mask=image,\n",
    "    background_color=\"white\",\n",
    "    max_words=100,\n",
    "    font_path=\"/System/Library/Fonts/STHeiti Light.ttc\",\n",
    "    min_font_size=40,\n",
    "    max_font_size=100,\n",
    "    width=800,\n",
    "    height=400\n",
    ")\n",
    "\n",
    "wCloud = cloud.generate(cut_text)\n",
    "\n",
    "plt.imshow(wCloud, interpolation=\"bilinear\")\n",
    "plt.axis(\"off\")\n",
    "plt.show()\n"
   ],
   "id": "43caa47678f6a43f",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 35240 characters]\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-04-21T00:34:53.423429Z",
     "start_time": "2025-04-21T00:34:53.246830Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from matplotlib import pyplot as plt\n",
    "import networkx as nx\n",
    "\n",
    "G = nx.DiGraph()\n",
    "# 节点\n",
    "G.add_nodes_from([1, 2, 3, 4, 5, 6, 7])\n",
    "# 环\n",
    "nx.add_cycle(G, [1, 2, 3])\n",
    "# 边\n",
    "G.add_edge(1, 4)\n",
    "# 多条边\n",
    "G.add_edges_from([(3, 5), (3, 6), (6, 7)])\n",
    "nx.draw_networkx(G)\n",
    "\n",
    "plt.show()"
   ],
   "id": "63a6fa9a4702af92",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 11468 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-04-21T00:35:24.592118Z",
     "start_time": "2025-04-21T00:35:24.531970Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from matplotlib import pyplot as plt\n",
    "import networkx as nx\n",
    "\n",
    "G = nx.DiGraph()\n",
    "# 节点\n",
    "G.add_nodes_from([1, 2, 3, 4, 5, 6, 7])\n",
    "# 环\n",
    "nx.add_cycle(G, [1, 2, 3])\n",
    "# 边\n",
    "G.add_edge(1, 4)\n",
    "# 多条边\n",
    "G.add_edges_from([(3, 5), (3, 6), (6, 7)])\n",
    "# nx.draw_networkx(G)\n",
    "\n",
    "node_color = ['yellow', 'blue', 'pink', 'green', 'gray', 'navy', 'indigo']\n",
    "edge_color = ['orange', 'purple', 'orange', 'cyan']\n",
    "nx.draw_networkx(G, node_color=node_color, edge_color=edge_color)\n",
    "\n",
    "plt.show()"
   ],
   "id": "6b3f8e29c99b061a",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 12784 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-04-21T00:35:38.411590Z",
     "start_time": "2025-04-21T00:35:38.332429Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from matplotlib import pyplot as plt\n",
    "import networkx as nx\n",
    "\n",
    "G = nx.Graph()\n",
    "G.add_nodes_from([1])\n",
    "nx.draw_networkx(G)\n",
    "plt.show()\n",
    "\n",
    "G = nx.Graph()\n",
    "G.add_nodes_from([1, 2, 3, 4])\n",
    "G.add_edges_from([(1, 2), (1, 3), (1, 4)])\n",
    "nx.draw_networkx(G)\n",
    "\n",
    "plt.show()"
   ],
   "id": "192d8ad05dbcc473",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmp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9ABAkugBBogsQJLoAQaILEPQHkRbsQkGD5OcAAAAASUVORK5CYII=\n"
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 9088 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-04-21T00:35:48.005938Z",
     "start_time": "2025-04-21T00:35:47.890966Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from matplotlib import pyplot as plt\n",
    "import networkx as nx\n",
    "\n",
    "G = nx.Graph()\n",
    "G.add_nodes_from([1])\n",
    "nx.draw_networkx(G,node_color='purple')\n",
    "plt.show()\n",
    "\n",
    "G = nx.Graph()\n",
    "G.add_nodes_from([1, 2, 3, 4])\n",
    "G.add_edges_from([(1, 2), (1, 3), (1, 4)])\n",
    "nx.draw_networkx(G,\n",
    "                 node_color=['purple','green','blue','red'],\n",
    "                 edge_color=['pink','orange','navy'])\n",
    "\n",
    "plt.show()"
   ],
   "id": "51a6bbfd1186c6fa",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAF5UlEQVR4nO3dv09VZxzH8e9tIAGJMSaKCQxlYNGowQSm+iMuJHZzcrWjux2cHF3cu/oPtHGyqRP+WIyYEB10wMGBQWxiHBCSCzkdUFuLQsXrh6N9ve4ED+fJd3rn5rmHcztN0xQAGd/t9AAA/yeiCxAkugBBogsQJLoAQX2bLe7bt68ZGxsLjQLwbXjw4MGfTdPs/9DaptEdGxur2dnZLzMVwDeq0+k8+9ia4wWA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Xp6t/16eFt39Xf01fnfYvwLSS4wVa7e1DazZ7ytg7nfV3uJ4yRpuJLq03eWGyRqZG6s6VOzV/Y76q8/fjHKvW71KoZv0M98SlE97h0mqiy1dhZHKkzv16rpZerH9zxOKjxVp5uVIDewdq+MhwTZz3zRF8HUSXr8rQ/qH64ecfdnoM2DYfpAEEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AkOgCBIkuQJDoAgSJLkCQ6AIEiS5AUKdpmo8vdjovqupZbhyAb8L3TdPs/9DCptEFoLccLwAEiS5AkOgCBIkuQJDoAgT9BQhN3RKizDACAAAAAElFTkSuQmCC\n"
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ],
      "image/png": "[encoded data, 8612 characters]\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 9
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "3fdb794e68f86ab3"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
