{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "688ee55a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "185233e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "# CMU Serif\n",
    "plt.rcParams['font.family'] = 'CMU Serif'\n",
    "plt.rcParams['mathtext.fontset'] = 'cm'\n",
    "plt.rcParams['font.size'] = 14\n",
    "plt.rcParams['axes.titlesize'] = 16\n",
    "plt.rcParams['axes.labelsize'] = 15\n",
    "plt.rcParams['xtick.labelsize'] = 13\n",
    "plt.rcParams['ytick.labelsize'] = 13\n",
    "plt.rcParams['legend.fontsize'] = 12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "70b2bfca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Лабиринт</th>\n",
       "      <th>Алгоритм</th>\n",
       "      <th>Время</th>\n",
       "      <th>Посещено клеток</th>\n",
       "      <th>Длина пути</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>maze10x10</td>\n",
       "      <td>BFS</td>\n",
       "      <td>0.07440</td>\n",
       "      <td>25.0</td>\n",
       "      <td>16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>maze10x10</td>\n",
       "      <td>BFS</td>\n",
       "      <td>0.07570</td>\n",
       "      <td>25.0</td>\n",
       "      <td>16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>maze10x10</td>\n",
       "      <td>BFS</td>\n",
       "      <td>0.07270</td>\n",
       "      <td>25.0</td>\n",
       "      <td>16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>maze10x10</td>\n",
       "      <td>BFS</td>\n",
       "      <td>0.07430</td>\n",
       "      <td>25.0</td>\n",
       "      <td>16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>maze10x10</td>\n",
       "      <td>BFS</td>\n",
       "      <td>0.05370</td>\n",
       "      <td>25.0</td>\n",
       "      <td>16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>215</th>\n",
       "      <td>maze_no_path</td>\n",
       "      <td>Dijkstra</td>\n",
       "      <td>2.09330</td>\n",
       "      <td>1245.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>216</th>\n",
       "      <td>maze_no_path</td>\n",
       "      <td>Dijkstra</td>\n",
       "      <td>2.17550</td>\n",
       "      <td>1245.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>217</th>\n",
       "      <td>maze_no_path</td>\n",
       "      <td>Dijkstra</td>\n",
       "      <td>2.38650</td>\n",
       "      <td>1245.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>218</th>\n",
       "      <td>maze_no_path</td>\n",
       "      <td>Dijkstra</td>\n",
       "      <td>2.27960</td>\n",
       "      <td>1245.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>219</th>\n",
       "      <td>maze_no_path(среднее)</td>\n",
       "      <td>Dijkstra</td>\n",
       "      <td>2.19875</td>\n",
       "      <td>1245.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>220 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                  Лабиринт  Алгоритм    Время  Посещено клеток  Длина пути\n",
       "0                maze10x10       BFS  0.07440             25.0        16.0\n",
       "1                maze10x10       BFS  0.07570             25.0        16.0\n",
       "2                maze10x10       BFS  0.07270             25.0        16.0\n",
       "3                maze10x10       BFS  0.07430             25.0        16.0\n",
       "4                maze10x10       BFS  0.05370             25.0        16.0\n",
       "..                     ...       ...      ...              ...         ...\n",
       "215           maze_no_path  Dijkstra  2.09330           1245.0         0.0\n",
       "216           maze_no_path  Dijkstra  2.17550           1245.0         0.0\n",
       "217           maze_no_path  Dijkstra  2.38650           1245.0         0.0\n",
       "218           maze_no_path  Dijkstra  2.27960           1245.0         0.0\n",
       "219  maze_no_path(среднее)  Dijkstra  2.19875           1245.0         0.0\n",
       "\n",
       "[220 rows x 5 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "csv_path = 'csv/banchmark.csv'\n",
    "\n",
    "data = pd.read_csv(csv_path)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c76b78ad",
   "metadata": {},
   "outputs": [],
   "source": [
    "maze_mini_bfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_mini_bfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10(среднее)') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_mini_dfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_mini_dfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10(среднее)') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_mini_astar = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_mini_astar_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10(среднее)') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_mini_dijkstra = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_mini_dijkstra_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze10x10(среднее)') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "43185f9c",
   "metadata": {},
   "outputs": [],
   "source": [
    "maze_midl_bfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_midl_bfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50(среднее)') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_midl_dfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_midl_dfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50(среднее)') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_midl_astar = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_midl_astar_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50(среднее)') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_midl_dijkstra = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_midl_dijkstra_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze50x50(среднее)') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "dd77cde8",
   "metadata": {},
   "outputs": [],
   "source": [
    "maze_max_bfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_max_bfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100(среднее)') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_max_dfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_max_dfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100(среднее)') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_max_astar = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_max_astar_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100(среднее)') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_max_dijkstra = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_max_dijkstra_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze100x100(среднее)') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "c7bbc090",
   "metadata": {},
   "outputs": [],
   "source": [
    "maze_empty_bfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_empty_bfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty(среднее)') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_empty_dfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_empty_dfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty(среднее)') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_empty_astar = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_empty_astar_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty(среднее)') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_empty_dijkstra = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_empty_dijkstra_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_empty(среднее)') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "742bce22",
   "metadata": {},
   "outputs": [],
   "source": [
    "maze_no_path_bfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_no_path_bfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path(среднее)') & (data['Алгоритм'] == 'BFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_no_path_dfs = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_no_path_dfs_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path(среднее)') & (data['Алгоритм'] == 'DFS'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_no_path_astar = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_no_path_astar_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path(среднее)') & (data['Алгоритм'] == 'A*'),\n",
    "        'Время'\n",
    "    ].iloc[0]\n",
    "\n",
    "maze_no_path_dijkstra = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].tolist()\n",
    "maze_no_path_dijkstra_average  = data.loc[\n",
    "        (data['Лабиринт'] == 'maze_no_path(среднее)') & (data['Алгоритм'] == 'Dijkstra'),\n",
    "        'Время'\n",
    "    ].iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "1e1fa8a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "iterations = range(1, 11)\n",
    "\n",
    "\n",
    "bfs_col = 'blue'\n",
    "dfs_col = 'orange'\n",
    "AStar_col = 'green'\n",
    "Dijkstra_col = 'red'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "d6fae13f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 56916 characters]",
      "text/plain": [
       "<Figure size 1400x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14, 6))\n",
    "\n",
    "# ============= Левый график: случайные данные =============\n",
    "plt.title(\"Поиск пути в лабиринте 10x10\")\n",
    "plt.ylabel('Время, мс')\n",
    "plt.xlabel('Повторения')\n",
    "plt.xticks(iterations)\n",
    "\n",
    "# BFS\n",
    "plt.scatter(iterations, maze_mini_bfs, label='BFS', color=bfs_col)\n",
    "plt.axhline(y=maze_mini_bfs_average, color=bfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# DFS\n",
    "plt.scatter(iterations, maze_mini_dfs, label='DFS', color=dfs_col)\n",
    "plt.axhline(y=maze_mini_dfs_average, color=dfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "#  A*\n",
    "plt.scatter(iterations, maze_mini_astar, label='A*', color=AStar_col)\n",
    "plt.axhline(y=maze_mini_astar_average, color=AStar_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# Связный список\n",
    "plt.scatter(iterations, maze_mini_dijkstra, label='Дейкстра', color=Dijkstra_col)\n",
    "plt.axhline(y=maze_mini_dijkstra_average, color=Dijkstra_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "plt.legend(loc='best')\n",
    "plt.grid(True, alpha=0.3)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.savefig('img\\\\10x10.pdf',\n",
    "            format='pdf',\n",
    "            dpi=300,\n",
    "            bbox_inches='tight',  \n",
    "            pad_inches=0.1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "8ef02f9e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 58788 characters]",
      "text/plain": [
       "<Figure size 1400x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14, 6))\n",
    "\n",
    "# ============= Левый график: случайные данные =============\n",
    "plt.title(\"Поиск пути в лабиринте 50x50\")\n",
    "plt.ylabel('Время, мс')\n",
    "plt.xlabel('Повторения')\n",
    "plt.xticks(iterations)\n",
    "\n",
    "# BFS\n",
    "plt.scatter(iterations, maze_midl_bfs, label='BFS', color=bfs_col)\n",
    "plt.axhline(y=maze_midl_bfs_average, color=bfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# DFS\n",
    "plt.scatter(iterations, maze_midl_dfs, label='DFS', color=dfs_col)\n",
    "plt.axhline(y=maze_midl_dfs_average, color=dfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "#  A*\n",
    "plt.scatter(iterations, maze_midl_astar, label='A*', color=AStar_col)\n",
    "plt.axhline(y=maze_midl_astar_average, color=AStar_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# Связный список\n",
    "plt.scatter(iterations, maze_midl_dijkstra, label='Дейкстра', color=Dijkstra_col)\n",
    "plt.axhline(y=maze_midl_dijkstra_average, color=Dijkstra_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "plt.legend(loc='best')\n",
    "plt.grid(True, alpha=0.3)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.savefig('img/50x50.pdf',\n",
    "            format='pdf',\n",
    "            dpi=300,\n",
    "            bbox_inches='tight',  \n",
    "            pad_inches=0.1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "1ab3cd43",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 63872 characters]",
      "text/plain": [
       "<Figure size 1400x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14, 6))\n",
    "\n",
    "# ============= Левый график: случайные данные =============\n",
    "plt.title(\"Поиск пути в лабиринте 100x100\")\n",
    "plt.ylabel('Время, мс')\n",
    "plt.xlabel('Повторения')\n",
    "plt.xticks(iterations)\n",
    "\n",
    "# BFS\n",
    "plt.scatter(iterations, maze_max_bfs, label='BFS', color=bfs_col)\n",
    "plt.axhline(y=maze_max_bfs_average, color=bfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# DFS\n",
    "plt.scatter(iterations, maze_max_dfs, label='DFS', color=dfs_col)\n",
    "plt.axhline(y=maze_max_dfs_average, color=dfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "#  A*\n",
    "plt.scatter(iterations, maze_max_astar, label='A*', color=AStar_col)\n",
    "plt.axhline(y=maze_max_astar_average, color=AStar_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# Связный список\n",
    "plt.scatter(iterations, maze_max_dijkstra, label='Дейкстра', color=Dijkstra_col)\n",
    "plt.axhline(y=maze_max_dijkstra_average, color=Dijkstra_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "plt.legend(loc='best')\n",
    "plt.grid(True, alpha=0.3)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.savefig('img/100x100.pdf',\n",
    "            format='pdf',\n",
    "            dpi=300,\n",
    "            bbox_inches='tight',  \n",
    "            pad_inches=0.1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "5802d209",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 51528 characters]",
      "text/plain": [
       "<Figure size 1400x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14, 6))\n",
    "\n",
    "# ============= Левый график: случайные данные =============\n",
    "plt.title(\"Поиск пути в пустом лабиринте\")\n",
    "plt.ylabel('Время, мс')\n",
    "plt.xlabel('Повторения')\n",
    "plt.xticks(iterations)\n",
    "\n",
    "# BFS\n",
    "plt.scatter(iterations, maze_empty_bfs, label='BFS', color=bfs_col)\n",
    "plt.axhline(y=maze_empty_bfs_average, color=bfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# DFS\n",
    "plt.scatter(iterations, maze_empty_dfs, label='DFS', color=dfs_col)\n",
    "plt.axhline(y=maze_empty_dfs_average, color=dfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "#  A*\n",
    "plt.scatter(iterations, maze_empty_astar, label='A*', color=AStar_col)\n",
    "plt.axhline(y=maze_empty_astar_average, color=AStar_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# Связный список\n",
    "plt.scatter(iterations, maze_empty_dijkstra, label='Дейкстра', color=Dijkstra_col)\n",
    "plt.axhline(y=maze_empty_dijkstra_average, color=Dijkstra_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "plt.legend(loc='best')\n",
    "plt.grid(True, alpha=0.3)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.savefig('img/empty.pdf',\n",
    "            format='pdf',\n",
    "            dpi=300,\n",
    "            bbox_inches='tight',  \n",
    "            pad_inches=0.1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "de2b628e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 60348 characters]",
      "text/plain": [
       "<Figure size 1400x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(14, 6))\n",
    "\n",
    "# ============= Левый график: случайные данные =============\n",
    "plt.title(\"Поиск пути в лабиринте без выхода\")\n",
    "plt.ylabel('Время, мс')\n",
    "plt.xlabel('Повторения')\n",
    "plt.xticks(iterations)\n",
    "\n",
    "# BFS\n",
    "plt.scatter(iterations, maze_no_path_bfs, label='BFS', color=bfs_col)\n",
    "plt.axhline(y=maze_no_path_bfs_average, color=bfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# DFS\n",
    "plt.scatter(iterations, maze_no_path_dfs, label='DFS', color=dfs_col)\n",
    "plt.axhline(y=maze_no_path_dfs_average, color=dfs_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "#  A*\n",
    "plt.scatter(iterations, maze_no_path_astar, label='A*', color=AStar_col)\n",
    "plt.axhline(y=maze_no_path_astar_average, color=AStar_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "# Связный список\n",
    "plt.scatter(iterations, maze_no_path_dijkstra, label='Дейкстра', color=Dijkstra_col)\n",
    "plt.axhline(y=maze_no_path_dijkstra_average, color=Dijkstra_col, linewidth=1, \n",
    "            linestyle='--', alpha=0.7)\n",
    "\n",
    "plt.legend(loc='best')\n",
    "plt.grid(True, alpha=0.3)\n",
    "\n",
    "plt.tight_layout()\n",
    "plt.savefig('img/no_path.pdf',\n",
    "            format='pdf',\n",
    "            dpi=300,\n",
    "            bbox_inches='tight',  \n",
    "            pad_inches=0.1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f87691fd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
