{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c930ce7b-e060-4021-b97c-192045f17122",
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6e1c76cc-6f99-484a-b73c-c99d9d567bbd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c0dab307-2c2c-41d2-9867-ec9ba82a8099",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Loaded TOML config file successfully.\n"
     ]
    }
   ],
   "source": [
    "import networkx as nx\n",
    "from lang_main.analysis import graphs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "629f2051-7ef0-4ce0-a5ad-86b292cc20af",
   "metadata": {},
   "outputs": [],
   "source": [
    "edge_weighst = [\n",
    "    {'weight': 1},\n",
    "    {'weight': 2},\n",
    "    {'weight': 3},\n",
    "    {'weight': 4},\n",
    "    {'weight': 5},\n",
    "    {'weight': 6},\n",
    "]\n",
    "edges = [\n",
    "    (1, 2),\n",
    "    (1, 3),\n",
    "    (2, 4),\n",
    "    (3, 4),\n",
    "    (1, 4),\n",
    "    (2, 1),\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c4fd9997-1e41-49f1-b879-4b3a6571931d",
   "metadata": {},
   "outputs": [],
   "source": [
    "edges_to_add = []\n",
    "for i, edge in enumerate(edges):\n",
    "    edge = list(edge)\n",
    "    edge.append(edge_weighst[i])\n",
    "    edges_to_add.append(tuple(edge))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "bdf1c8d2-1093-420e-91fa-e2edd0cd72f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, 2, {'weight': 1}),\n",
       " (1, 3, {'weight': 2}),\n",
       " (2, 4, {'weight': 3}),\n",
       " (3, 4, {'weight': 4}),\n",
       " (1, 4, {'weight': 5}),\n",
       " (2, 1, {'weight': 6})]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "edges_to_add"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "d017b2bc-9cd3-4124-afed-c6eabc07a540",
   "metadata": {},
   "outputs": [],
   "source": [
    "G = nx.DiGraph()\n",
    "G.add_edges_from(edges_to_add)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "f8bbf276-3b07-41d6-ad74-778f09cbab96",
   "metadata": {},
   "outputs": [],
   "source": [
    "graphs.add_weighted_degree(G, 'weight', 'degree_weighted')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "d7b6f917-23f6-44a4-bc8d-125f7658e4d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutEdgeView([(1, 2), (1, 3), (1, 4), (2, 4), (2, 1), (3, 4)])"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G.edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "473e9e25-d417-4a0a-bff2-7765de516a89",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "0a48d11d-1f2b-475e-9ddf-bb9a3f67accb",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "e340377a-0df4-44ca-b18e-8b354e273eb9",
   "metadata": {},
   "outputs": [],
   "source": [
    "save_pth = Path.cwd() / 'test.graphml'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "66677ad0-a1e5-4772-a0ba-7fbeeda55297",
   "metadata": {},
   "outputs": [],
   "source": [
    "nx.write_graphml(G, save_pth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "f01ebe25-56b9-410a-a2bf-d5a6e211de7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "G_load = nx.read_graphml(save_pth, node_type=int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "10bfad35-1f96-41a1-9014-578313502e6c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutEdgeView([(1, 2), (1, 3), (1, 4), (2, 4), (2, 1), (3, 4)])"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G_load.edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "66189241-637e-4765-b6f0-6ff090b6ba0a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a1af4ba3-ced8-425f-a730-da14fd8aab8e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "1efd5f4e-fd19-46fd-bb7e-b23bec724cdd",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main.pipelines.predefined import STFR_MODEL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "50ee13e1-e10e-4efe-8706-6ca321f6cf9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "sents = [\n",
    "    'Kontrolle der Schmiernippel',\n",
    "    'Kontrolle der Schmiersysteme',\n",
    "]\n",
    "'Kontrolle der Lichtschranken\n",
    "Überprüfung der Spannrollen\n",
    "Überprüfung der Druckventile\n",
    "Kontrolle der Schmiernippel\n",
    "Kontrolle der Schmiersysteme\n",
    "Inspektion der Förderbänder\n",
    "Reinigung der Luftfilter\n",
    "Inspektion der Schutzabdeckungen\n",
    "Überprüfung der Ölstände\n",
    "'Überprüfung der Hydraulik'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ca0b4089-d8cc-4566-a9ef-ed35b55d18b0",
   "metadata": {},
   "outputs": [],
   "source": [
    "embds = STFR_MODEL.encode(sents)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cff09ea6-04b9-4544-aee5-0a7e0bbda2d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[1.0000, 0.8907],\n",
       "        [0.8907, 1.0000]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "STFR_MODEL.similarity(embds, embds)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "45dc7050-9b6e-4c62-ba87-a74fb7985933",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "384"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "STFR_MODEL.max_seq_length"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "54bf2e2a-7ada-4e4d-9e2e-1d17631e7d06",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c5d970e6-7bfd-4da0-82da-56a12e12a86c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "7dcf9e86-a7d3-436c-a705-cddb83e704bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {\n",
    "    'idx': [0,1,2,3,4],\n",
    "    'data': ['test1', 'test2', 'test3', 'test4', 'test5']\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0962d3af-e44d-4078-ac4f-dbd59e6a33eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "df1 = pd.DataFrame.from_dict(data)\n",
    "df2 = pd.DataFrame.from_dict(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "5743636e-0330-4c7b-879b-0aa8ff6bfa53",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bool((df1 == df2).all(axis=None))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d88b4e70-012e-4dfe-ad52-4210386ed8fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "4afe4713-20d5-4626-a942-e28c4eff8d0a",
   "metadata": {},
   "outputs": [],
   "source": [
    "p = Path(r'A:\\Arbeitsaufgaben\\lang-main\\tests\\_comparison_results')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "da810b1b-b5cf-4c18-ad26-eff156ccfd54",
   "metadata": {},
   "outputs": [],
   "source": [
    "p_load = p / 'merge_similarity_candidates.pkl'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "aa5774ff-5be3-4a7a-92dc-09331f12ee2d",
   "metadata": {},
   "outputs": [],
   "source": [
    "df1 = pd.read_pickle(p_load)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "e4ec576e-ec39-4981-99e7-75fdc7ac0979",
   "metadata": {},
   "outputs": [],
   "source": [
    "df2 = pd.read_pickle(p_load)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "dc24c3a0-484b-4019-8f2c-4913e36d9b1b",
   "metadata": {},
   "outputs": [],
   "source": [
    "df1_c = df1[['entry', 'len', 'num_occur', 'num_assoc_obj_ids']]\n",
    "df2_c = df2[['entry', 'len', 'num_occur', 'num_assoc_obj_ids']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "83ade5ae-95f7-4f44-afb2-e1c5a2c5694c",
   "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>entry</th>\n",
       "      <th>len</th>\n",
       "      <th>num_occur</th>\n",
       "      <th>num_assoc_obj_ids</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    entry   len  num_occur  num_assoc_obj_ids\n",
       "41   True  True       True               True\n",
       "22   True  True       True               True\n",
       "13   True  True       True               True\n",
       "6    True  True       True               True\n",
       "29   True  True       True               True\n",
       "10   True  True       True               True\n",
       "17   True  True       True               True\n",
       "61   True  True       True               True\n",
       "5    True  True       True               True"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(df1_c == df2_c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "97d6dd4a-7f3d-4459-bf42-46d0bd087ccd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "35463772-bf3c-43b4-b536-cf4456b3f0f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "from dateutil import parser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "fa9c87f8-a42c-447d-bbb3-9c9d6830bd04",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "8d6f97a6-dafa-439e-9d9e-c37515be81bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "pattern_dates = re.compile(r'(\\d{1,2}\\.)?(\\d{1,2}\\.)?([\\d]{2,4})?')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "5a1a15e7-f9bb-463f-9c83-a12ff0f8328e",
   "metadata": {},
   "outputs": [],
   "source": [
    "dates = ['22.05.', '08.2024', '22.05.2024', 'hallo', '22.1250.25']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "442beb19-06ca-46ce-9d64-2e6c632ffb3c",
   "metadata": {},
   "outputs": [],
   "source": [
    "string = '22.1250.25'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "21e4a7c2-76f4-43bd-aeed-34e52ed53db3",
   "metadata": {},
   "outputs": [],
   "source": [
    "match = pattern_dates.search(string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "3f5d75f6-58dd-43a6-abf3-80f581807554",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('22.', None, '1250')"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "match.groups()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "306bcd91-8b87-47fe-96d4-cbc2a2bbad88",
   "metadata": {},
   "outputs": [],
   "source": [
    "dates_recog = []\n",
    "for date in dates:\n",
    "    match = pattern_dates.search(date)\n",
    "    date_found = any(match.groups())\n",
    "    dates_recog.append(date_found)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "4e996e9b-8d75-4060-984e-ee439bfd5d45",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[True, True, True, False, True]"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dates_recog"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "91d4094b-f886-4056-a697-5223f157f1d3",
   "metadata": {},
   "outputs": [],
   "source": [
    "tk = graphs.TokenGraph()\n",
    "tk.add_edges_from(edges_to_add)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0dabae5f-89b6-4457-a4ef-17cc33c6d561",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8830bbd6-ce01-475b-b492-455400319a9d",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Loaded TOML config file successfully.\n"
     ]
    }
   ],
   "source": [
    "from lang_main import model_loader\n",
    "from lang_main.analysis import tokens, graphs\n",
    "\n",
    "from lang_main.types import SpacyModelTypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ee31987c-9763-4952-8d83-bf9265430e74",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\thinc\\shims\\pytorch.py:261: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
      "  model.load_state_dict(torch.load(filelike, map_location=device))\n"
     ]
    }
   ],
   "source": [
    "sentence = (\n",
    "    'Ich ging am 22.05. mit ID 0912393 schnell über die Wiese zu einem Menschen, um ihm zu helfen. '\n",
    "    'Ich konnte nicht mit ansehen, wie er Probleme beim Tragen '\n",
    "    'seiner Tasche hatte.'\n",
    ")\n",
    "model = model_loader.load_spacy(\n",
    "    model_name=SpacyModelTypes.DE_CORE_NEWS_SM,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e086ee66-95c3-4fbc-bd04-a16b0fcdb26a",
   "metadata": {},
   "outputs": [],
   "source": [
    "doc = model(sentence)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "120c886d-6f2d-48e1-a300-8f39d9771204",
   "metadata": {},
   "outputs": [],
   "source": [
    "from spacy import displacy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "30b5f152-be1f-43c6-8466-98de50a28443",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<span class=\"tex2jax_ignore\"><svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:lang=\"de\" id=\"22b603d03c644eac83cadccad8539198-0\" class=\"displacy\" width=\"5475\" height=\"662.0\" direction=\"ltr\" style=\"max-width: none; height: 662.0px; color: #000000; background: #ffffff; font-family: Arial; direction: ltr\">\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"50\">Ich</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"50\">PRON</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"225\">ging</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"225\">VERB</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"400\">am</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"400\">ADP</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"575\">22.05.</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"575\">NUM</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"750\">mit</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"750\">ADP</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"925\">ID</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"925\">X</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1100\">0912393</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1100\">NUM</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1275\">schnell</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1275\">ADV</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1450\">über</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1450\">ADP</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1625\">die</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1625\">DET</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1800\">Wiese</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1800\">NOUN</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1975\">zu</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1975\">ADP</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2150\">einem</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2150\">DET</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2325\">Menschen,</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2325\">NOUN</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2500\">um</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2500\">SCONJ</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2675\">ihm</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2675\">PRON</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2850\">zu</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2850\">PART</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"3025\">helfen.</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"3025\">VERB</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"3200\">Ich</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"3200\">PRON</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"3375\">konnte</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"3375\">AUX</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"3550\">nicht</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"3550\">PART</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"3725\">mit</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"3725\">ADV</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"3900\">ansehen,</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"3900\">VERB</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"4075\">wie</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"4075\">SCONJ</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"4250\">er</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"4250\">PRON</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"4425\">Probleme</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"4425\">NOUN</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"4600\">beim</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"4600\">ADP</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"4775\">Tragen</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"4775\">NOUN</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"4950\">seiner</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"4950\">DET</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"5125\">Tasche</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"5125\">NOUN</tspan>\n",
       "</text>\n",
       "\n",
       "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"572.0\">\n",
       "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"5300\">hatte.</tspan>\n",
       "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"5300\">VERB</tspan>\n",
       "</text>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-0\" stroke-width=\"2px\" d=\"M70,527.0 C70,439.5 200.0,439.5 200.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-0\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">sb</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M70,529.0 L62,517.0 78,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-1\" stroke-width=\"2px\" d=\"M245,527.0 C245,439.5 375.0,439.5 375.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-1\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M375.0,529.0 L383.0,517.0 367.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-2\" stroke-width=\"2px\" d=\"M420,527.0 C420,439.5 550.0,439.5 550.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-2\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M550.0,529.0 L558.0,517.0 542.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-3\" stroke-width=\"2px\" d=\"M245,527.0 C245,352.0 730.0,352.0 730.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-3\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M730.0,529.0 L738.0,517.0 722.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-4\" stroke-width=\"2px\" d=\"M770,527.0 C770,439.5 900.0,439.5 900.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-4\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M900.0,529.0 L908.0,517.0 892.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-5\" stroke-width=\"2px\" d=\"M945,527.0 C945,439.5 1075.0,439.5 1075.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-5\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M1075.0,529.0 L1083.0,517.0 1067.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-6\" stroke-width=\"2px\" d=\"M245,527.0 C245,264.5 1260.0,264.5 1260.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-6\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M1260.0,529.0 L1268.0,517.0 1252.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-7\" stroke-width=\"2px\" d=\"M245,527.0 C245,177.0 1440.0,177.0 1440.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-7\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M1440.0,529.0 L1448.0,517.0 1432.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-8\" stroke-width=\"2px\" d=\"M1645,527.0 C1645,439.5 1775.0,439.5 1775.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-8\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M1645,529.0 L1637,517.0 1653,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-9\" stroke-width=\"2px\" d=\"M1470,527.0 C1470,352.0 1780.0,352.0 1780.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-9\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M1780.0,529.0 L1788.0,517.0 1772.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-10\" stroke-width=\"2px\" d=\"M245,527.0 C245,89.5 1970.0,89.5 1970.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-10\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M1970.0,529.0 L1978.0,517.0 1962.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-11\" stroke-width=\"2px\" d=\"M2170,527.0 C2170,439.5 2300.0,439.5 2300.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-11\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M2170,529.0 L2162,517.0 2178,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-12\" stroke-width=\"2px\" d=\"M1995,527.0 C1995,352.0 2305.0,352.0 2305.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-12\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M2305.0,529.0 L2313.0,517.0 2297.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-13\" stroke-width=\"2px\" d=\"M2520,527.0 C2520,264.5 3010.0,264.5 3010.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-13\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">cp</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M2520,529.0 L2512,517.0 2528,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-14\" stroke-width=\"2px\" d=\"M2695,527.0 C2695,352.0 3005.0,352.0 3005.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-14\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">da</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M2695,529.0 L2687,517.0 2703,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-15\" stroke-width=\"2px\" d=\"M2870,527.0 C2870,439.5 3000.0,439.5 3000.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-15\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">pm</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M2870,529.0 L2862,517.0 2878,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-16\" stroke-width=\"2px\" d=\"M245,527.0 C245,2.0 3025.0,2.0 3025.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-16\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M3025.0,529.0 L3033.0,517.0 3017.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-17\" stroke-width=\"2px\" d=\"M3220,527.0 C3220,439.5 3350.0,439.5 3350.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-17\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">sb</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M3220,529.0 L3212,517.0 3228,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-18\" stroke-width=\"2px\" d=\"M3395,527.0 C3395,439.5 3525.0,439.5 3525.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-18\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">ng</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M3525.0,529.0 L3533.0,517.0 3517.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-19\" stroke-width=\"2px\" d=\"M3745,527.0 C3745,439.5 3875.0,439.5 3875.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-19\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M3745,529.0 L3737,517.0 3753,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-20\" stroke-width=\"2px\" d=\"M3395,527.0 C3395,352.0 3880.0,352.0 3880.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-20\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">oc</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M3880.0,529.0 L3888.0,517.0 3872.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-21\" stroke-width=\"2px\" d=\"M4095,527.0 C4095,89.5 5295.0,89.5 5295.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-21\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mo</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M4095,529.0 L4087,517.0 4103,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-22\" stroke-width=\"2px\" d=\"M4270,527.0 C4270,177.0 5290.0,177.0 5290.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-22\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">sb</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M4270,529.0 L4262,517.0 4278,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-23\" stroke-width=\"2px\" d=\"M4445,527.0 C4445,264.5 5285.0,264.5 5285.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-23\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">oa</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M4445,529.0 L4437,517.0 4453,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-24\" stroke-width=\"2px\" d=\"M4445,527.0 C4445,439.5 4575.0,439.5 4575.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-24\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mnr</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M4575.0,529.0 L4583.0,517.0 4567.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-25\" stroke-width=\"2px\" d=\"M4620,527.0 C4620,439.5 4750.0,439.5 4750.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-25\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M4750.0,529.0 L4758.0,517.0 4742.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-26\" stroke-width=\"2px\" d=\"M4970,527.0 C4970,439.5 5100.0,439.5 5100.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-26\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nk</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M4970,529.0 L4962,517.0 4978,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-27\" stroke-width=\"2px\" d=\"M4795,527.0 C4795,352.0 5105.0,352.0 5105.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-27\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">ag</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M5105.0,529.0 L5113.0,517.0 5097.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "\n",
       "<g class=\"displacy-arrow\">\n",
       "    <path class=\"displacy-arc\" id=\"arrow-22b603d03c644eac83cadccad8539198-0-28\" stroke-width=\"2px\" d=\"M3920,527.0 C3920,2.0 5300.0,2.0 5300.0,527.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
       "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
       "        <textPath xlink:href=\"#arrow-22b603d03c644eac83cadccad8539198-0-28\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">oc</textPath>\n",
       "    </text>\n",
       "    <path class=\"displacy-arrowhead\" d=\"M5300.0,529.0 L5308.0,517.0 5292.0,517.0\" fill=\"currentColor\"/>\n",
       "</g>\n",
       "</svg></span>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "displacy.render(doc, style=\"dep\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "944b2da6-2c2a-4a58-b0ad-b2f280b7fecb",
   "metadata": {},
   "outputs": [],
   "source": [
    "sent = list(doc.sents)[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "ad8c1f0a-c46f-4b47-99d3-fa7e254ff570",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'konnte'"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word = sent[1]\n",
    "word.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "189207d4-d0e1-4b8a-be8d-f5328f37c9da",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Ich,\n",
       " konnte,\n",
       " nicht,\n",
       " mit,\n",
       " ansehen,\n",
       " ,,\n",
       " wie,\n",
       " er,\n",
       " Probleme,\n",
       " beim,\n",
       " Tragen,\n",
       " seiner,\n",
       " Tasche,\n",
       " hatte,\n",
       " .]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(word.subtree)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "a83bdfab-4ada-482a-b0be-d093f115a6e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ich:\t\tPRON\n",
      "konnte:\t\tAUX\n",
      "nicht:\t\tPART\n",
      "mit:\t\tADV\n",
      "ansehen:\t\tVERB\n",
      ",:\t\tPUNCT\n",
      "wie:\t\tSCONJ\n",
      "er:\t\tPRON\n",
      "Probleme:\t\tNOUN\n",
      "beim:\t\tADP\n",
      "Tragen:\t\tNOUN\n",
      "seiner:\t\tDET\n",
      "Tasche:\t\tNOUN\n",
      "hatte:\t\tVERB\n",
      ".:\t\tPUNCT\n"
     ]
    }
   ],
   "source": [
    "for token in word.subtree:\n",
    "    print(f'{token}:\\t\\t{token.pos_}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "04194be3-7f30-4f02-a3ed-c2ca016652b6",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main.analysis import tokens"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "ea169167-f55e-4574-92bc-54aafc75ccc7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'ging'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "da9c5a7b-162d-4b99-b59e-f97bb765d08c",
   "metadata": {},
   "outputs": [],
   "source": [
    "rel_descs = tokens.obtain_relevant_descendants(word)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "2fefb0dc-8285-4f42-9323-23b0bc9d8cc0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0912393, schnell, Wiese, Menschen)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tuple(rel_descs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "397e088f-743b-4554-a695-65d0ddaac8ce",
   "metadata": {},
   "outputs": [],
   "source": [
    "tk_graph = graphs.TokenGraph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "fd46701c-e428-43f8-80d9-979e96094bf3",
   "metadata": {},
   "outputs": [],
   "source": [
    "tokens.add_doc_info_to_graph(tk_graph, doc, weight=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "fc860f52-4bdb-469f-be8b-901bea39224e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "NodeView(('gehen', '0912393', 'schnell', 'Wiese', 'Mensch', 'mit', 'Problem', 'Tragen', 'Tasche', 'ansehen', 'haben'))"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tk_graph.nodes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "56e49d63-7374-428f-a1b0-26e3d136ab9a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutEdgeView([('gehen', '0912393'), ('gehen', 'schnell'), ('gehen', 'Wiese'), ('gehen', 'Mensch'), ('mit', 'Problem'), ('mit', 'Tragen'), ('mit', 'Tasche'), ('Problem', 'Tragen'), ('Problem', 'Tasche'), ('Tragen', 'Tasche'), ('ansehen', 'mit'), ('ansehen', 'Problem'), ('ansehen', 'Tragen'), ('ansehen', 'Tasche'), ('haben', 'Problem'), ('haben', 'Tragen'), ('haben', 'Tasche')])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tk_graph.edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "f0056e82-4ddc-4034-afc9-c25e3c2331b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['gehen',\n",
       " '0912393',\n",
       " 'schnell',\n",
       " 'Wiese',\n",
       " 'Mensch',\n",
       " 'mit',\n",
       " 'Problem',\n",
       " 'Tragen',\n",
       " 'Tasche',\n",
       " 'ansehen',\n",
       " 'haben']"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(tk_graph.nodes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "ee506f29-a6d0-47b9-a980-0227fa1d2a59",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg, undir = graphs.pipe_rescale_graph_edge_weights(tk)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "29a82ea9-6a66-47d3-bdbf-e41284785bc9",
   "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>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0952</td>\n",
       "      <td>0.7487</td>\n",
       "      <td>0.9830</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.8959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.9538</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     1       2       3       4\n",
       "1  0.0  0.0952  0.7487  0.9830\n",
       "2  1.0  0.0000  0.0000  0.8959\n",
       "3  0.0  0.0000  0.0000  0.9538\n",
       "4  0.0  0.0000  0.0000  0.0000"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nx.to_pandas_adjacency(tkg)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "de96d4db-0c98-4957-a91d-6d12e51fe2ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'weight': np.float32(1.0)}"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "undir[2][1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "c802f550-5200-41f5-882e-a8eb780bacf3",
   "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>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0952</td>\n",
       "      <td>0.9412</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.6864</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.0952</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.8661</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.9412</td>\n",
       "      <td>0.6864</td>\n",
       "      <td>0.8661</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        1       2       3       4\n",
       "1  0.0000  1.0000  0.0952  0.9412\n",
       "2  1.0000  0.0000  0.0000  0.6864\n",
       "3  0.0952  0.0000  0.0000  0.8661\n",
       "4  0.9412  0.6864  0.8661  0.0000"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nx.to_pandas_adjacency(undir)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "84c78e9a-8b34-465c-9bc4-13b38fa0cc32",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "58fe4954-ce69-4442-b6fa-504f1466b1dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tk.has_edge(1,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "baad206f-94ab-495a-8cc2-87a873220401",
   "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>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     1    2    3    4\n",
       "1  0.0  7.0  2.0  5.0\n",
       "2  7.0  0.0  0.0  3.0\n",
       "3  2.0  0.0  0.0  4.0\n",
       "4  5.0  3.0  4.0  0.0"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nx.to_pandas_adjacency(tk.undirected)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "996a303e-02db-496a-bd23-29c92d13d260",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "print(tk.undirected.has_edge(1,2))\n",
    "print(tk.undirected.has_edge(2,1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "5dbe02a1-3883-44d7-836b-dd2c4d27f5f8",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "Graph.to_undirected() got an unexpected keyword argument 'inplace'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[52], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m filt \u001b[38;5;241m=\u001b[39m \u001b[43mgraphs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfilter_graph_by_edge_weight\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtk\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mundirected\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m6\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\src\\lang_main\\analysis\\graphs.py:230\u001b[0m, in \u001b[0;36mfilter_graph_by_edge_weight\u001b[1;34m(graph, bound_lower, bound_upper)\u001b[0m\n\u001b[0;32m    228\u001b[0m         filtered_graph\u001b[38;5;241m.\u001b[39mremove_edge(edge[\u001b[38;5;241m0\u001b[39m], edge[\u001b[38;5;241m1\u001b[39m])\n\u001b[0;32m    229\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m bound_upper \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m weight \u001b[38;5;241m>\u001b[39m bound_upper:\n\u001b[1;32m--> 230\u001b[0m         filtered_graph\u001b[38;5;241m.\u001b[39mremove_edge(edge[\u001b[38;5;241m0\u001b[39m], edge[\u001b[38;5;241m1\u001b[39m])\n\u001b[0;32m    232\u001b[0m filtered_graph\u001b[38;5;241m.\u001b[39mto_undirected(inplace\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, logging\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m    233\u001b[0m filtered_graph\u001b[38;5;241m.\u001b[39mupdate_metadata(logging\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n",
      "\u001b[1;31mTypeError\u001b[0m: Graph.to_undirected() got an unexpected keyword argument 'inplace'"
     ]
    }
   ],
   "source": [
    "filt = graphs.filter_graph_by_edge_weight(tk.undirected, 2, 6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "3d9ecb28-23ef-48ac-9cee-86ace6be7af1",
   "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>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     1    2    3    4\n",
       "1  0.0  0.0  2.0  5.0\n",
       "2  0.0  0.0  0.0  3.0\n",
       "3  2.0  0.0  0.0  4.0\n",
       "4  5.0  3.0  4.0  0.0"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nx.to_pandas_adjacency(filt.undirected)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "42345f27-585f-4498-a4cc-50d17c9f9b69",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "too many values to unpack (expected 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[54], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mfilt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43medges\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mweight\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\networkx\\classes\\reportviews.py:1095\u001b[0m, in \u001b[0;36mOutEdgeView.__getitem__\u001b[1;34m(self, e)\u001b[0m\n\u001b[0;32m   1090\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(e, \u001b[38;5;28mslice\u001b[39m):\n\u001b[0;32m   1091\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m nx\u001b[38;5;241m.\u001b[39mNetworkXError(\n\u001b[0;32m   1092\u001b[0m         \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mtype\u001b[39m(\u001b[38;5;28mself\u001b[39m)\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m does not support slicing, \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m   1093\u001b[0m         \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtry list(G.edges)[\u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;241m.\u001b[39mstart\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;241m.\u001b[39mstop\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;241m.\u001b[39mstep\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m]\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m   1094\u001b[0m     )\n\u001b[1;32m-> 1095\u001b[0m u, v \u001b[38;5;241m=\u001b[39m e\n\u001b[0;32m   1096\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m   1097\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_adjdict[u][v]\n",
      "\u001b[1;31mValueError\u001b[0m: too many values to unpack (expected 2)"
     ]
    }
   ],
   "source": [
    "filt.edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17e7c931-d94e-43cf-ac97-bb6fccc1ee70",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "7dfa028e-d2e7-4390-bd36-b08b0a591b22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filt.has_edge(1,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "1b6e6938-1546-490a-9b64-e3d2f60d188d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filt.has_edge(2,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "518cada9-561a-4b96-b750-3d500d1d28b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, 2), (1, 3), (1, 4), (2, 4), (2, 1), (3, 4)]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(tk.edges)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "9830c614-5c16-41fd-8987-be3d421da34a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'degree_weighted': 14}"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tk.nodes[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "42b2bb65-534f-4c9c-b439-d5eec4b285e0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'degree_weighted': 10}"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tk.undirected.nodes[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c937e70b-bd89-4c3b-aa09-5f0a63982c13",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3235f188-6e99-4855-aa3d-b0e04e3db319",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'num_nodes': 4,\n",
       " 'num_edges': 6,\n",
       " 'min_edge_weight': 1,\n",
       " 'max_edge_weight': 6,\n",
       " 'node_memory': 112,\n",
       " 'edge_memory': 336,\n",
       " 'total_memory': 448}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graphs.get_graph_metadata(G)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ca2ce8e8-d72a-4edf-ae42-0f79bd9d19a2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "223dc592-fa56-4536-a5c2-a166001a6aca",
   "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>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     1    2    3    4\n",
       "1  0.0  1.0  2.0  5.0\n",
       "2  6.0  0.0  0.0  3.0\n",
       "3  0.0  0.0  0.0  4.0\n",
       "4  0.0  0.0  0.0  0.0"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nx.to_pandas_adjacency(G)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "1f677da0-7416-413c-adb1-ae1384e09349",
   "metadata": {},
   "outputs": [],
   "source": [
    "G_undir = graphs.convert_graph_to_undirected(G, cast_int=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "356862fb-2383-43d9-80ba-4fe83646c9d9",
   "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>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     1    2    3    4\n",
       "1  0.0  7.0  2.0  5.0\n",
       "2  7.0  0.0  0.0  3.0\n",
       "3  2.0  0.0  0.0  4.0\n",
       "4  5.0  3.0  4.0  0.0"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nx.to_pandas_adjacency(G_undir)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "b8a3db1a-0d2a-4635-ab88-7802e2cf59e4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G_undir.is_directed()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "46001528-75b0-4fe8-a3ec-353bbd3eeeff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'weight': 7.0}"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G_undir[1][2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "cf2dcdff-f0b7-416e-9db3-c7a21ea96b96",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([{'data': {'id': 1, 'label': 1}},\n",
       "  {'data': {'id': 2, 'label': 2}},\n",
       "  {'data': {'id': 3, 'label': 3}},\n",
       "  {'data': {'id': 4, 'label': 4}},\n",
       "  {'data': {'source': 1, 'target': 2, 'weight': 1}},\n",
       "  {'data': {'source': 1, 'target': 3, 'weight': 2}},\n",
       "  {'data': {'source': 1, 'target': 4, 'weight': 5}},\n",
       "  {'data': {'source': 2, 'target': 4, 'weight': 3}},\n",
       "  {'data': {'source': 2, 'target': 1, 'weight': 6}},\n",
       "  {'data': {'source': 3, 'target': 4, 'weight': 4}}],\n",
       " {'min': 1, 'max': 6})"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "graphs.convert_graph_to_cytoscape(G)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f82481e9-873f-4657-80d3-ba75af74fa27",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TokenGraph(name: TokenGraph, number of nodes: 4, number of edges: 6)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tk.update_metadata()\n",
    "tk"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "4b806620-b469-45ef-823b-db46f8590509",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, 4), (2, 3), (3, 2), (4, 3)]"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(G.degree)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "2a41d019-1b6b-46f7-b13e-ac22da737940",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G.degree[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e99f2fb4-4c8d-4564-810d-a4b2ed9d6009",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, 4), (2, 3), (3, 2), (4, 3)]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(tk.degree)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "1368ebf6-e008-492d-8d15-fe3ed12b78a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "g_filt = graphs.filter_graph_by_node_degree(\n",
    "        tk,\n",
    "        bound_lower=3,\n",
    "        bound_upper=3,\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "de69f73e-da1d-4479-81da-006f2ce61844",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TokenGraph(name: TokenGraph, number of nodes: 2, number of edges: 1)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g_filt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b12fd64d-737e-4c68-94ea-72a817647a04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 4]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(g_filt.nodes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "21434c7c-887c-4f9f-884a-48514e2279e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "G = nx.DiGraph()\n",
    "G.add_edges_from(edges_to_add)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "2defef69-f09a-4869-984a-27b6373b17b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'weight': 1}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G[1][2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "0308a2ac-f554-4e24-9ddb-578dd588f3c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(G.edges)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15d9ce65-f9a5-40de-a737-098579f6a8ee",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7acf4be7-45f3-45e6-87f5-14343f23d610",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9139812b-74ba-45ce-adfc-e57667259692",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Loaded TOML config file successfully.\n"
     ]
    }
   ],
   "source": [
    "from lang_main import search_iterative, search_base_path\n",
    "from pathlib import Path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "35118922-3a17-4698-93bc-5292a276a4b4",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main import constants"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "341299bf-e926-4e55-8545-8805a186f49c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "WindowsPath('A:/Arbeitsaufgaben/lang-models')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "constants.MODEL_BASE_FOLDER"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "11ce4062-b229-4d88-967d-6eeb6d0135b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sentence_transformers import SentenceTransformer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "40dac543-1e53-4fd8-a192-88f3527872b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "model_kwargs = {\n",
    "    'file_name': 'onnx/model_quint8_avx2.onnx',\n",
    "    'provider': 'CPUExecutionProvider',\n",
    "    'export': False,\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "8a0eaa9f-e2d2-4106-b80b-80916e9d8bfe",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "The ONNX file model_quint8_avx2.onnx is not a regular name used in optimum.onnxruntime, the ORTModel might not behave as expected.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "215b46e3607e4530b2d8f8227367ef23",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "model_quint8_avx2.onnx:   0%|          | 0.00/23.0M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:139: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in A:\\Arbeitsaufgaben\\lang-models\\models--sentence-transformers--all-MiniLM-L6-v2. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.\n",
      "To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development\n",
      "  warnings.warn(message)\n"
     ]
    }
   ],
   "source": [
    "stfr = SentenceTransformer('all-MiniLM-L6-v2', similarity_fn_name='cosine', backend='onnx', model_kwargs=model_kwargs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cd921aca-0673-41ec-98a3-18e360a39a41",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main.constants import SPACY_MODEL_NAME"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "88173a68-7d8e-4f4c-a4ad-bbf78efaf781",
   "metadata": {},
   "outputs": [],
   "source": [
    "import importlib"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e5293976-22ab-406a-ba32-066fd7254394",
   "metadata": {},
   "outputs": [],
   "source": [
    "mod = importlib.import_module(SPACY_MODEL_NAME)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "6023a339-02da-429c-acf5-f14a56989357",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<module 'de_dep_news_trf' from 'A:\\\\Arbeitsaufgaben\\\\lang-main\\\\.venv\\\\Lib\\\\site-packages\\\\de_dep_news_trf\\\\__init__.py'>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mod"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5f4fa066-fa0f-4818-9cf9-ec28923150ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Loaded TOML config file successfully.\n"
     ]
    }
   ],
   "source": [
    "from lang_main.analysis.shared import clean_string_slim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "71286836-7eb2-4095-ab82-42d7ac7ed476",
   "metadata": {},
   "outputs": [],
   "source": [
    "string = 'Ölleckage   durch\\nundichten \\t Ölsumpf,, aber Dichtung intakt??!!!'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e8284e76-e750-458e-bb63-d59d6d57a396",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ölleckage   durch\n",
      "undichten \t Ölsumpf,, aber Dichtung intakt??!!!\n"
     ]
    }
   ],
   "source": [
    "print(string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "82e98d8f-2e24-42f9-a3ed-3b3454ae64f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Ölleckage durch undichten Ölsumpf, aber Dichtung intakt!'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clean_string_slim(string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b527b145-15d2-4961-b441-1843fe9f5c29",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "49c2e2f0-1e6d-4969-b583-8fc15b8930f9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "16ae5d5c-a0a7-400b-8e38-231c72ad27b5",
   "metadata": {},
   "outputs": [],
   "source": [
    "pattern_dates = re.compile(r'(\\d{1,2}\\.)?(\\d{1,2}\\.)?([\\d]{2,4})?')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "3b9fe636-f895-404a-819d-61198d34262d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Am  war ich essen. Am  hingegen nicht. Und  war ich allein.'"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "string = 'Am 11.02.2024 war ich essen. Am 11.12. hingegen nicht. Und 2024 war ich allein.'\n",
    "string = pattern_dates.sub('', string)\n",
    "string"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c49ab3c-e860-42af-ac0c-2f44f075e846",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f34b343b-a7b6-4a6d-8db4-7f2f71addc54",
   "metadata": {},
   "outputs": [],
   "source": [
    "from importlib.util import find_spec"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "59c32d49-5bad-4f48-b91f-f069487ff543",
   "metadata": {},
   "outputs": [],
   "source": [
    "importlib.util.find_spec('nunpy')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "dd3d9434-374d-42a4-9c08-230495d0f5a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "_has_dash: bool = True if (find_spec('dash') and find_spec('kalido')) else False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4da22bea-d086-4097-86f6-37784b59e02b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_has_dash"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "dfc51145-759e-43ee-a850-580149679c5b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "_has_py4cyto"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dbdbc7c1-4dd6-49d6-b570-3fc7eb60938f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "36aa5c9c-c29a-4a05-8854-30b086a9240e",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "b8afbf49-e61c-49ce-af53-694b01f90702",
   "metadata": {},
   "outputs": [],
   "source": [
    "curr_path = Path.cwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c353967a-2702-4370-b4f2-914ac3b950a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(curr_path.glob('./lang_main_consdfig.toml'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "48ee9b11-60fa-43d4-87de-c9a2172a563b",
   "metadata": {},
   "outputs": [],
   "source": [
    "pkg_dir = curr_path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "02d404e1-a352-44f6-a4e9-96b6aed0c3a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "WindowsPath('A:/Arbeitsaufgaben/lang-main/notebooks')"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pkg_dir"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "fc9142c2-9e59-4113-811c-7a03068857f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('A:/Arbeitsaufgaben/lang-main/notebooks'),\n",
       " WindowsPath('A:/Arbeitsaufgaben/lang-main'),\n",
       " WindowsPath('A:/Arbeitsaufgaben'),\n",
       " WindowsPath('A:/')]"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list((pkg_dir/'home.py').parents)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "ac1312bf-332f-4008-8951-c53e35f37990",
   "metadata": {},
   "outputs": [],
   "source": [
    "cfg_found = False\n",
    "for it in range(len(pkg_dir.parents)):\n",
    "    search_path = pkg_dir.parents[it]\n",
    "    res = tuple(search_path.glob(f'lang_main*.toml'))\n",
    "    if res:\n",
    "        cfg_found = True\n",
    "        target = res[0]\n",
    "        break\n",
    "    if search_path.name == 'python':\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "a9bb96cc-f8a7-4749-ae2b-62e363d18f54",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cfg_found"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "58472aba-e887-4c50-857a-894c1c5c9003",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "WindowsPath('A:/Arbeitsaufgaben/lang-main/lang_main_config.toml')"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d46b6ce8-b51b-49e0-b494-fc24fda0f73f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import py4cytoscape as p4c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6fde72d3-b95b-4d37-be71-a7d3661dd3f5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "You are connected to Cytoscape!\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'You are connected to Cytoscape!'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.cytoscape_ping()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "186c3c83-a34d-46cd-85b3-4db66a72ccf8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['v1']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.cytoscape_api_versions()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "db862248-47fe-43e3-82bf-9484d321a7ea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'apiVersion': 'v1',\n",
       " 'cytoscapeVersion': '3.10.2',\n",
       " 'automationAPIVersion': '1.9.0',\n",
       " 'py4cytoscapeVersion': '1.9.0'}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.cytoscape_version_info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "187ced81-6304-49bd-afc7-c18e656bc9a3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "af118d77-d87a-4687-be5b-e810a24c403e",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-09-12 12:20:04 +0000 | lang_main:io:INFO | Loaded TOML config file successfully.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
      "  warnings.warn(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "from lang_main import io\n",
    "from lang_main.analysis.graphs import rescale_edge_weights, get_graph_metadata\n",
    "from lang_main import model_loader\n",
    "from lang_main.types import LanguageModels\n",
    "from lang_main.constants import MODEL_LOADER_MAP\n",
    "import lang_main.pipelines.predefined as pipes\n",
    "import lang_main.render.cytoscape as cyto\n",
    "from lang_main.analysis import graphs\n",
    "\n",
    "from pathlib import Path\n",
    "import pickle\n",
    "import base64\n",
    "import os\n",
    "from logging import NullHandler\n",
    "import time\n",
    "\n",
    "import numpy as np\n",
    "import networkx as nx\n",
    "\n",
    "import py4cytoscape as p4c\n",
    "#import py4cytoscape.py4cytoscape_logger_settings as p4c_logging\n",
    "#p4c.set_summary_logger(False)\n",
    "#p4c_logging._SUMMARY_LOG_LEVEL = 'ERROR'\n",
    "# p4c_logging._DETAIL_LOG_LEVEL = 'ERROR'\n",
    "#p4c.py4cytoscape_logger.detail_logger.setLevel('ERROR')\n",
    "#p4c.py4cytoscape_logger.detail_logger.removeHandler(p4c.py4cytoscape_logger.detail_handler)\n",
    "#p4c.py4cytoscape_logger.detail_logger.addHandler(NullHandler())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "59cbcf38-6fe1-403b-9c10-f107e28185f0",
   "metadata": {},
   "outputs": [],
   "source": [
    "results = r'A:\\Arbeitsaufgaben\\lang-main\\scripts\\results\\test_20240807'\n",
    "p_res = Path(results)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "a34650ae-286f-4539-97d1-98dbecd0dafc",
   "metadata": {},
   "outputs": [],
   "source": [
    "prefilter = 'TK-GRAPH_POSTPROCESSING.pkl'\n",
    "postfilter = 'TK-GRAPH_ANALYSIS.pkl'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "313bd956-fc32-4425-9c47-daad3622528b",
   "metadata": {},
   "outputs": [],
   "source": [
    "p_pre = p_res / prefilter\n",
    "p_post = p_res / postfilter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b745044b-6152-4c69-8fab-016731d57532",
   "metadata": {},
   "outputs": [],
   "source": [
    "assert p_pre.exists()\n",
    "assert p_post.exists()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "7bd52a09-0114-4514-905f-d01d357c6a60",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-09-12 12:33:10 +0000 | lang_main:io:INFO | Loaded file successfully.\n",
      "2024-09-12 12:33:10 +0000 | lang_main:io:INFO | Loaded file successfully.\n"
     ]
    }
   ],
   "source": [
    "res_pre = io.load_pickle(p_pre)\n",
    "res_post = io.load_pickle(p_post)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "a2a9be43-9ca6-4410-93bf-1e528a8ce8b6",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg_pre = res_pre[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "7255a466-b421-465b-92a6-27a5e135e083",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg_post = res_post[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "dc259aab-ca18-4ab0-bcd0-0d9779c17f2c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "TokenGraph(name: TokenGraph, number of nodes: 7024, number of edges: 25600)\n",
      "TokenGraph(name: TokenGraph, number of nodes: 227, number of edges: 330)\n"
     ]
    }
   ],
   "source": [
    "print(tkg_pre)\n",
    "print(tkg_post)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "2faca328-80bb-4e49-be79-6c480c6ef0c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TokenGraph(name: TokenGraph, number of nodes: 351, number of edges: 603)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "BOUND = 30\n",
    "tkg_filt = graphs.filter_graph_by_edge_weight(tkg_pre, bound_lower=BOUND, bound_upper=None)\n",
    "tkg_filt = graphs.filter_graph_by_node_degree(tkg_filt, bound_lower=1, bound_upper=None)\n",
    "tkg_filt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "2fc9c0d6-06d6-4716-821c-1e213d72eb38",
   "metadata": {
    "jupyter": {
     "source_hidden": true
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "You are connected to Cytoscape!\n",
      "Applying default style...\n",
      "Applying preferred layout\n",
      "Exec time whole was 9.541292 sec\n",
      "Exec time import was 1.265542 sec\n",
      "Exec time layout was 3.962870 sec\n",
      "Exec time style was 4.312881 sec\n"
     ]
    }
   ],
   "source": [
    "t1 = time.perf_counter_ns()\n",
    "cyto.import_to_cytoscape(tkg_filt)\n",
    "t2 = time.perf_counter_ns()\n",
    "cyto.layout_network()\n",
    "t3 = time.perf_counter_ns()\n",
    "cyto.apply_style_to_network()\n",
    "t4 = time.perf_counter_ns()\n",
    "exec_time_whole = (t4 - t1) * 1e-9\n",
    "exec_time_import = (t2 - t1) * 1e-9\n",
    "exec_time_layout = (t3 - t2) * 1e-9\n",
    "exec_time_style = (t4 - t3) * 1e-9\n",
    "print(f'Exec time whole was {exec_time_whole:.6f} sec')\n",
    "print(f'Exec time import was {exec_time_import:.6f} sec')\n",
    "print(f'Exec time layout was {exec_time_layout:.6f} sec')\n",
    "print(f'Exec time style was {exec_time_style:.6f} sec')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "a68a0fb9-8cfe-4b27-9eb8-6c4895ae3f40",
   "metadata": {},
   "outputs": [],
   "source": [
    "render_pipe = pipes.build_tk_graph_render_pipe(with_subgraphs=True, export_folder=Path.cwd())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "f7fc4e3b-7470-4050-92d9-57cbc0f27f69",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-09-12 12:21:28 +0000 | lang_main:base:INFO | Starting pipeline >>Graph_Static-Rendering<<...\n",
      "You are connected to Cytoscape!\n",
      "Applying default style...\n",
      "Applying preferred layout\n",
      "No nodes selected.\n",
      "No nodes selected.\n",
      "No nodes selected.\n",
      "No nodes selected.\n",
      "2024-09-12 12:21:42 +0000 | lang_main:io:INFO | Saved file successfully under A:\\Arbeitsaufgaben\\lang-main\\notebooks\\results\\Pipe-Graph_Static-Rendering_Step-6_build_subnetworks.pkl\n",
      "2024-09-12 12:21:42 +0000 | lang_main:base:INFO | Processing pipeline >>Graph_Static-Rendering<< successfully ended after 6 steps.\n",
      "Exec time whole was 13.943395 sec\n"
     ]
    }
   ],
   "source": [
    "t1 = time.perf_counter_ns()\n",
    "render_pipe.run((tkg_filt,))\n",
    "t2 = time.perf_counter_ns()\n",
    "exec_time_whole = (t2 - t1) * 1e-9\n",
    "print(f'Exec time whole was {exec_time_whole:.6f} sec')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "46c18cbc-b7b7-427e-8001-f1db5a9679d3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f042d3d9-ea84-4b7e-baba-1d9f6e261277",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "sns.set()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f2e8f841-d577-4b98-8f72-dee9c908264b",
   "metadata": {},
   "outputs": [],
   "source": [
    "record1 = [\n",
    "    168, 203, 262, 351, 465, 726, 1122,\n",
    "    1368, 1709, 2928\n",
    "]\n",
    "record2 = [\n",
    "    225, 293, 405, 603, 857,\n",
    "    1317, 2191, 2802, 3765, 7149\n",
    "]\n",
    "record3 = [\n",
    "    12.94, 12.96, 13.55, 14.45, 15.39,\n",
    "    17.64, 22.90, 26.95, 33.82, 61.75\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ab400322-4d3e-4502-88fe-d3c68a97d8a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {\n",
    "    'nodes_num': record1,\n",
    "    'edges_num': record2,\n",
    "    'time_sec': record3,\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "459f5450-167c-430c-bded-e47c33073584",
   "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>nodes_num</th>\n",
       "      <th>edges_num</th>\n",
       "      <th>time_sec</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>168</td>\n",
       "      <td>225</td>\n",
       "      <td>12.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>203</td>\n",
       "      <td>293</td>\n",
       "      <td>12.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>262</td>\n",
       "      <td>405</td>\n",
       "      <td>13.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>351</td>\n",
       "      <td>603</td>\n",
       "      <td>14.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>465</td>\n",
       "      <td>857</td>\n",
       "      <td>15.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>726</td>\n",
       "      <td>1317</td>\n",
       "      <td>17.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1122</td>\n",
       "      <td>2191</td>\n",
       "      <td>22.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1368</td>\n",
       "      <td>2802</td>\n",
       "      <td>26.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1709</td>\n",
       "      <td>3765</td>\n",
       "      <td>33.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2928</td>\n",
       "      <td>7149</td>\n",
       "      <td>61.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   nodes_num  edges_num  time_sec\n",
       "0        168        225     12.94\n",
       "1        203        293     12.96\n",
       "2        262        405     13.55\n",
       "3        351        603     14.45\n",
       "4        465        857     15.39\n",
       "5        726       1317     17.64\n",
       "6       1122       2191     22.90\n",
       "7       1368       2802     26.95\n",
       "8       1709       3765     33.82\n",
       "9       2928       7149     61.75"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame.from_dict(data)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cf445f6c-1d52-4f2a-81df-aa1b1b7bf7cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='nodes_num', ylabel='time_sec'>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 17384 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.scatterplot(data=df, x='nodes_num', y='time_sec')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "23d5d724-24eb-4f85-b195-b3c9e804f85a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='edges_num', ylabel='time_sec'>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 18132 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.scatterplot(data=df, x='edges_num', y='time_sec')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "5bba09eb-566d-4e27-b48e-3fa56e3a3aa0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='nodes_num', ylabel='edges_num'>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 22684 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.scatterplot(data=df, x='nodes_num', y='edges_num')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ae655662-5c2e-47ec-8650-bb0146323bbc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "77ebcddb-ad7a-45eb-bff7-d35c33ca4885",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "37e5c62e-9148-41fc-b30e-bee3e41d58b9",
   "metadata": {},
   "outputs": [],
   "source": [
    "pattern = r'[(]+'\n",
    "patt = re.compile(pattern)\n",
    "pattern = r'[)]+'\n",
    "patt2 = re.compile(pattern)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "4a621bdf-f825-4f67-8525-a3d74ef426a5",
   "metadata": {},
   "outputs": [],
   "source": [
    "string = 'Test)1234 und anbei test2 (Änderung)'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "2487ade7-3b03-4e19-a15d-d150145de822",
   "metadata": {},
   "outputs": [],
   "source": [
    "string = patt.sub('\\(', string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "8e0dacf2-2a39-43ae-a1af-5484c4b1f12a",
   "metadata": {},
   "outputs": [],
   "source": [
    "string = patt2.sub('\\)', string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "99039e7c-efe5-460f-8e02-54b60e144649",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test\\)1234 und anbei test2 \\(Änderung\\)\n"
     ]
    }
   ],
   "source": [
    "print(string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "09416b7b-9dee-4517-adab-e9cfbb8c11d2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fe9ad00d-4c6e-4db9-8add-e0157cfcf18b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e70111a8-3110-4445-beb3-0848ae199d15",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "248d29c7-80a6-4854-8393-774e9ff4041c",
   "metadata": {},
   "outputs": [],
   "source": [
    "cyto.layout_network()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "8fb7a836-292d-446f-91cd-0168e6beb5b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "pre_c = tkg_pre.copy()\n",
    "post_c = tkg_post.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "c5681f05-ce64-4ef0-b8f0-db85ea9bc74e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "92690"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(post_c.edges(data='weight'))[0][2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "8bee6e03-976d-4621-bc74-c67ff4713008",
   "metadata": {},
   "outputs": [],
   "source": [
    "original = set(pre_c.edges(data='weight'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "8751ddbb-c050-4b06-adb5-d9999b2c779f",
   "metadata": {},
   "outputs": [],
   "source": [
    "ret = sorted(original, key=lambda tup: tup[2], reverse=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "54e01e8c-c56e-4a1b-b2b2-0f0250c31df2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25600"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(ret)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "id": "ed3506d5-52ea-4c44-a1b2-8ba651eef466",
   "metadata": {},
   "outputs": [],
   "source": [
    "chosen = set(ret[:300])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "c347381d-dd98-4b81-a0c7-7173b8bd20c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "300"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(chosen)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "33d07e9b-83ab-4794-81e1-472119786bcb",
   "metadata": {},
   "outputs": [],
   "source": [
    "drop = original.difference(chosen)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "b500a720-abe3-4a11-9038-bd52a294a704",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25300"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(drop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "60e37ec4-1df5-407d-8c53-f61c29e13ac6",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg_test = tkg_pre.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "4cbf8d58-60b2-4baa-aad1-a95a35b321b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg_test.remove_edges_from(drop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "8a20a28a-0ccc-4baa-ba47-88bf93a40bfa",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg_test = graphs.filter_graph_by_node_degree(tkg_test, bound_lower=1, bound_upper=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "05355584-717e-4411-8c6a-6c42d98f6274",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TokenGraph(name: TokenGraph, number of nodes: 210, number of edges: 300)"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "b8be7c17-8011-408d-a3f9-49f799d43bdf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutEdgeDataView([('Wartungstätigkeit', 'Vorgabe', 92690), ('Wartungstätigkeit', 'Maschinenhersteller', 92690), ('Wartungstätigkeit', 'Maschinenbediener', 242), ('Wartungstätigkeit', 'Laserabteilung', 242), ('Wartungstätigkeit', 'Arbeitsplan', 244), ('Wartungstätigkeit', 'abarbeiten', 242), ('Vorgabe', 'Maschinenhersteller', 92690), ('Vorgabe', 'PLEVA', 1369), ('Vorgabe', 'Wartungsplan', 2210), ('Vorgabe', 'sehen', 1905), ('Vorgabe', 'Extradatum', 1905), ('Vorgabe', 'Firma', 730), ('Vorgabe', 'Menzel', 712), ('Vorgabe', 'Vorbelegung', 527), ('Überprüfung', 'Ölabscheider', 1622), ('Überprüfung', 'Leiter', 504), ('Überprüfung', 'Kompensator', 200), ('Überprüfung', 'Verschleiß', 200), ('Überprüfung', 'Dichtigkeit', 212), ('Überprüfung', 'Akku', 165), ('Überprüfung', 'Kran', 90), ('Sichtkontrolle', 'Reinigung', 3450), ('Reinigung', 'Bedarf', 280), ('Reinigung', 'Sichtkontrolle', 239), ('Reinigung', 'Einrichtung', 239), ('Reinigung', 'Luftdruckkontrolle', 239), ('Kontrolle', 'WC-Anlage', 1265), ('Kontrolle', 'Stabbreithalter', 687), ('Kontrolle', 'Kompressorstation', 617), ('Kontrolle', 'Wasseraufbereitungsanlage', 521), ('Kontrolle', 'Heizungsanlage', 520), ('Kontrolle', 'Druckkontrolle', 487), ('Kontrolle', 'bar', 974), ('Kontrolle', 'Rieme', 198), ('Kontrolle', 'Erste-Hilfe-Koffer', 160), ('Kontrolle', 'orange', 160), ('Kontrolle', 'Gesamtanlage', 348), ('Kontrolle', 'Beschädigung', 398), ('Kontrolle', 'usw.', 398), ('Kontrolle', 'Feucht', 141), ('Kontrolle', 'Temperatursensor', 141), ('Kontrolle', 'Hilfe', 141), ('Kontrolle', 'Efficio-System', 141), ('Kontrolle', 'Pflasterschrank', 160), ('Kontrolle', 'Kühlturm', 132), ('Kontrolle', 'Reinigung', 257), ('Kontrolle', 'Schweißkopf', 107), ('Kontrolle', 'Verschleiß', 107), ('Kontrolle', 'prüfen', 107), ('Kontrolle', 'Auslassventil', 127), ('Kontrolle', 'Dampfzylinder', 127), ('Kontrolle', 'Verkalkung', 127), ('Druckkontrolle', 'bar', 974), ('machen', 'gegebenenfalls', 487), ('machen', 'Filter', 487), ('machen', 'sauber', 497), ('Analyse', 'Kesselwasser', 386), ('-', 'Speisewasser', 386), ('-', '-', 386), ('-', 'Kondensat', 386), ('überprüfen', 'Wasserverbrauch', 386), ('auffüllen', 'Desifektionsmittel', 303), ('auffüllen', 'Aschenbecher', 303), ('leeren', 'Aschenbecher', 303), ('Wartung', 'Toilette', 231), ('Wartung', 'Kühlturm', 198), ('Wartungsplan', 'PLEVA', 1369), ('Wartungsplan', 'Firma', 540), ('Wartungsplan', 'Menzel', 525), ('sehen', 'Extradatum', 1939), ('sehen', 'Arbeitsplan', 209), ('sehen', 'Vorbelegung', 533), ('Verschleiß', 'Dichtigkeit', 200), ('schmieren', 'Kontrolle', 198), ('schmieren', 'Rieme', 198), ('schmieren', 'Linearkugellager', 482), ('schmieren', 'neu', 185), ('Maschinenbediener', 'Laserabteilung', 242), ('abarbeiten', 'derzeit', 172), ('abarbeiten', 'Herr', 172), ('abarbeiten', 'Förster', 172), ('Stand', 'Stöppel', 1302), ('Stand', 'Binder', 150), ('Stand', 'KW', 90), ('Stand', 'Moser', 167), ('Stand', 'Termin', 93), ('Stand', 'Prüfung', 119), ('Stand', 'Herr', 161), ('-Leiterprüfung', 'Herr', 344), ('-Leiterprüfung', 'Buschmann', 172), ('-Leiterprüfung', 'derzeit', 172), ('-Leiterprüfung', 'Förster', 172), ('Herr', 'Buschmann', 380), ('Herr', 'derzeit', 175), ('Herr', 'Herr', 240), ('Herr', 'Förster', 695), ('Herr', 'Graf', 571), ('Herr', 'Sturm', 93), ('Herr', 'Stauner', 112), ('Buschmann', 'derzeit', 172), ('Buschmann', 'Herr', 172), ('Buschmann', 'Förster', 172), ('derzeit', 'Herr', 364), ('derzeit', 'Förster', 344), ('terminieren', 'Herr', 416), ('terminieren', 'Buschmann', 172), ('terminieren', 'Absprache', 108), ('reparieren', 'Leiter', 172), ('Prüfung', 'DGUV', 166), ('Prüfung', 'V3', 166), ('V3', 'DGUV', 166), ('Blombe', 'vorhanden', 160), ('Blombe', 'bitte', 160), ('Blombe', 'Ticket', 160), ('Blombe', 'Magazin', 160), ('Ticket', 'Magazin', 320), ('Ticket', 'Bedarf', 160), ('Ticket', 'Verbandsmaterial', 160), ('Ticket', 'bitte', 160), ('Küsters-Anlage', 'Anlage', 241), ('Küsters-Anlage', 'Leckage', 241), ('Küsters-Anlage', 'prüfen', 241), ('prüfen', 'Anlage', 591), ('prüfen', 'Leckage', 589), ('prüfen', 'Sitz', 163), ('prüfen', 'Befestigungsschraube', 132), ('prüfen', 'Verschleiß', 214), ('abschmieren', 'Lager', 241), ('Campen-Aufwickler', 'Linearkugellager', 241), ('Campen-Aufwickler', 'schmieren', 241), ('Campen-Abwickler', 'Linearkugellager', 241), ('Campen-Abwickler', 'schmieren', 241), ('Wumag-Trockner', 'Kontrolle', 241), ('Wumag-Trockner', 'Gesamtanlage', 241), ('Wumag-Trockner', 'Beschädigung', 241), ('Wumag-Trockner', 'usw.', 241), ('Gesamtanlage', 'Anlage', 107), ('Gesamtanlage', 'Leckage', 107), ('Gesamtanlage', 'prüfen', 107), ('Beschädigung', 'usw.', 398), ('Wasseraufbereitung', 'Anlage', 241), ('Wasseraufbereitung', 'Leckage', 241), ('Wasseraufbereitung', 'prüfen', 241), ('Leiterprüfung', 'derzeit', 153), ('Leiterprüfung', 'Arbeit', 153), ('Abteilungsleiter', 'Email', 153), ('Abteilungsleiter', 'Eigenverantwortlichkeit', 153), ('Abteilungsleiter', 'Mithilfe', 153), ('Abteilungsleiter', 'Herr', 155), ('Abteilungsleiter', 'Graf', 153), ('Email', 'Eigenverantwortlichkeit', 306), ('Email', 'Mithilfe', 306), ('Email', 'Herr', 306), ('Email', 'Graf', 306), ('Eigenverantwortlichkeit', 'Mithilfe', 459), ('Eigenverantwortlichkeit', 'Herr', 459), ('Eigenverantwortlichkeit', 'Graf', 459), ('Mithilfe', 'Herr', 306), ('Mithilfe', 'Graf', 306), ('informieren', 'Email', 154), ('informieren', 'Eigenverantwortlichkeit', 153), ('informieren', 'Mithilfe', 153), ('informieren', 'Herr', 171), ('informieren', 'Graf', 153), ('Feucht', 'Temperatursensor', 141), ('Hilfe', 'Efficio-System', 141), ('abgleichen', 'Messwert', 141), ('Bedarf', 'Verbandsmaterial', 160), ('Auflistung', 'Verbandsmaterial', 160), ('finden', 'Auflistung', 160), ('finden', 'Verbandsmaterial', 160), ('finden', 'Extradate', 160), ('finden', 'UTT', 160), ('finden', 'intern', 160), ('finden', 'Objekt', 160), ('Extradate', 'UTT', 160), ('Extradate', 'intern', 160), ('Extradate', 'Objekt', 160), ('UTT', 'intern', 160), ('UTT', 'Objekt', 160), ('Firma', 'Hawker', 165), ('Firma', 'Menzel', 712), ('Firma', 'MHM', 161), ('Abschmierung', 'Ventilator', 209), ('Abschmierung', 'Motor', 209), ('Ventilator', 'Motor', 221), ('Motor', 'ansonsten', 209), ('Motor', 'Bedarf', 209), ('durchführen', 'Monat', 209), ('Erledigungsdatum', 'Motor', 209), ('Erledigungsdatum', 'ansonsten', 209), ('Erledigungsdatum', 'Bedarf', 209), ('ansonsten', 'Bedarf', 209), ('anschreiben', 'Motor', 209), ('anschreiben', 'ansonsten', 209), ('anschreiben', 'Bedarf', 209), ('Wäscherkontrolle', 'Reinigung', 209), ('Wäscherkontrolle', 'Bedarf', 209), ('Wäscherkontrolle', 'Trommel', 209), ('Formplatte', 'Sitz', 107), ('Formplatte', 'Befestigungsschraube', 107), ('Formplatte', 'prüfen', 107), ('Sitz', 'Befestigungsschraube', 132), ('Gegendruckbolze', 'Verschleiß', 107), ('Gegendruckbolze', 'prüfen', 107), ('Schweißkopf', 'Verschleiß', 107), ('Schweißkopf', 'prüfen', 107), ('Karabulut', 'Sherif', 98), ('Leerung', 'Papiermüllbehälter', 106), ('Leerung', 'Keller', 106), ('Leerung', 'Personalbüro', 106), ('Keller', 'Personalbüro', 107), ('Verschmutzung', 'Fremdkörper', 164), ('Sicherstellung', 'Ausblasöffnung', 164), ('Indikator', 'Testomat', 133), ('Wartungsarbeit', 'sehen', 207), ('Wartungsarbeit', 'Arbeitsplan', 207), ('Vorbelegung', 'Extradatum', 527), ('Stehlagergehäus', 'SNI', 493), ('Stehlagergehäus', 'Nachschmieren', 493), ('Flanschlager', 'RIZ60', 493), ('Spannkopflager', 'TIU-60', 493), ('Inneneinheit', 'Kontrollieren', 127), ('Inneneinheit', 'Fileren', 127), ('Inneneinheit', 'Verschmutzung', 127), ('Kontrollieren', 'Fileren', 127), ('Kontrollieren', 'Verschmutzung', 127), ('Kontrollieren', 'Temperatur', 127), ('Kontrollieren', 'Feucht', 127), ('Außeneinheit', 'Luftansaugseite', 127), ('Außeneinheit', 'Sauberkeit', 127), ('Außeneinheit', 'Filter', 127), ('Außeneinheit', 'kontrollieren', 127), ('Luftansaugseite', 'Sauberkeit', 127), ('Luftansaugseite', 'Filter', 127), ('Luftansaugseite', 'kontrollieren', 127), ('Sauberkeit', 'Filter', 127), ('kontrollieren', 'Sauberkeit', 127), ('kontrollieren', 'Filter', 127), ('achten', 'Laufgeräusch', 127), ('Befeuchter', 'Kontrollieren', 127), ('Befeuchter', 'Feucht', 127), ('Auslassventil', 'Dampfzylinder', 127), ('Einrichtung', 'Luftdruckkontrolle', 240), ('anfragen', 'Termin', 361), ('anfragen', 'Schneider', 361), ('Termin', 'Schneider', 360), ('reinigen', 'SAE50', 185), ('reinigen', 'Bedarf', 185), ('reinigen', 'Woche', 185), ('reinigen', 'Monat', 185), ('reinigen', 'neu', 186), ('Uhr', 'ca.', 119), ('Lagerung', 'Palette', 282), ('Lagerung', 'Fach', 188), ('Lagerung', 'Hochregal', 188), ('Lagerung', 'Halle', 188), ('Lagerung', 'so', 188), ('Lagerung', 'zulässig', 188), ('Palette', 'Fach', 141), ('Palette', 'Hochregal', 141), ('Palette', 'Halle', 141), ('Palette', 'so', 188), ('Palette', 'zulässig', 188), ('Fach', 'Hochregal', 188), ('Fach', 'Halle', 188), ('Fach', 'so', 141), ('Fach', 'zulässig', 141), ('Hochregal', 'Halle', 188), ('Hochregal', 'so', 141), ('Hochregal', 'zulässig', 141), ('Halle', 'so', 141), ('Halle', 'zulässig', 141), ('so', 'zulässig', 188), ('zulässig', 'so', 94), ('noch', 'Haus', 107), ('Prüfbericht', 'noch', 189), ('Prüfbericht', 'Haus', 108), ('Absprache', 'Herr', 238), ('tauschen', 'Lager', 211), ('Rauwalze', 'Einziehwalze', 1275), ('Rauwalze', 'neu', 637), ('Einziehwalze', 'neu', 636), ('überziehen', 'neu', 678), ('erfolgen', 'Prüfung', 125), ('Baugruppe', 'Pos-Nr', 185), ('Baugruppe', 'Nr.', 185), ('Baugruppe', 'Stückliste', 185), ('Nr.', 'Stückliste', 185), ('ME-Nummer', 'Bezeichnung', 185), ('verbauen', 'Hersteller', 185), ('verbauen', 'Anzahl', 185), ('verbauen', 'Schmierstoff', 185), ('Wartungsintervall', 'Wechselintervall', 185), ('Rollenkette-zweifach', 'Öl', 185), ('SAE50', 'Bedarf', 185), ('Kettbaum', 'Gewind', 270), ('Kettbaum', 'nachschneiden', 270), ('nachschneiden', 'Gewind', 279), ('laufen', 'Maschine', 93)])"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg_test.edges(data='weight')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11040820-9dce-4acd-b9ce-113dc1857084",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "9fb559ca-658f-4fd7-943b-5509eacccb56",
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = {1,2,3}\n",
    "s2 = {1,2,3,4,5,6}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "0e093317-d708-4dda-a2b2-aaf31f237594",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{4, 5, 6}"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2.difference(s1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f151211e-dcfb-4fa5-8590-0d4b5b75efc5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6c49661f-5cb0-4a55-97c6-98ef562aba3d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "000ea2c0-8ec4-45c2-a69b-8ff0f27bd742",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2d91512f-8976-452e-acc9-4bff3dc33dd1",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<spacy.lang.de.German at 0x24040684090>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model_loader.instantiate_model(MODEL_LOADER_MAP, LanguageModels.SPACY)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7fe9337f-a11b-4eab-ae46-a8a4ccf3f461",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4256081a-6364-4e8f-8cfd-799912ca6b94",
   "metadata": {},
   "outputs": [],
   "source": [
    "res_path = Path(r'A:\\Arbeitsaufgaben\\lang-main\\scripts\\results\\test_20240619')\n",
    "assert res_path.exists()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e9a92ad6-5e63-49c4-b9e7-9f81da8549fe",
   "metadata": {},
   "outputs": [],
   "source": [
    "#obj = 'TK-GRAPH_POSTPROCESSING.pkl'\n",
    "obj = 'TK-GRAPH_ANALYSIS.pkl'\n",
    "load_pth = res_path / obj\n",
    "assert load_pth.exists()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c2421d89-ed8c-41dd-b363-ad5b5b716704",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-24 06:14:16 +0000 | io:INFO | Loaded file successfully.\n"
     ]
    }
   ],
   "source": [
    "ret = io.load_pickle(load_pth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ca25a7f2-84af-4b5e-89d6-b139fca35617",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg = ret[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ff7e7ab6-67d9-4a2c-b668-cf10740f7542",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TokenGraph(name: TokenGraph, number of nodes: 158, number of edges: 192)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "66901689-8b95-400a-b2fb-11d3ea215512",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg.rescaled_weights"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "842e01fa-29cd-4028-9461-c7af24e01c33",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'degree_weighted': 186350}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg.nodes['Wartungstätigkeit']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "8d36d22e-73fd-44fe-ab08-98f8186bc6b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'degree_weighted': 186350}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg.undirected.nodes['Wartungstätigkeit']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "1e61aca3-efea-4e38-8174-5ca4b2585256",
   "metadata": {},
   "outputs": [],
   "source": [
    "obj = 'TK-GRAPH_POSTPROCESSING.pkl'\n",
    "# obj = 'TK-GRAPH_ANALYSIS.pkl'\n",
    "load_pth = res_path / obj\n",
    "assert load_pth.exists()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5d83c04c-03ab-4086-a4e9-ae430e4c6090",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-19 05:56:10 +0000 | io:INFO | Loaded file successfully.\n"
     ]
    }
   ],
   "source": [
    "ret = io.load_pickle(load_pth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "4718b54e-0891-4f70-8c67-90c439bc8bfd",
   "metadata": {},
   "outputs": [],
   "source": [
    "tkg = ret[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ddcb4ff0-eac4-45ba-9c6e-83ada4b0276c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "TokenGraph(name: TokenGraph, number of nodes: 6859, number of edges: 25499)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "3d514552-3b55-41d1-af80-a1b559711608",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tkg.rescaled_weights"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b73844e0-4242-4a8c-b552-48f10df34cc0",
   "metadata": {},
   "outputs": [],
   "source": [
    "directed, undirected = tkg.rescale_edge_weights()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "593b9f87-4e9f-45e4-9367-55347924357b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'num_nodes': 6859,\n",
       " 'num_edges': 25499,\n",
       " 'min_edge_weight': 0.0952,\n",
       " 'max_edge_weight': 1.0,\n",
       " 'node_memory': 433996,\n",
       " 'edge_memory': 1427944,\n",
       " 'total_memory': 1861940}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "directed.metadata_directed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "aed4354a-69e4-4215-bd4b-a6c7c37c3ac5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'num_nodes': 6859,\n",
       " 'num_edges': 24796,\n",
       " 'min_edge_weight': 1,\n",
       " 'max_edge_weight': 92690,\n",
       " 'node_memory': 433996,\n",
       " 'edge_memory': 1388576,\n",
       " 'total_memory': 1822572}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "directed.metadata_undirected"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "587de2ae-26ed-42f5-a8bd-104f9cbf1490",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'num_nodes': 6859,\n",
       " 'num_edges': 24796,\n",
       " 'min_edge_weight': 0.0952,\n",
       " 'max_edge_weight': 1.0,\n",
       " 'node_memory': 433996,\n",
       " 'edge_memory': 1388576,\n",
       " 'total_memory': 1822572}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_graph_metadata(undirected)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "859be6a3-a919-433a-a0a7-f4d74cdc6bf7",
   "metadata": {},
   "source": [
    "break_early = False\n",
    "i = 0\n",
    "for idx, (node1, node2) in enumerate(list(Gtest.edges)):\n",
    "    if break_early and i == 10:\n",
    "        break\n",
    "    Gtest[node1][node2]['weight'] = adjusted_weights[idx]\n",
    "    \n",
    "    i += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "f381b25a-6149-4a2a-876c-4cbd8bb9bd04",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wartungstätigkeit Vorgabe 1.0\n",
      "Wartungstätigkeit Maschinenhersteller 1.0\n",
      "Wartungstätigkeit Maschinenbediener 0.8215\n",
      "Wartungstätigkeit Laserabteilung 0.8215\n",
      "Wartungstätigkeit Arbeitsplan 0.8219\n",
      "Wartungstätigkeit abarbeiten 0.8215\n",
      "Wartungstätigkeit Webmaschinenkontrollliste 0.2534\n",
      "Wartungstätigkeit sehen 0.2534\n",
      "Vorgabe Maschinenhersteller 1.0\n",
      "Vorgabe Wartungsplan 0.9181\n"
     ]
    }
   ],
   "source": [
    "break_early = True\n",
    "i = 0\n",
    "for n1, n2, w in directed.edges.data('weight'):\n",
    "    if break_early and i == 10:\n",
    "        break\n",
    "    print(n1, n2, w)\n",
    "\n",
    "    i += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a7929935-3bd2-4eb8-907c-4d37251f11ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wartungstätigkeit Vorgabe 1.0\n",
      "Wartungstätigkeit Maschinenhersteller 1.0\n",
      "Wartungstätigkeit sehen 0.2534\n",
      "Wartungstätigkeit Maschinenbediener 0.8215\n",
      "Wartungstätigkeit Laserabteilung 0.8215\n",
      "Wartungstätigkeit Arbeitsplan 0.8219\n",
      "Wartungstätigkeit abarbeiten 0.8215\n",
      "Wartungstätigkeit Webmaschinenkontrollliste 0.2534\n",
      "Vorgabe Maschinenhersteller 1.0\n",
      "Vorgabe Wartungsplan 0.9181\n"
     ]
    }
   ],
   "source": [
    "break_early = True\n",
    "i = 0\n",
    "for n1, n2, w in undirected.edges.data('weight'):\n",
    "    if break_early and i == 10:\n",
    "        break\n",
    "    print(n1, n2, w)\n",
    "\n",
    "    i += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b2e2cbbe-68ef-4ea0-9ed0-b114be1efd08",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "55665c2f-9a86-47f4-9125-557666e1f541",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "# Load re-scaled Token Graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2a3be1eb-b289-46ab-8d70-53110ad2806c",
   "metadata": {},
   "outputs": [],
   "source": [
    "#obj = 'TK-GRAPH_POSTPROCESSING.pkl'\n",
    "obj = 'TK-GRAPH_ANALYSIS_RESCALED.pkl'\n",
    "load_pth = res_path / obj\n",
    "assert load_pth.exists()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "64d8ba18-b1e2-470d-8bf5-9dd7cfec31de",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-24 06:14:31 +0000 | io:INFO | Loaded file successfully.\n"
     ]
    }
   ],
   "source": [
    "ret = io.load_pickle(load_pth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d80522a0-c13a-42d3-af9d-8e10914c7831",
   "metadata": {},
   "outputs": [],
   "source": [
    "tk_resc = ret[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "4a19d096-27f8-4626-97ee-31c0f84a294f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'num_nodes': 158,\n",
       " 'num_edges': 189,\n",
       " 'min_edge_weight': 0.0952,\n",
       " 'max_edge_weight': 1.0,\n",
       " 'node_memory': 9908,\n",
       " 'edge_memory': 10584,\n",
       " 'total_memory': 20492}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_graph_metadata(tk_resc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "86fe9b96-2e96-4a6c-a511-6a9c16b8fd63",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Wartungstätigkeit 3.1190000474452972\n",
      "Vorgabe 4.145399987697601\n",
      "Maschinenhersteller 2.0\n",
      "Sichtkontrolle 0.8227999806404114\n",
      "Reinigung 1.7093999981880188\n",
      "Überprüfung 2.0071999728679657\n",
      "Ölabscheider 0.7318999767303467\n",
      "Kontrolle 6.2471999898552895\n",
      "C-Anlage 0.6929000020027161\n",
      "Stabbreithalter 0.5758000016212463\n"
     ]
    }
   ],
   "source": [
    "break_early = True\n",
    "n = 10\n",
    "\n",
    "for idx, (node, weighted_degree) in enumerate(tk_resc.degree(weight='weight')):\n",
    "    if break_early and idx == n:\n",
    "        break\n",
    "    print(node, weighted_degree)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 312,
   "id": "420fd2db-98d0-48df-8a01-b4355778a6e9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Wartungstätigkeit': 3.1190000474452972,\n",
       " 'Vorgabe': 4.145399987697601,\n",
       " 'Maschinenhersteller': 2.0,\n",
       " 'Sichtkontrolle': 0.8227999806404114,\n",
       " 'Reinigung': 1.7093999981880188,\n",
       " 'Überprüfung': 2.0071999728679657,\n",
       " 'Ölabscheider': 0.7318999767303467,\n",
       " 'Kontrolle': 6.2471999898552895,\n",
       " 'C-Anlage': 0.6929000020027161,\n",
       " 'Stabbreithalter': 0.5758000016212463,\n",
       " 'Scharniere': 0.7002999782562256,\n",
       " '--': 0.7002999782562256,\n",
       " 'Schließvorrichtung': 0.7059999704360962,\n",
       " 'Schloß': 0.7059999704360962,\n",
       " 'Kompressorstation': 0.5514000058174133,\n",
       " 'Wasseraufbereitungsanlage': 0.5105999708175659,\n",
       " 'Heizungsanlage': 0.5101000070571899,\n",
       " 'Druckkontrolle': 1.140199989080429,\n",
       " 'bar': 1.2935999631881714,\n",
       " 'machen': 1.4854000210762024,\n",
       " 'gegebenenfalls': 0.4934000074863434,\n",
       " 'Filter': 0.4934000074863434,\n",
       " 'sauber': 0.4986000061035156,\n",
       " 'Leiter': 0.6482000052928925,\n",
       " 'Analyse': 0.42980000376701355,\n",
       " 'Kesselwasser': 0.42980000376701355,\n",
       " 'überprüfen': 0.42980000376701355,\n",
       " 'Wasserverbrauch': 0.42980000376701355,\n",
       " 'auffüllen': 0.7113999724388123,\n",
       " 'Desifektionsmittel': 0.35569998621940613,\n",
       " 'Aschenbecher': 0.7113999724388123,\n",
       " 'leeren': 0.35569998621940613,\n",
       " 'Wartung': 0.46550001204013824,\n",
       " 'Toilette': 0.2621000111103058,\n",
       " 'Wartungsplan': 2.1448000073432922,\n",
       " 'sehen': 3.650799944996834,\n",
       " 'Extradatum': 3.2020999789237976,\n",
       " 'Kompensator': 0.20739999413490295,\n",
       " 'Verschleiß': 0.6553999930620193,\n",
       " 'Dichtigkeit': 0.4373999983072281,\n",
       " 'Kühlturm': 0.20340000092983246,\n",
       " 'schmieren': 1.4377999901771545,\n",
       " 'Rieme': 0.4068000018596649,\n",
       " 'Maschinenbediener': 0.5580000281333923,\n",
       " 'Laserabteilung': 0.5580000281333923,\n",
       " 'Arbeitsplan': 0.7273000031709671,\n",
       " 'abarbeiten': 0.7170000076293945,\n",
       " 'Küsters-Anlage': 0.6922999918460846,\n",
       " 'Anlage': 0.6487999856472015,\n",
       " 'Leckage': 0.7812000215053558,\n",
       " 'prüfen': 1.5511000156402588,\n",
       " 'abschmieren': 0.4147999882698059,\n",
       " 'Lager': 0.4318999946117401,\n",
       " 'Campen-Aufwickler': 0.20739999413490295,\n",
       " 'Linearkugellager': 0.4399999976158142,\n",
       " 'Campen-Abwickler': 0.20739999413490295,\n",
       " 'Wumag-Trockner': 0.20739999413490295,\n",
       " 'Gesamtanlage': 0.3847000002861023,\n",
       " 'Beschädigung': 0.8136000037193298,\n",
       " 'usw.': 0.8136000037193298,\n",
       " 'Stand': 0.9007999897003174,\n",
       " 'Stöppel': 0.6636999845504761,\n",
       " '-Leiterprüfung': 0.8335999846458435,\n",
       " 'Herr': 5.480200096964836,\n",
       " 'Buschmann': 1.108900010585785,\n",
       " 'derzeit': 1.4514999985694885,\n",
       " 'Förster': 1.411899983882904,\n",
       " 'terminieren': 0.44359999895095825,\n",
       " 'reparieren': 0.1459999978542328,\n",
       " 'Akku': 0.1282999962568283,\n",
       " 'Firma': 3.6372000351548195,\n",
       " 'Hawker': 0.1282999962568283,\n",
       " 'Prüfung': 0.23270000517368317,\n",
       " 'V': 0.1177000030875206,\n",
       " 'Erste-Hilfe-Koffer': 0.11500000208616257,\n",
       " 'orange': 0.11500000208616257,\n",
       " 'Blombe': 0.46000000834465027,\n",
       " 'vorhanden': 0.11500000208616257,\n",
       " 'bitte': 0.11500000208616257,\n",
       " 'Ticket': 0.48810001462697983,\n",
       " 'Magazin': 0.48810001462697983,\n",
       " 'Leiterprüfung': 0.19040000438690186,\n",
       " 'Arbeit': 0.09520000219345093,\n",
       " 'Abteilungsleiter': 0.48180001229047775,\n",
       " 'Email': 1.6289000436663628,\n",
       " 'Eigenverantwortlichkeit': 1.9827000498771667,\n",
       " 'Mithilfe': 1.7449000477790833,\n",
       " 'Graf': 1.884600043296814,\n",
       " 'informieren': 0.5197000131011009,\n",
       " 'Pflasterschrank': 0.11500000208616257,\n",
       " 'Bedarf': 0.8617000207304955,\n",
       " 'Verbandsmaterial': 0.3450000062584877,\n",
       " 'Auflistung': 0.23000000417232513,\n",
       " 'finden': 0.5750000104308128,\n",
       " 'Extradate': 0.3450000062584877,\n",
       " 'intern': 0.23000000417232513,\n",
       " 'Objekt': 0.23000000417232513,\n",
       " 'Wartungsarbeit': 0.4415999948978424,\n",
       " 'Einrichtung': 0.2759999930858612,\n",
       " 'Luftdruckkontrolle': 0.2759999930858612,\n",
       " 'Abschmierung': 0.49140000343322754,\n",
       " 'Ventilator': 0.49140000343322754,\n",
       " 'Motor': 0.9828000068664551,\n",
       " 'durchführen': 0.24570000171661377,\n",
       " 'Monat': 0.4219000041484833,\n",
       " 'Erledigungsdatum': 0.24570000171661377,\n",
       " 'anschreiben': 0.24570000171661377,\n",
       " 'Wechseln': 0.504800021648407,\n",
       " 'V-Röhre': 0.2524000108242035,\n",
       " 'Betriebsstunde': 0.2524000108242035,\n",
       " 'Wäscherkontrolle': 0.49140000343322754,\n",
       " 'Sitz': 0.15800000727176666,\n",
       " 'Verschmutzung': 0.1256999969482422,\n",
       " 'Sicherstellung': 0.1256999969482422,\n",
       " 'Ausblasöffnung': 0.1256999969482422,\n",
       " 'Fremdkörper': 0.1256999969482422,\n",
       " 'anfragen': 0.45570001006126404,\n",
       " 'Termin': 0.45570001006126404,\n",
       " 'Menzel': 0.5950000286102295,\n",
       " 'Vorbelegung': 1.5947999954223633,\n",
       " 'Stehlagergehäuse': 0.4966000020503998,\n",
       " 'M': 0.1177000030875206,\n",
       " 'Moser': 0.2371000051498413,\n",
       " 'Lagerung': 1.2455999702215195,\n",
       " 'Palette': 0.6974999904632568,\n",
       " 'Fach': 0.5480999797582626,\n",
       " 'Hochregal': 0.5480999797582626,\n",
       " 'Halle': 0.5480999797582626,\n",
       " 'so': 0.5480999797582626,\n",
       " 'zulässig': 0.5480999797582626,\n",
       " 'tauschen': 0.22450000047683716,\n",
       " 'reinigen': 0.530799999833107,\n",
       " 'Rauwalze': 1.255899965763092,\n",
       " 'Einziehwalze': 1.2551999688148499,\n",
       " 'neu': 2.048299953341484,\n",
       " 'überziehen': 0.573199987411499,\n",
       " 'erfolgen': 0.11500000208616257,\n",
       " 'Absprache': 0.09809999912977219,\n",
       " 'Baugruppe': 0.704800009727478,\n",
       " 'Pos.-Nr': 0.352400004863739,\n",
       " 'Nr.': 0.5286000072956085,\n",
       " 'Stückliste': 0.5286000072956085,\n",
       " 'E-Nummer': 0.1762000024318695,\n",
       " 'Bezeichnung': 0.1762000024318695,\n",
       " 'verbauen': 0.352400004863739,\n",
       " 'Hersteller': 0.1762000024318695,\n",
       " 'Anzahl': 0.1762000024318695,\n",
       " 'Schmierstoffmenge': 0.1762000024318695,\n",
       " 'max.': 0.1762000024318695,\n",
       " 'Wartungsintervall': 0.1762000024318695,\n",
       " 'Wechselintervall': 0.1762000024318695,\n",
       " 'Rollenkette-zweifach': 0.1762000024318695,\n",
       " 'Öl': 0.1762000024318695,\n",
       " 'E50': 0.1762000024318695,\n",
       " 'Woche': 0.1762000024318695,\n",
       " 'Kettbaum': 0.6245999932289124,\n",
       " 'Gewind': 0.6347000002861023,\n",
       " 'nachschneiden': 0.6347000002861023}"
      ]
     },
     "execution_count": 312,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict(tk_resc.degree(weight='weight'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "cafbd812-3292-4610-8fb4-0e230a3e63f4",
   "metadata": {},
   "outputs": [],
   "source": [
    "nx.set_node_attributes(tk_resc, dict(tk_resc.degree(weight='weight')), name='weight_degree')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "fac462a9-4fe0-408b-9fea-9bf3b05ac7a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'weight_degree': 3.1190000474452972}\n",
      "{'weight_degree': 4.145399987697601}\n",
      "{'weight_degree': 2.0}\n",
      "{'weight_degree': 0.8227999806404114}\n",
      "{'weight_degree': 1.7093999981880188}\n",
      "{'weight_degree': 2.0071999728679657}\n",
      "{'weight_degree': 0.7318999767303467}\n",
      "{'weight_degree': 6.2471999898552895}\n",
      "{'weight_degree': 0.6929000020027161}\n",
      "{'weight_degree': 0.5758000016212463}\n"
     ]
    }
   ],
   "source": [
    "break_early = True\n",
    "n = 10\n",
    "\n",
    "for idx, node in enumerate(tk_resc.nodes):\n",
    "    if break_early and idx == n:\n",
    "        break\n",
    "    print(tk_resc.nodes[node])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86699c31-5679-4baa-a52a-d7e97dd77761",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "781d2906-f2cb-447a-b8b9-c82d9ae7e29f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "You are connected to Cytoscape!\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'You are connected to Cytoscape!'"
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#import py4cytoscape as p4c\n",
    "p4c.cytoscape_ping()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "2262166f-8fc6-468d-a808-1ff79ac0a70a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['lang_main']"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_collection_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "635ef0b3-0e22-4565-92ba-c1e50ff1c6ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.networks.delete_all_networks()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 182,
   "id": "2db0ecc6-15aa-49a7-baca-bee8a3faa27e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 182,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.networks.delete_network('test3')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "id": "986a01f1-1b98-4d6b-bf4b-83d0ef306425",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "id": "fcc82b82-1bb5-484f-9d49-75de18ebddd4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 208,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.networks.delete_all_networks()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 209,
   "id": "28b25e27-ed77-4c23-84d5-e3dec004e4fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Applying default style...\n",
      "Applying preferred layout\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "20743"
      ]
     },
     "execution_count": 209,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "p4c.create_network_from_networkx(tk_resc, title=BASE_NAME, collection='lang_main')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 210,
   "id": "a4871473-83b3-44ed-a6b0-45453975cdd6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'networkTitle': 'test (undirected)',\n",
       " 'nodeCount': '158',\n",
       " 'edgeCount': '189',\n",
       " 'avNeighbors': '2.3684210526315788',\n",
       " 'diameter': '10',\n",
       " 'radius': '5',\n",
       " 'avSpl': '3.7965860597439547',\n",
       " 'cc': '0.3375',\n",
       " 'density': '0.06401137980085347',\n",
       " 'heterogeneity': '1.0891156226526975',\n",
       " 'centralization': '0.38888888888888895',\n",
       " 'ncc': '27',\n",
       " 'time': '0.003'}"
      ]
     },
     "execution_count": 210,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.tools.analyze_network(directed=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c0dc5a0-0686-459b-9e98-50ab8238ecb2",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "70104956-06d4-461b-ab4d-312d868f6e98",
   "metadata": {},
   "outputs": [],
   "source": [
    "BASE_NETWORK_NAME = 'test'\n",
    "\n",
    "def import_to_cytoscape(graph):\n",
    "    p4c.networks.delete_all_networks()\n",
    "    p4c.create_network_from_networkx(graph, title=BASE_NETWORK_NAME, collection='lang_main')\n",
    "    p4c.tools.analyze_network(directed=False)\n",
    "\n",
    "\n",
    "def reset_current_network_to_base():\n",
    "    p4c.set_current_network(BASE_NETWORK_NAME)\n",
    "\n",
    "\n",
    "def export_network_to_image(filename, filetype='SVG', network_name=BASE_NETWORK_NAME):\n",
    "    target_folder = Path.cwd() / 'results'\n",
    "    if not target_folder.exists():\n",
    "        target_folder.mkdir(parents=True)\n",
    "    file_pth = target_folder / filename\n",
    "\n",
    "    text_as_font = True\n",
    "    if filetype == 'SVG':\n",
    "        text_as_font = False\n",
    "\n",
    "    p4c.export_image(filename=str(file_pth), type=filetype, network=network_name, overwrite_file=True, all_graphics_details=True, export_text_as_font=text_as_font, page_size='A4')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "2c240f53-0f6c-4de3-adcb-7be4f051ca2a",
   "metadata": {},
   "outputs": [],
   "source": [
    "LAYOUT_NAME = 'force-directed'\n",
    "LAYOUT_PROPERTIES = {\n",
    "    'numIterations': 1000,\n",
    "    'defaultSpringCoefficient': 1e-4,\n",
    "    'defaultSpringLength': 45,\n",
    "    'defaultNodeMass': 11,\n",
    "    'isDeterministic': True,\n",
    "    'singlePartition': False,\n",
    "}\n",
    "PATH_STYLESHEET = Path('lang_main.xml')\n",
    "STYLESHEET_NAME = 'lang_main'\n",
    "\n",
    "def layout_network(layout_name=LAYOUT_NAME, layout_properties=LAYOUT_PROPERTIES, network_name=BASE_NETWORK_NAME):\n",
    "    p4c.set_layout_properties(layout_name, layout_properties)\n",
    "    p4c.layout_network(layout_name=layout_name, network=network_name)\n",
    "    p4c.fit_content(selected_only=False, network=network_name)\n",
    "\n",
    "\n",
    "def apply_style_to_network(pth_to_stylesheet=PATH_STYLESHEET, network_name=BASE_NETWORK_NAME):\n",
    "    styles_avail = p4c.get_visual_style_names()\n",
    "    if STYLESHEET_NAME not in styles_avail:\n",
    "        p4c.import_visual_styles(pth_to_stylesheet)\n",
    "\n",
    "    p4c.set_visual_style(STYLESHEET_NAME, network=network_name)\n",
    "    p4c.fit_content(selected_only=False, network=network_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "9759f36d-761f-45fc-a9d2-157aef08c1bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "SELECTION_PROPERTY = 'node_selection'\n",
    "SELECTION_NUMBER = 5\n",
    "ITER_NEIGHBOUR_DEPTH = 2\n",
    "\n",
    "def get_sub_node_selection(network_name=BASE_NETWORK_NAME):\n",
    "    node_table = p4c.get_table_columns(network=network_name)\n",
    "    node_table['stress_norm'] = node_table['Stress'] / node_table['Stress'].max()\n",
    "    node_table[SELECTION_PROPERTY] = node_table['weight_degree'] * node_table['BetweennessCentrality'] * node_table['stress_norm']\n",
    "    node_table = node_table.sort_values(by=SELECTION_PROPERTY, ascending=False)\n",
    "    node_table_choice = node_table.iloc[:SELECTION_NUMBER,:]\n",
    "\n",
    "    return node_table_choice['SUID'].to_list()\n",
    "\n",
    "\n",
    "def select_neighbours_of_node(node, network_name=BASE_NETWORK_NAME):\n",
    "    p4c.clear_selection(network=network_name)\n",
    "    p4c.select_nodes(node, network=network_name)\n",
    "\n",
    "    for _ in range(ITER_NEIGHBOUR_DEPTH):\n",
    "        _ = p4c.select_first_neighbors(network=network_name)\n",
    "\n",
    "    _ = p4c.select_edges_connecting_selected_nodes()\n",
    "\n",
    "\n",
    "def make_subnetwork(index, network_name=BASE_NETWORK_NAME, export_image=True):\n",
    "    subnetwork_name = network_name + f'_sub_{index+1}'\n",
    "    p4c.create_subnetwork(nodes='selected', edges='selected', subnetwork_name=subnetwork_name, network=network_name)\n",
    "    p4c.set_current_network(subnetwork_name)\n",
    "    p4c.fit_content(selected_only=False, network=network_name)\n",
    "    if export_image:\n",
    "        export_network_to_image(filename=subnetwork_name, network_name=subnetwork_name)\n",
    "\n",
    "\n",
    "def build_subnetworks(nodes_to_analyse, network_name=BASE_NETWORK_NAME, export_image=True):\n",
    "    for idx, node in enumerate(nodes_to_analyse):\n",
    "        select_neighbours_of_node(node=node, network_name=network_name)\n",
    "        make_subnetwork(index=idx, network_name=network_name, export_image=export_image)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "c7dc0828-ea07-4bfe-b8e7-2dc97a5107db",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = p4c.get_table_columns()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "d7117506-7f2d-4a0d-ac19-cd55996bdfd6",
   "metadata": {},
   "outputs": [],
   "source": [
    "data['test2'] = data['degree_weighted'] * 1000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "1e2389d4-283b-458a-a6a0-dfbf5ee1a00e",
   "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>SUID</th>\n",
       "      <th>shared name</th>\n",
       "      <th>name</th>\n",
       "      <th>selected</th>\n",
       "      <th>AverageShortestPathLength</th>\n",
       "      <th>BetweennessCentrality</th>\n",
       "      <th>ClosenessCentrality</th>\n",
       "      <th>ClusteringCoefficient</th>\n",
       "      <th>Degree</th>\n",
       "      <th>Eccentricity</th>\n",
       "      <th>...</th>\n",
       "      <th>PartnerOfMultiEdgedNodePairs</th>\n",
       "      <th>Radiality</th>\n",
       "      <th>SelfLoops</th>\n",
       "      <th>Stress</th>\n",
       "      <th>TopologicalCoefficient</th>\n",
       "      <th>id</th>\n",
       "      <th>degree_weighted</th>\n",
       "      <th>row.names</th>\n",
       "      <th>test</th>\n",
       "      <th>test2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>257</th>\n",
       "      <td>257</td>\n",
       "      <td>anschreiben</td>\n",
       "      <td>anschreiben</td>\n",
       "      <td>False</td>\n",
       "      <td>1.750000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.812500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>anschreiben</td>\n",
       "      <td>0.2457</td>\n",
       "      <td>257</td>\n",
       "      <td>245.700002</td>\n",
       "      <td>245.700002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>259</th>\n",
       "      <td>259</td>\n",
       "      <td>Erledigungsdatum</td>\n",
       "      <td>Erledigungsdatum</td>\n",
       "      <td>False</td>\n",
       "      <td>1.750000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.812500</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Erledigungsdatum</td>\n",
       "      <td>0.2457</td>\n",
       "      <td>259</td>\n",
       "      <td>245.700002</td>\n",
       "      <td>245.700002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>261</th>\n",
       "      <td>261</td>\n",
       "      <td>Monat</td>\n",
       "      <td>Monat</td>\n",
       "      <td>False</td>\n",
       "      <td>4.945946</td>\n",
       "      <td>0.054054</td>\n",
       "      <td>0.202186</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2</td>\n",
       "      <td>9</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.753378</td>\n",
       "      <td>0</td>\n",
       "      <td>72</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>Monat</td>\n",
       "      <td>0.4219</td>\n",
       "      <td>261</td>\n",
       "      <td>421.900004</td>\n",
       "      <td>421.900004</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>263</th>\n",
       "      <td>263</td>\n",
       "      <td>durchführen</td>\n",
       "      <td>durchführen</td>\n",
       "      <td>False</td>\n",
       "      <td>5.918919</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.168950</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1</td>\n",
       "      <td>10</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.692568</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>durchführen</td>\n",
       "      <td>0.2457</td>\n",
       "      <td>263</td>\n",
       "      <td>245.700002</td>\n",
       "      <td>245.700002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>265</th>\n",
       "      <td>265</td>\n",
       "      <td>Motor</td>\n",
       "      <td>Motor</td>\n",
       "      <td>False</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.833333</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>10</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>Motor</td>\n",
       "      <td>0.9828</td>\n",
       "      <td>265</td>\n",
       "      <td>982.800007</td>\n",
       "      <td>982.800007</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>247</th>\n",
       "      <td>247</td>\n",
       "      <td>Sitz</td>\n",
       "      <td>Sitz</td>\n",
       "      <td>False</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Sitz</td>\n",
       "      <td>0.1580</td>\n",
       "      <td>247</td>\n",
       "      <td>158.000007</td>\n",
       "      <td>158.000007</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>249</th>\n",
       "      <td>249</td>\n",
       "      <td>Wäscherkontrolle</td>\n",
       "      <td>Wäscherkontrolle</td>\n",
       "      <td>False</td>\n",
       "      <td>3.459459</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.289062</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.846284</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>Wäscherkontrolle</td>\n",
       "      <td>0.4914</td>\n",
       "      <td>249</td>\n",
       "      <td>491.400003</td>\n",
       "      <td>491.400003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>251</th>\n",
       "      <td>251</td>\n",
       "      <td>Betriebsstunde</td>\n",
       "      <td>Betriebsstunde</td>\n",
       "      <td>False</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Betriebsstunde</td>\n",
       "      <td>0.2524</td>\n",
       "      <td>251</td>\n",
       "      <td>252.400011</td>\n",
       "      <td>252.400011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>253</th>\n",
       "      <td>253</td>\n",
       "      <td>V-Röhre</td>\n",
       "      <td>V-Röhre</td>\n",
       "      <td>False</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>V-Röhre</td>\n",
       "      <td>0.2524</td>\n",
       "      <td>253</td>\n",
       "      <td>252.400011</td>\n",
       "      <td>252.400011</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>255</th>\n",
       "      <td>255</td>\n",
       "      <td>Wechseln</td>\n",
       "      <td>Wechseln</td>\n",
       "      <td>False</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Wechseln</td>\n",
       "      <td>0.5048</td>\n",
       "      <td>255</td>\n",
       "      <td>504.800022</td>\n",
       "      <td>504.800022</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>158 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     SUID       shared name              name  selected  \\\n",
       "257   257       anschreiben       anschreiben     False   \n",
       "259   259  Erledigungsdatum  Erledigungsdatum     False   \n",
       "261   261             Monat             Monat     False   \n",
       "263   263       durchführen       durchführen     False   \n",
       "265   265             Motor             Motor     False   \n",
       "..    ...               ...               ...       ...   \n",
       "247   247              Sitz              Sitz     False   \n",
       "249   249  Wäscherkontrolle  Wäscherkontrolle     False   \n",
       "251   251    Betriebsstunde    Betriebsstunde     False   \n",
       "253   253           V-Röhre           V-Röhre     False   \n",
       "255   255          Wechseln          Wechseln     False   \n",
       "\n",
       "     AverageShortestPathLength  BetweennessCentrality  ClosenessCentrality  \\\n",
       "257                   1.750000               0.000000             0.571429   \n",
       "259                   1.750000               0.000000             0.571429   \n",
       "261                   4.945946               0.054054             0.202186   \n",
       "263                   5.918919               0.000000             0.168950   \n",
       "265                   1.000000               0.833333             1.000000   \n",
       "..                         ...                    ...                  ...   \n",
       "247                   3.000000               0.000000             0.333333   \n",
       "249                   3.459459               0.000000             0.289062   \n",
       "251                   1.500000               0.000000             0.666667   \n",
       "253                   1.500000               0.000000             0.666667   \n",
       "255                   1.000000               1.000000             1.000000   \n",
       "\n",
       "     ClusteringCoefficient  Degree  Eccentricity  ...  \\\n",
       "257               0.000000       1             2  ...   \n",
       "259               0.000000       1             2  ...   \n",
       "261               0.000000       2             9  ...   \n",
       "263               0.000000       1            10  ...   \n",
       "265               0.166667       4             1  ...   \n",
       "..                     ...     ...           ...  ...   \n",
       "247               0.000000       1             5  ...   \n",
       "249               1.000000       2             7  ...   \n",
       "251               0.000000       1             2  ...   \n",
       "253               0.000000       1             2  ...   \n",
       "255               0.000000       2             1  ...   \n",
       "\n",
       "     PartnerOfMultiEdgedNodePairs  Radiality  SelfLoops  Stress  \\\n",
       "257                             0   0.812500          0       0   \n",
       "259                             0   0.812500          0       0   \n",
       "261                             0   0.753378          0      72   \n",
       "263                             0   0.692568          0       0   \n",
       "265                             0   1.000000          0      10   \n",
       "..                            ...        ...        ...     ...   \n",
       "247                             0   0.666667          0       0   \n",
       "249                             0   0.846284          0       0   \n",
       "251                             0   0.750000          0       0   \n",
       "253                             0   0.750000          0       0   \n",
       "255                             0   1.000000          0       2   \n",
       "\n",
       "     TopologicalCoefficient                id  degree_weighted  row.names  \\\n",
       "257                0.000000       anschreiben           0.2457        257   \n",
       "259                0.000000  Erledigungsdatum           0.2457        259   \n",
       "261                0.500000             Monat           0.4219        261   \n",
       "263                0.000000       durchführen           0.2457        263   \n",
       "265                0.500000             Motor           0.9828        265   \n",
       "..                      ...               ...              ...        ...   \n",
       "247                0.000000              Sitz           0.1580        247   \n",
       "249                0.666667  Wäscherkontrolle           0.4914        249   \n",
       "251                0.000000    Betriebsstunde           0.2524        251   \n",
       "253                0.000000           V-Röhre           0.2524        253   \n",
       "255                0.000000          Wechseln           0.5048        255   \n",
       "\n",
       "           test       test2  \n",
       "257  245.700002  245.700002  \n",
       "259  245.700002  245.700002  \n",
       "261  421.900004  421.900004  \n",
       "263  245.700002  245.700002  \n",
       "265  982.800007  982.800007  \n",
       "..          ...         ...  \n",
       "247  158.000007  158.000007  \n",
       "249  491.400003  491.400003  \n",
       "251  252.400011  252.400011  \n",
       "253  252.400011  252.400011  \n",
       "255  504.800022  504.800022  \n",
       "\n",
       "[158 rows x 24 columns]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "facae316-6acb-4094-9eef-19bead44a813",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "1. import network\n",
    "2. layouting\n",
    "3. apply styles\n",
    "4. export image\n",
    "5. build subgraphs\n",
    "    1. get candidates\n",
    "    2. build subnetwork\n",
    "    3. export subnetwork"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 305,
   "id": "583d304d-571f-43f5-b8eb-905a01ddaec4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Applying default style...\n",
      "Applying preferred layout\n"
     ]
    }
   ],
   "source": [
    "import_to_cytoscape(tk_resc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 306,
   "id": "b13f2eb2-fa1e-495c-8e77-e992f78a69b6",
   "metadata": {},
   "outputs": [],
   "source": [
    "layout_network()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 307,
   "id": "60c1ca0f-ac73-4545-bffa-7eb656ade8fa",
   "metadata": {},
   "outputs": [],
   "source": [
    "apply_style_to_network()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 308,
   "id": "8cc5f1c0-0bb4-4e77-ba70-83ef449f37c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "export_network_to_image(filename=BASE_NETWORK_NAME)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "040c4439-3c46-4d48-92ed-af9614f90cb0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 309,
   "id": "da0f7a3f-c7e5-4c50-85d9-16a90ff69011",
   "metadata": {},
   "outputs": [],
   "source": [
    "nodes_to_analyse = get_sub_node_selection()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 310,
   "id": "27a9cbc3-d852-4f5d-a6ee-92f97cf10db1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No nodes selected.\n",
      "No nodes selected.\n",
      "No nodes selected.\n",
      "No nodes selected.\n"
     ]
    }
   ],
   "source": [
    "build_subnetworks(nodes_to_analyse=nodes_to_analyse, export_image=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39a61348-f2b6-4bf8-bc71-5d77e38bef47",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "fae73cc5-ac29-463d-8ea3-87a1c8072932",
   "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>SUID</th>\n",
       "      <th>shared name</th>\n",
       "      <th>name</th>\n",
       "      <th>selected</th>\n",
       "      <th>id</th>\n",
       "      <th>degree_weighted</th>\n",
       "      <th>AverageShortestPathLength</th>\n",
       "      <th>ClusteringCoefficient</th>\n",
       "      <th>ClosenessCentrality</th>\n",
       "      <th>IsSingleNode</th>\n",
       "      <th>...</th>\n",
       "      <th>Stress</th>\n",
       "      <th>Degree</th>\n",
       "      <th>BetweennessCentrality</th>\n",
       "      <th>NeighborhoodConnectivity</th>\n",
       "      <th>NumberOfDirectedEdges</th>\n",
       "      <th>NumberOfUndirectedEdges</th>\n",
       "      <th>Radiality</th>\n",
       "      <th>TopologicalCoefficient</th>\n",
       "      <th>stress_norm</th>\n",
       "      <th>node_selection</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>16385</th>\n",
       "      <td>16385</td>\n",
       "      <td>Fremdkörper</td>\n",
       "      <td>Fremdkörper</td>\n",
       "      <td>False</td>\n",
       "      <td>Fremdkörper</td>\n",
       "      <td>0.1257</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16130</th>\n",
       "      <td>16130</td>\n",
       "      <td>Aschenbecher</td>\n",
       "      <td>Aschenbecher</td>\n",
       "      <td>False</td>\n",
       "      <td>Aschenbecher</td>\n",
       "      <td>0.7114</td>\n",
       "      <td>1.333333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.75</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.833333</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.002275</td>\n",
       "      <td>0.001079</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16388</th>\n",
       "      <td>16388</td>\n",
       "      <td>anfragen</td>\n",
       "      <td>anfragen</td>\n",
       "      <td>False</td>\n",
       "      <td>anfragen</td>\n",
       "      <td>0.4557</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16133</th>\n",
       "      <td>16133</td>\n",
       "      <td>leeren</td>\n",
       "      <td>leeren</td>\n",
       "      <td>False</td>\n",
       "      <td>leeren</td>\n",
       "      <td>0.3557</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.50</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16391</th>\n",
       "      <td>16391</td>\n",
       "      <td>Termin</td>\n",
       "      <td>Termin</td>\n",
       "      <td>False</td>\n",
       "      <td>Termin</td>\n",
       "      <td>0.4557</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16121</th>\n",
       "      <td>16121</td>\n",
       "      <td>Wasserverbrauch</td>\n",
       "      <td>Wasserverbrauch</td>\n",
       "      <td>False</td>\n",
       "      <td>Wasserverbrauch</td>\n",
       "      <td>0.4298</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16379</th>\n",
       "      <td>16379</td>\n",
       "      <td>Sicherstellung</td>\n",
       "      <td>Sicherstellung</td>\n",
       "      <td>False</td>\n",
       "      <td>Sicherstellung</td>\n",
       "      <td>0.1257</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16124</th>\n",
       "      <td>16124</td>\n",
       "      <td>auffüllen</td>\n",
       "      <td>auffüllen</td>\n",
       "      <td>False</td>\n",
       "      <td>auffüllen</td>\n",
       "      <td>0.7114</td>\n",
       "      <td>1.333333</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.75</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.833333</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.002275</td>\n",
       "      <td>0.001079</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16382</th>\n",
       "      <td>16382</td>\n",
       "      <td>Ausblasöffnung</td>\n",
       "      <td>Ausblasöffnung</td>\n",
       "      <td>False</td>\n",
       "      <td>Ausblasöffnung</td>\n",
       "      <td>0.1257</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.00</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16127</th>\n",
       "      <td>16127</td>\n",
       "      <td>Desifektionsmittel</td>\n",
       "      <td>Desifektionsmittel</td>\n",
       "      <td>False</td>\n",
       "      <td>Desifektionsmittel</td>\n",
       "      <td>0.3557</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.50</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>158 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        SUID         shared name                name  selected  \\\n",
       "16385  16385         Fremdkörper         Fremdkörper     False   \n",
       "16130  16130        Aschenbecher        Aschenbecher     False   \n",
       "16388  16388            anfragen            anfragen     False   \n",
       "16133  16133              leeren              leeren     False   \n",
       "16391  16391              Termin              Termin     False   \n",
       "...      ...                 ...                 ...       ...   \n",
       "16121  16121     Wasserverbrauch     Wasserverbrauch     False   \n",
       "16379  16379      Sicherstellung      Sicherstellung     False   \n",
       "16124  16124           auffüllen           auffüllen     False   \n",
       "16382  16382      Ausblasöffnung      Ausblasöffnung     False   \n",
       "16127  16127  Desifektionsmittel  Desifektionsmittel     False   \n",
       "\n",
       "                       id  degree_weighted  AverageShortestPathLength  \\\n",
       "16385         Fremdkörper           0.1257                   1.000000   \n",
       "16130        Aschenbecher           0.7114                   1.333333   \n",
       "16388            anfragen           0.4557                   1.000000   \n",
       "16133              leeren           0.3557                   2.000000   \n",
       "16391              Termin           0.4557                   1.000000   \n",
       "...                   ...              ...                        ...   \n",
       "16121     Wasserverbrauch           0.4298                   1.000000   \n",
       "16379      Sicherstellung           0.1257                   1.000000   \n",
       "16124           auffüllen           0.7114                   1.333333   \n",
       "16382      Ausblasöffnung           0.1257                   1.000000   \n",
       "16127  Desifektionsmittel           0.3557                   2.000000   \n",
       "\n",
       "       ClusteringCoefficient  ClosenessCentrality  IsSingleNode  ...  Stress  \\\n",
       "16385                    0.0                 1.00         False  ...       0   \n",
       "16130                    0.0                 0.75         False  ...       4   \n",
       "16388                    0.0                 1.00         False  ...       0   \n",
       "16133                    0.0                 0.50         False  ...       0   \n",
       "16391                    0.0                 1.00         False  ...       0   \n",
       "...                      ...                  ...           ...  ...     ...   \n",
       "16121                    0.0                 1.00         False  ...       0   \n",
       "16379                    0.0                 1.00         False  ...       0   \n",
       "16124                    0.0                 0.75         False  ...       4   \n",
       "16382                    0.0                 1.00         False  ...       0   \n",
       "16127                    0.0                 0.50         False  ...       0   \n",
       "\n",
       "       Degree  BetweennessCentrality  NeighborhoodConnectivity  \\\n",
       "16385       1               0.000000                       1.0   \n",
       "16130       2               0.666667                       1.5   \n",
       "16388       1               0.000000                       1.0   \n",
       "16133       1               0.000000                       2.0   \n",
       "16391       1               0.000000                       1.0   \n",
       "...       ...                    ...                       ...   \n",
       "16121       1               0.000000                       1.0   \n",
       "16379       1               0.000000                       1.0   \n",
       "16124       2               0.666667                       1.5   \n",
       "16382       1               0.000000                       1.0   \n",
       "16127       1               0.000000                       2.0   \n",
       "\n",
       "       NumberOfDirectedEdges  NumberOfUndirectedEdges  Radiality  \\\n",
       "16385                      0                        1   1.000000   \n",
       "16130                      0                        2   0.833333   \n",
       "16388                      0                        1   1.000000   \n",
       "16133                      0                        1   0.500000   \n",
       "16391                      0                        1   1.000000   \n",
       "...                      ...                      ...        ...   \n",
       "16121                      0                        1   1.000000   \n",
       "16379                      0                        1   1.000000   \n",
       "16124                      0                        2   0.833333   \n",
       "16382                      0                        1   1.000000   \n",
       "16127                      0                        1   0.500000   \n",
       "\n",
       "       TopologicalCoefficient  stress_norm  node_selection  \n",
       "16385                     0.0     0.000000        0.000000  \n",
       "16130                     0.5     0.002275        0.001079  \n",
       "16388                     0.0     0.000000        0.000000  \n",
       "16133                     0.0     0.000000        0.000000  \n",
       "16391                     0.0     0.000000        0.000000  \n",
       "...                       ...          ...             ...  \n",
       "16121                     0.0     0.000000        0.000000  \n",
       "16379                     0.0     0.000000        0.000000  \n",
       "16124                     0.5     0.002275        0.001079  \n",
       "16382                     0.0     0.000000        0.000000  \n",
       "16127                     0.0     0.000000        0.000000  \n",
       "\n",
       "[158 rows x 23 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = p4c.get_table_columns()\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "4b1e0799-59ac-431d-9e3f-8752bb0a4be5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "min_val=0.0, max_val=3.008924891341149\n"
     ]
    }
   ],
   "source": [
    "min_val = data['node_selection'].min()\n",
    "max_val = data['node_selection'].max()\n",
    "print(f'{min_val=}, {max_val=}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "6d2e939c-7218-4449-a0de-8679f57f43b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "scheme = p4c.scheme_c_number_continuous(start_value=15, end_value=40)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "17f6c3f1-4584-47ed-b563-2e71b6850184",
   "metadata": {},
   "outputs": [],
   "source": [
    "node_size_map = p4c.gen_node_size_map('node_selection', number_scheme=scheme, mapping_type='c', style_name='lang_main', default_number=18)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "842b04be-f434-4530-afac-22c892e1fc83",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'table_column': 'node_selection',\n",
       " 'table_column_values': [0.0, 1.5044624456705744, 3.008924891341149],\n",
       " 'sizes': [15, 27.5, 40],\n",
       " 'mapping_type': 'c',\n",
       " 'default_size': 18,\n",
       " 'style_name': 'lang_main',\n",
       " 'network': None,\n",
       " 'base_url': 'http://127.0.0.1:1234/v1'}"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "node_size_map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "34dd3ada-c65b-4914-a918-e1798ef4e88b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.set_node_size_mapping(**node_size_map)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d5b6c04b-dfe1-4cfc-bf0a-8251a9367a81",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "74749a78-1afb-4158-8ab4-05b18b59e39e",
   "metadata": {},
   "outputs": [],
   "source": [
    "test = dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9ec4f934-8ea5-401f-9f2f-86de478cec01",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "jo\n"
     ]
    }
   ],
   "source": [
    "if not test:\n",
    "    print('jo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "97905d05-483c-4e9a-b88d-00353ada870b",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main.render.cytoscape import layout_network"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "900868b3-7e3a-44c7-bef4-53c5a3e63e63",
   "metadata": {},
   "outputs": [],
   "source": [
    "layout_network()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d3369d18-0e29-4dc3-a7ba-bab8b356282f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 296,
   "id": "1dbbf2a3-6de3-4557-8966-40f12c55d755",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "41497"
      ]
     },
     "execution_count": 296,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "IDX = 0\n",
    "nodes_to_select[IDX]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 297,
   "id": "3b3eebe1-90e8-429d-8099-96f6e59f7e18",
   "metadata": {},
   "outputs": [],
   "source": [
    "select_neighbours_of_node(nodes_to_select[IDX])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 300,
   "id": "c1b46f42-5837-4a77-9d7c-5780bd5057be",
   "metadata": {},
   "outputs": [],
   "source": [
    "build_subnetwork(IDX)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0558b387-e1c4-43b8-aa3c-4d3a182856f4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3f215f7a-2cec-4ea8-8fc7-6b217fb3df7f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de481ea5-db5d-46ba-9eed-e7da476d895f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "261bf119-4757-4840-a0b9-0d3d4fb77dd9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8b5dfc7f-44fd-4f7b-a8a8-0cd3c73449b4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 190,
   "id": "2ce067f3-9647-489d-934e-fcdf1a2561f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "node_table = p4c.get_table_columns(network=BASE_NAME)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 191,
   "id": "f4490242-0aac-46af-a913-08a627815587",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 191,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(node_table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "id": "9bf840a7-e533-42e2-936a-2678f6bfc4ca",
   "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>SUID</th>\n",
       "      <th>shared name</th>\n",
       "      <th>name</th>\n",
       "      <th>selected</th>\n",
       "      <th>id</th>\n",
       "      <th>weight_degree</th>\n",
       "      <th>AverageShortestPathLength</th>\n",
       "      <th>ClusteringCoefficient</th>\n",
       "      <th>ClosenessCentrality</th>\n",
       "      <th>IsSingleNode</th>\n",
       "      <th>...</th>\n",
       "      <th>SelfLoops</th>\n",
       "      <th>Eccentricity</th>\n",
       "      <th>Stress</th>\n",
       "      <th>Degree</th>\n",
       "      <th>BetweennessCentrality</th>\n",
       "      <th>NeighborhoodConnectivity</th>\n",
       "      <th>NumberOfDirectedEdges</th>\n",
       "      <th>NumberOfUndirectedEdges</th>\n",
       "      <th>Radiality</th>\n",
       "      <th>TopologicalCoefficient</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>18610</th>\n",
       "      <td>18610</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>False</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>6.2472</td>\n",
       "      <td>2.270270</td>\n",
       "      <td>0.025000</td>\n",
       "      <td>0.440476</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>1062</td>\n",
       "      <td>16</td>\n",
       "      <td>0.797297</td>\n",
       "      <td>1.812500</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>0.920608</td>\n",
       "      <td>0.091346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18778</th>\n",
       "      <td>18778</td>\n",
       "      <td>Herr</td>\n",
       "      <td>Herr</td>\n",
       "      <td>False</td>\n",
       "      <td>Herr</td>\n",
       "      <td>5.4802</td>\n",
       "      <td>3.114286</td>\n",
       "      <td>0.294872</td>\n",
       "      <td>0.321101</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>962</td>\n",
       "      <td>15</td>\n",
       "      <td>0.402857</td>\n",
       "      <td>4.692308</td>\n",
       "      <td>0</td>\n",
       "      <td>14</td>\n",
       "      <td>0.837363</td>\n",
       "      <td>0.329670</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18799</th>\n",
       "      <td>18799</td>\n",
       "      <td>Firma</td>\n",
       "      <td>Firma</td>\n",
       "      <td>False</td>\n",
       "      <td>Firma</td>\n",
       "      <td>3.6372</td>\n",
       "      <td>3.571429</td>\n",
       "      <td>0.127273</td>\n",
       "      <td>0.280000</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>1328</td>\n",
       "      <td>11</td>\n",
       "      <td>0.401681</td>\n",
       "      <td>2.818182</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "      <td>0.802198</td>\n",
       "      <td>0.223140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18694</th>\n",
       "      <td>18694</td>\n",
       "      <td>sehen</td>\n",
       "      <td>sehen</td>\n",
       "      <td>False</td>\n",
       "      <td>sehen</td>\n",
       "      <td>3.6508</td>\n",
       "      <td>3.114286</td>\n",
       "      <td>0.333333</td>\n",
       "      <td>0.321101</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>1034</td>\n",
       "      <td>7</td>\n",
       "      <td>0.281793</td>\n",
       "      <td>4.571429</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0.837363</td>\n",
       "      <td>0.268908</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18712</th>\n",
       "      <td>18712</td>\n",
       "      <td>schmieren</td>\n",
       "      <td>schmieren</td>\n",
       "      <td>False</td>\n",
       "      <td>schmieren</td>\n",
       "      <td>1.4378</td>\n",
       "      <td>2.621622</td>\n",
       "      <td>0.066667</td>\n",
       "      <td>0.381443</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>626</td>\n",
       "      <td>6</td>\n",
       "      <td>0.469970</td>\n",
       "      <td>4.333333</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0.898649</td>\n",
       "      <td>0.183333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19048</th>\n",
       "      <td>19048</td>\n",
       "      <td>E50</td>\n",
       "      <td>E50</td>\n",
       "      <td>False</td>\n",
       "      <td>E50</td>\n",
       "      <td>0.1762</td>\n",
       "      <td>4.243243</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.235669</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.797297</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19045</th>\n",
       "      <td>19045</td>\n",
       "      <td>Öl</td>\n",
       "      <td>Öl</td>\n",
       "      <td>False</td>\n",
       "      <td>Öl</td>\n",
       "      <td>0.1762</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19042</th>\n",
       "      <td>19042</td>\n",
       "      <td>Rollenkette-zweifach</td>\n",
       "      <td>Rollenkette-zweifach</td>\n",
       "      <td>False</td>\n",
       "      <td>Rollenkette-zweifach</td>\n",
       "      <td>0.1762</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19039</th>\n",
       "      <td>19039</td>\n",
       "      <td>Wechselintervall</td>\n",
       "      <td>Wechselintervall</td>\n",
       "      <td>False</td>\n",
       "      <td>Wechselintervall</td>\n",
       "      <td>0.1762</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18943</th>\n",
       "      <td>18943</td>\n",
       "      <td>Menzel</td>\n",
       "      <td>Menzel</td>\n",
       "      <td>False</td>\n",
       "      <td>Menzel</td>\n",
       "      <td>0.5950</td>\n",
       "      <td>4.542857</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.220126</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>11.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.727473</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>158 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        SUID           shared name                  name  selected  \\\n",
       "18610  18610             Kontrolle             Kontrolle     False   \n",
       "18778  18778                  Herr                  Herr     False   \n",
       "18799  18799                 Firma                 Firma     False   \n",
       "18694  18694                 sehen                 sehen     False   \n",
       "18712  18712             schmieren             schmieren     False   \n",
       "...      ...                   ...                   ...       ...   \n",
       "19048  19048                   E50                   E50     False   \n",
       "19045  19045                    Öl                    Öl     False   \n",
       "19042  19042  Rollenkette-zweifach  Rollenkette-zweifach     False   \n",
       "19039  19039      Wechselintervall      Wechselintervall     False   \n",
       "18943  18943                Menzel                Menzel     False   \n",
       "\n",
       "                         id  weight_degree  AverageShortestPathLength  \\\n",
       "18610             Kontrolle         6.2472                   2.270270   \n",
       "18778                  Herr         5.4802                   3.114286   \n",
       "18799                 Firma         3.6372                   3.571429   \n",
       "18694                 sehen         3.6508                   3.114286   \n",
       "18712             schmieren         1.4378                   2.621622   \n",
       "...                     ...            ...                        ...   \n",
       "19048                   E50         0.1762                   4.243243   \n",
       "19045                    Öl         0.1762                   1.000000   \n",
       "19042  Rollenkette-zweifach         0.1762                   1.000000   \n",
       "19039      Wechselintervall         0.1762                   1.000000   \n",
       "18943                Menzel         0.5950                   4.542857   \n",
       "\n",
       "       ClusteringCoefficient  ClosenessCentrality  IsSingleNode  ...  \\\n",
       "18610               0.025000             0.440476         False  ...   \n",
       "18778               0.294872             0.321101         False  ...   \n",
       "18799               0.127273             0.280000         False  ...   \n",
       "18694               0.333333             0.321101         False  ...   \n",
       "18712               0.066667             0.381443         False  ...   \n",
       "...                      ...                  ...           ...  ...   \n",
       "19048               0.000000             0.235669         False  ...   \n",
       "19045               0.000000             1.000000         False  ...   \n",
       "19042               0.000000             1.000000         False  ...   \n",
       "19039               0.000000             1.000000         False  ...   \n",
       "18943               0.000000             0.220126         False  ...   \n",
       "\n",
       "       SelfLoops  Eccentricity  Stress  Degree  BetweennessCentrality  \\\n",
       "18610          0             5    1062      16               0.797297   \n",
       "18778          1             6     962      15               0.402857   \n",
       "18799          0             7    1328      11               0.401681   \n",
       "18694          0             6    1034       7               0.281793   \n",
       "18712          0             6     626       6               0.469970   \n",
       "...          ...           ...     ...     ...                    ...   \n",
       "19048          0             8       0       1               0.000000   \n",
       "19045          0             1       0       1               0.000000   \n",
       "19042          0             1       0       1               0.000000   \n",
       "19039          0             1       0       1               0.000000   \n",
       "18943          0             8       0       1               0.000000   \n",
       "\n",
       "       NeighborhoodConnectivity  NumberOfDirectedEdges  \\\n",
       "18610                  1.812500                      0   \n",
       "18778                  4.692308                      0   \n",
       "18799                  2.818182                      0   \n",
       "18694                  4.571429                      0   \n",
       "18712                  4.333333                      0   \n",
       "...                         ...                    ...   \n",
       "19048                  4.000000                      0   \n",
       "19045                  1.000000                      0   \n",
       "19042                  1.000000                      0   \n",
       "19039                  1.000000                      0   \n",
       "18943                 11.000000                      0   \n",
       "\n",
       "       NumberOfUndirectedEdges  Radiality  TopologicalCoefficient  \n",
       "18610                       16   0.920608                0.091346  \n",
       "18778                       14   0.837363                0.329670  \n",
       "18799                       11   0.802198                0.223140  \n",
       "18694                        7   0.837363                0.268908  \n",
       "18712                        6   0.898649                0.183333  \n",
       "...                        ...        ...                     ...  \n",
       "19048                        1   0.797297                0.000000  \n",
       "19045                        1   1.000000                0.000000  \n",
       "19042                        1   1.000000                0.000000  \n",
       "19039                        1   1.000000                0.000000  \n",
       "18943                        1   0.727473                0.000000  \n",
       "\n",
       "[158 rows x 21 columns]"
      ]
     },
     "execution_count": 192,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "node_table.sort_values(by='Degree', ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b4ebe14c-2b23-4da2-8be6-2223add935af",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "id": "7386bd66-1924-4199-84d2-a6d1a66def40",
   "metadata": {},
   "outputs": [],
   "source": [
    "node_table['stress_norm'] = node_table['Stress'] / node_table['Stress'].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "id": "9422c085-e30e-4418-8c74-26d89edf0ad4",
   "metadata": {},
   "outputs": [],
   "source": [
    "node_table['w_deg with betweenness'] = node_table['weight_degree'] * node_table['BetweennessCentrality'] * node_table['stress_norm']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e9795c94-cb76-452e-9eda-2285d050fd1b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "id": "a2fb09ff-bf2e-48d1-9ceb-777efe0b0b40",
   "metadata": {},
   "outputs": [],
   "source": [
    "node_table_sorted = node_table.sort_values(by='w_deg with betweenness', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "id": "6ae4b7b9-75db-4b80-bd46-53ea25b06829",
   "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>SUID</th>\n",
       "      <th>shared name</th>\n",
       "      <th>name</th>\n",
       "      <th>selected</th>\n",
       "      <th>id</th>\n",
       "      <th>weight_degree</th>\n",
       "      <th>AverageShortestPathLength</th>\n",
       "      <th>ClusteringCoefficient</th>\n",
       "      <th>ClosenessCentrality</th>\n",
       "      <th>IsSingleNode</th>\n",
       "      <th>...</th>\n",
       "      <th>Stress</th>\n",
       "      <th>Degree</th>\n",
       "      <th>BetweennessCentrality</th>\n",
       "      <th>NeighborhoodConnectivity</th>\n",
       "      <th>NumberOfDirectedEdges</th>\n",
       "      <th>NumberOfUndirectedEdges</th>\n",
       "      <th>Radiality</th>\n",
       "      <th>TopologicalCoefficient</th>\n",
       "      <th>stress_norm</th>\n",
       "      <th>w_deg with betweenness</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>18610</th>\n",
       "      <td>18610</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>False</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>6.2472</td>\n",
       "      <td>2.270270</td>\n",
       "      <td>0.025000</td>\n",
       "      <td>0.440476</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1062</td>\n",
       "      <td>16</td>\n",
       "      <td>0.797297</td>\n",
       "      <td>1.812500</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>0.920608</td>\n",
       "      <td>0.091346</td>\n",
       "      <td>0.604096</td>\n",
       "      <td>3.008925</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18585</th>\n",
       "      <td>18585</td>\n",
       "      <td>Wartungstätigkeit</td>\n",
       "      <td>Wartungstätigkeit</td>\n",
       "      <td>False</td>\n",
       "      <td>Wartungstätigkeit</td>\n",
       "      <td>3.1190</td>\n",
       "      <td>2.714286</td>\n",
       "      <td>0.133333</td>\n",
       "      <td>0.368421</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1758</td>\n",
       "      <td>6</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0.868132</td>\n",
       "      <td>0.242424</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.782286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18778</th>\n",
       "      <td>18778</td>\n",
       "      <td>Herr</td>\n",
       "      <td>Herr</td>\n",
       "      <td>False</td>\n",
       "      <td>Herr</td>\n",
       "      <td>5.4802</td>\n",
       "      <td>3.114286</td>\n",
       "      <td>0.294872</td>\n",
       "      <td>0.321101</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>962</td>\n",
       "      <td>15</td>\n",
       "      <td>0.402857</td>\n",
       "      <td>4.692308</td>\n",
       "      <td>0</td>\n",
       "      <td>14</td>\n",
       "      <td>0.837363</td>\n",
       "      <td>0.329670</td>\n",
       "      <td>0.547213</td>\n",
       "      <td>1.208102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18799</th>\n",
       "      <td>18799</td>\n",
       "      <td>Firma</td>\n",
       "      <td>Firma</td>\n",
       "      <td>False</td>\n",
       "      <td>Firma</td>\n",
       "      <td>3.6372</td>\n",
       "      <td>3.571429</td>\n",
       "      <td>0.127273</td>\n",
       "      <td>0.280000</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1328</td>\n",
       "      <td>11</td>\n",
       "      <td>0.401681</td>\n",
       "      <td>2.818182</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "      <td>0.802198</td>\n",
       "      <td>0.223140</td>\n",
       "      <td>0.755404</td>\n",
       "      <td>1.103640</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18592</th>\n",
       "      <td>18592</td>\n",
       "      <td>Vorgabe</td>\n",
       "      <td>Vorgabe</td>\n",
       "      <td>False</td>\n",
       "      <td>Vorgabe</td>\n",
       "      <td>4.1454</td>\n",
       "      <td>2.885714</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.346535</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1106</td>\n",
       "      <td>5</td>\n",
       "      <td>0.315406</td>\n",
       "      <td>4.600000</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>0.854945</td>\n",
       "      <td>0.383333</td>\n",
       "      <td>0.629124</td>\n",
       "      <td>0.822570</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        SUID        shared name               name  selected  \\\n",
       "18610  18610          Kontrolle          Kontrolle     False   \n",
       "18585  18585  Wartungstätigkeit  Wartungstätigkeit     False   \n",
       "18778  18778               Herr               Herr     False   \n",
       "18799  18799              Firma              Firma     False   \n",
       "18592  18592            Vorgabe            Vorgabe     False   \n",
       "\n",
       "                      id  weight_degree  AverageShortestPathLength  \\\n",
       "18610          Kontrolle         6.2472                   2.270270   \n",
       "18585  Wartungstätigkeit         3.1190                   2.714286   \n",
       "18778               Herr         5.4802                   3.114286   \n",
       "18799              Firma         3.6372                   3.571429   \n",
       "18592            Vorgabe         4.1454                   2.885714   \n",
       "\n",
       "       ClusteringCoefficient  ClosenessCentrality  IsSingleNode  ...  Stress  \\\n",
       "18610               0.025000             0.440476         False  ...    1062   \n",
       "18585               0.133333             0.368421         False  ...    1758   \n",
       "18778               0.294872             0.321101         False  ...     962   \n",
       "18799               0.127273             0.280000         False  ...    1328   \n",
       "18592               0.400000             0.346535         False  ...    1106   \n",
       "\n",
       "       Degree  BetweennessCentrality  NeighborhoodConnectivity  \\\n",
       "18610      16               0.797297                  1.812500   \n",
       "18585       6               0.571429                  3.000000   \n",
       "18778      15               0.402857                  4.692308   \n",
       "18799      11               0.401681                  2.818182   \n",
       "18592       5               0.315406                  4.600000   \n",
       "\n",
       "       NumberOfDirectedEdges  NumberOfUndirectedEdges  Radiality  \\\n",
       "18610                      0                       16   0.920608   \n",
       "18585                      0                        6   0.868132   \n",
       "18778                      0                       14   0.837363   \n",
       "18799                      0                       11   0.802198   \n",
       "18592                      0                        5   0.854945   \n",
       "\n",
       "       TopologicalCoefficient  stress_norm  w_deg with betweenness  \n",
       "18610                0.091346     0.604096                3.008925  \n",
       "18585                0.242424     1.000000                1.782286  \n",
       "18778                0.329670     0.547213                1.208102  \n",
       "18799                0.223140     0.755404                1.103640  \n",
       "18592                0.383333     0.629124                0.822570  \n",
       "\n",
       "[5 rows x 23 columns]"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "node_table_sorted.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "id": "a5f22fd0-e002-43ec-8dc3-99eb52f8bcd2",
   "metadata": {},
   "outputs": [],
   "source": [
    "node_table_choice = node_table_sorted.iloc[:5,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "id": "c123cdd7-f000-4a60-9dc2-73b8a4410e31",
   "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>SUID</th>\n",
       "      <th>shared name</th>\n",
       "      <th>name</th>\n",
       "      <th>selected</th>\n",
       "      <th>id</th>\n",
       "      <th>weight_degree</th>\n",
       "      <th>AverageShortestPathLength</th>\n",
       "      <th>ClusteringCoefficient</th>\n",
       "      <th>ClosenessCentrality</th>\n",
       "      <th>IsSingleNode</th>\n",
       "      <th>...</th>\n",
       "      <th>Stress</th>\n",
       "      <th>Degree</th>\n",
       "      <th>BetweennessCentrality</th>\n",
       "      <th>NeighborhoodConnectivity</th>\n",
       "      <th>NumberOfDirectedEdges</th>\n",
       "      <th>NumberOfUndirectedEdges</th>\n",
       "      <th>Radiality</th>\n",
       "      <th>TopologicalCoefficient</th>\n",
       "      <th>stress_norm</th>\n",
       "      <th>w_deg with betweenness</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>18610</th>\n",
       "      <td>18610</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>False</td>\n",
       "      <td>Kontrolle</td>\n",
       "      <td>6.2472</td>\n",
       "      <td>2.270270</td>\n",
       "      <td>0.025000</td>\n",
       "      <td>0.440476</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1062</td>\n",
       "      <td>16</td>\n",
       "      <td>0.797297</td>\n",
       "      <td>1.812500</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>0.920608</td>\n",
       "      <td>0.091346</td>\n",
       "      <td>0.604096</td>\n",
       "      <td>3.008925</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18585</th>\n",
       "      <td>18585</td>\n",
       "      <td>Wartungstätigkeit</td>\n",
       "      <td>Wartungstätigkeit</td>\n",
       "      <td>False</td>\n",
       "      <td>Wartungstätigkeit</td>\n",
       "      <td>3.1190</td>\n",
       "      <td>2.714286</td>\n",
       "      <td>0.133333</td>\n",
       "      <td>0.368421</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1758</td>\n",
       "      <td>6</td>\n",
       "      <td>0.571429</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0.868132</td>\n",
       "      <td>0.242424</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.782286</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18778</th>\n",
       "      <td>18778</td>\n",
       "      <td>Herr</td>\n",
       "      <td>Herr</td>\n",
       "      <td>False</td>\n",
       "      <td>Herr</td>\n",
       "      <td>5.4802</td>\n",
       "      <td>3.114286</td>\n",
       "      <td>0.294872</td>\n",
       "      <td>0.321101</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>962</td>\n",
       "      <td>15</td>\n",
       "      <td>0.402857</td>\n",
       "      <td>4.692308</td>\n",
       "      <td>0</td>\n",
       "      <td>14</td>\n",
       "      <td>0.837363</td>\n",
       "      <td>0.329670</td>\n",
       "      <td>0.547213</td>\n",
       "      <td>1.208102</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18799</th>\n",
       "      <td>18799</td>\n",
       "      <td>Firma</td>\n",
       "      <td>Firma</td>\n",
       "      <td>False</td>\n",
       "      <td>Firma</td>\n",
       "      <td>3.6372</td>\n",
       "      <td>3.571429</td>\n",
       "      <td>0.127273</td>\n",
       "      <td>0.280000</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1328</td>\n",
       "      <td>11</td>\n",
       "      <td>0.401681</td>\n",
       "      <td>2.818182</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "      <td>0.802198</td>\n",
       "      <td>0.223140</td>\n",
       "      <td>0.755404</td>\n",
       "      <td>1.103640</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18592</th>\n",
       "      <td>18592</td>\n",
       "      <td>Vorgabe</td>\n",
       "      <td>Vorgabe</td>\n",
       "      <td>False</td>\n",
       "      <td>Vorgabe</td>\n",
       "      <td>4.1454</td>\n",
       "      <td>2.885714</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.346535</td>\n",
       "      <td>False</td>\n",
       "      <td>...</td>\n",
       "      <td>1106</td>\n",
       "      <td>5</td>\n",
       "      <td>0.315406</td>\n",
       "      <td>4.600000</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>0.854945</td>\n",
       "      <td>0.383333</td>\n",
       "      <td>0.629124</td>\n",
       "      <td>0.822570</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 23 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        SUID        shared name               name  selected  \\\n",
       "18610  18610          Kontrolle          Kontrolle     False   \n",
       "18585  18585  Wartungstätigkeit  Wartungstätigkeit     False   \n",
       "18778  18778               Herr               Herr     False   \n",
       "18799  18799              Firma              Firma     False   \n",
       "18592  18592            Vorgabe            Vorgabe     False   \n",
       "\n",
       "                      id  weight_degree  AverageShortestPathLength  \\\n",
       "18610          Kontrolle         6.2472                   2.270270   \n",
       "18585  Wartungstätigkeit         3.1190                   2.714286   \n",
       "18778               Herr         5.4802                   3.114286   \n",
       "18799              Firma         3.6372                   3.571429   \n",
       "18592            Vorgabe         4.1454                   2.885714   \n",
       "\n",
       "       ClusteringCoefficient  ClosenessCentrality  IsSingleNode  ...  Stress  \\\n",
       "18610               0.025000             0.440476         False  ...    1062   \n",
       "18585               0.133333             0.368421         False  ...    1758   \n",
       "18778               0.294872             0.321101         False  ...     962   \n",
       "18799               0.127273             0.280000         False  ...    1328   \n",
       "18592               0.400000             0.346535         False  ...    1106   \n",
       "\n",
       "       Degree  BetweennessCentrality  NeighborhoodConnectivity  \\\n",
       "18610      16               0.797297                  1.812500   \n",
       "18585       6               0.571429                  3.000000   \n",
       "18778      15               0.402857                  4.692308   \n",
       "18799      11               0.401681                  2.818182   \n",
       "18592       5               0.315406                  4.600000   \n",
       "\n",
       "       NumberOfDirectedEdges  NumberOfUndirectedEdges  Radiality  \\\n",
       "18610                      0                       16   0.920608   \n",
       "18585                      0                        6   0.868132   \n",
       "18778                      0                       14   0.837363   \n",
       "18799                      0                       11   0.802198   \n",
       "18592                      0                        5   0.854945   \n",
       "\n",
       "       TopologicalCoefficient  stress_norm  w_deg with betweenness  \n",
       "18610                0.091346     0.604096                3.008925  \n",
       "18585                0.242424     1.000000                1.782286  \n",
       "18778                0.329670     0.547213                1.208102  \n",
       "18799                0.223140     0.755404                1.103640  \n",
       "18592                0.383333     0.629124                0.822570  \n",
       "\n",
       "[5 rows x 23 columns]"
      ]
     },
     "execution_count": 198,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "node_table_choice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "id": "6f68b890-6c80-4750-a35c-ee29b594462d",
   "metadata": {},
   "outputs": [],
   "source": [
    "nodes_to_select = node_table_choice['SUID'].to_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "id": "6d94b18f-2590-4d1b-b165-300466bfd1b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 200,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.clear_selection()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 239,
   "id": "62cf521b-e709-4086-9f3d-3e3f8dd9faaa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 239,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.select_nodes(nodes_to_select[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fdeeccd4-3e7c-4c76-a024-f45540142c4a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 202,
   "id": "a371ce7a-d9b9-4158-a0cb-797834a16f97",
   "metadata": {},
   "outputs": [],
   "source": [
    "iter_depth = 2\n",
    "\n",
    "for _ in range(iter_depth):\n",
    "    _ = p4c.select_first_neighbors()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 203,
   "id": "cce979e2-65f1-4896-8758-659ff21c315b",
   "metadata": {},
   "outputs": [],
   "source": [
    "_ = p4c.select_edges_connecting_selected_nodes()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23157e10-02c6-4adb-8a36-4bdbfe5f9f4b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 206,
   "id": "2038fd62-b75f-4ba1-b258-53789b4665b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20402"
      ]
     },
     "execution_count": 206,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.create_subnetwork(nodes='selected', edges='selected', subnetwork_name='test_sub_1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "12828271-fea9-4e4a-98c3-87860992a6db",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f367b253-2172-4dce-9379-a3ed95f3368e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49ad6a55-2a12-44c4-a193-2fbb3da84bcf",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 205,
   "id": "7de95550-c077-467f-a962-5e84ddf430c7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 205,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.fit_content(selected_only=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b73934d1-f16a-4ef9-8969-b1be8e7310f5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "783cb7d6-c6b1-4a9b-8019-02ce2628dde9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 314,
   "id": "697647da-3b8b-4029-bec9-af2e2bb6984a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['attribute-circle',\n",
       " 'attribute-grid',\n",
       " 'attributes-layout',\n",
       " 'circular',\n",
       " 'cose',\n",
       " 'degree-circle',\n",
       " 'force-directed',\n",
       " 'force-directed-cl',\n",
       " 'fruchterman-rheingold',\n",
       " 'grid',\n",
       " 'hierarchical',\n",
       " 'isom',\n",
       " 'kamada-kawai',\n",
       " 'stacked-node-layout']"
      ]
     },
     "execution_count": 314,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted(list(p4c.get_layout_name_mapping().values()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "id": "fa15c057-d453-4c7e-8af2-18220ea90651",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['numIterations',\n",
       " 'defaultSpringCoefficient',\n",
       " 'defaultSpringLength',\n",
       " 'defaultNodeMass',\n",
       " 'isDeterministic',\n",
       " 'singlePartition']"
      ]
     },
     "execution_count": 186,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_layout_property_names('force-directed')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 259,
   "id": "6f48d9cc-f527-4b33-9477-60636a480371",
   "metadata": {},
   "outputs": [],
   "source": [
    "LAYOUT_NAME = 'force-directed'\n",
    "LAYOUT_PROPERTIES = {\n",
    "    'numIterations': 1000,\n",
    "    'defaultSpringCoefficient': 1e-4,\n",
    "    'defaultSpringLength': 45,\n",
    "    'defaultNodeMass': 11,\n",
    "    'isDeterministic': True,\n",
    "    'singlePartition': False,\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "id": "d542b2ea-11d5-4802-b1b9-65e5e12f6d38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.set_layout_properties('force-directed', layout_props)\n",
    "#p4c.get_layout_property_type('kamada-kawai', 'randomize')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8eb62660-27a6-43a0-be19-4c4479eac8d7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 189,
   "id": "c1069996-b638-4bfa-8ad4-f750a33022d6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 189,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.layout_network(layout_name='force-directed', network='test3')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7f5c1e6-8e32-4e90-b531-38611fef85ce",
   "metadata": {},
   "outputs": [],
   "source": [
    "p4c.fit_content(selected_only=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "8802c969-c3f4-433a-8cab-c6704fa03039",
   "metadata": {},
   "outputs": [],
   "source": [
    "# visual style gets always imported with increasing index,\n",
    "# later check if style in Cytoscape is already available\n",
    "styles_avail = p4c.get_visual_style_names()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "1b6023ef-b4a2-4cf3-92ef-01419fc5258a",
   "metadata": {},
   "outputs": [],
   "source": [
    "if 'lang_main' not in styles_avail:\n",
    "    p4c.import_visual_styles('lang_main.xml')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "3e27695b-5b26-4176-9bc9-adb91d848025",
   "metadata": {},
   "outputs": [],
   "source": [
    "assert 'lang_main' in p4c.get_visual_style_names()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4083b72d-f321-4489-be19-6167f13ab226",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "59234fed-cc38-4ee3-9ef8-9180e7785ea5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'message': 'Visual Style applied.'}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.set_visual_style('lang_main')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2653d1af-b3a5-4da7-9066-0940cb913dab",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fd5fd222-75fd-4523-8401-a4a37c6010fd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "d972ff5a-e695-43b6-b8c5-ab295fd5de3d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 72004 characters]",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.notebook_export_show_image()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a45fce84-bbb9-476a-8be3-5eb7b082afed",
   "metadata": {},
   "source": [
    "- graph properties in Cytoscape or pre-calculated?\n",
    "- node sizes depending on graph properties\n",
    "- edge width depending on graph properties"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3796359f-3112-4bbf-ae76-e52b3602c9f0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c8cba3d9-0145-4b37-9ebf-07f0e3c61815",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "# Py4Cytoscape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fcd9247f-c4f9-4f73-9fd3-2ab56700073f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "You are connected to Cytoscape!\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'apiVersion': 'v1',\n",
       " 'cytoscapeVersion': '3.10.2',\n",
       " 'automationAPIVersion': '1.9.0',\n",
       " 'py4cytoscapeVersion': '1.9.0'}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import py4cytoscape as p4c\n",
    "#dir(p4c)\n",
    "p4c.cytoscape_ping()\n",
    "p4c.cytoscape_version_info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b9290659-e33c-47fc-8d89-7aa3dd6e843a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "nodes = pd.DataFrame(data={'id': [\"node 0\",\"node 1\",\"node 2\",\"node 3\"], 'group': [\"A\",\"A\",\"B\",\"B\"], 'score': [20,10,15,5]})\n",
    "edges = pd.DataFrame(data={'source': [\"node 0\",\"node 0\",\"node 0\",\"node 2\"], 'target': [\"node 1\",\"node 2\",\"node 3\",\"node 3\"], 'interaction': [\"inhibits\",\"interacts\",\"activates\",\"interacts\"], 'weight': [5.1,3.0,5.2,9.9]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "979d6def-83ac-47f6-ac6f-0d20ddf48d48",
   "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>id</th>\n",
       "      <th>group</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>node 0</td>\n",
       "      <td>A</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>node 1</td>\n",
       "      <td>A</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>node 2</td>\n",
       "      <td>B</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>node 3</td>\n",
       "      <td>B</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       id group  score\n",
       "0  node 0     A     20\n",
       "1  node 1     A     10\n",
       "2  node 2     B     15\n",
       "3  node 3     B      5"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nodes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "81702429-5735-48de-96a4-1f32c7c7d68c",
   "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>source</th>\n",
       "      <th>target</th>\n",
       "      <th>interaction</th>\n",
       "      <th>weight</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>node 0</td>\n",
       "      <td>node 1</td>\n",
       "      <td>inhibits</td>\n",
       "      <td>5.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>node 0</td>\n",
       "      <td>node 2</td>\n",
       "      <td>interacts</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>node 0</td>\n",
       "      <td>node 3</td>\n",
       "      <td>activates</td>\n",
       "      <td>5.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>node 2</td>\n",
       "      <td>node 3</td>\n",
       "      <td>interacts</td>\n",
       "      <td>9.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   source  target interaction  weight\n",
       "0  node 0  node 1    inhibits     5.1\n",
       "1  node 0  node 2   interacts     3.0\n",
       "2  node 0  node 3   activates     5.2\n",
       "3  node 2  node 3   interacts     9.9"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6b29d561-fffd-4a5b-91c1-8fb6a075ae4f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Applying default style...\n",
      "Applying preferred layout\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "128"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.create_network_from_data_frames(nodes, edges, title=\"my first network\", collection=\"DataFrame Example\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1e87b4d9-6ef0-4108-81ff-e0124e45b793",
   "metadata": {},
   "outputs": [],
   "source": [
    "p4c.hide_all_panels()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "23706ea9-b661-428e-a4de-ac4543aafc76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.set_network_zoom_bypass(1.5, bypass=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9c7e7fa0-8b17-43f6-9076-3e117748b06b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "In cyrest_delete(): Bypass Visual Property does not exist: NETWORK_SCALE_FACTOR\n"
     ]
    },
    {
     "ename": "CyError",
     "evalue": "In cyrest_delete(): Bypass Visual Property does not exist: NETWORK_SCALE_FACTOR",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mHTTPError\u001b[0m                                 Traceback (most recent call last)",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\commands.py:109\u001b[0m, in \u001b[0;36mcyrest_delete\u001b[1;34m(operation, parameters, base_url, require_json)\u001b[0m\n\u001b[0;32m    108\u001b[0m r \u001b[38;5;241m=\u001b[39m _do_request(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDELETE\u001b[39m\u001b[38;5;124m'\u001b[39m, url, params\u001b[38;5;241m=\u001b[39mparameters, base_url\u001b[38;5;241m=\u001b[39mbase_url)\n\u001b[1;32m--> 109\u001b[0m \u001b[43mr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    110\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\requests\\models.py:1021\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m   1020\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1021\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n",
      "\u001b[1;31mHTTPError\u001b[0m: 404 Client Error: Not Found for url: http://127.0.0.1:1234/v1/networks/128/views/220/network/NETWORK_SCALE_FACTOR/bypass",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mCyError\u001b[0m                                   Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[11], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mp4c\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclear_network_zoom_bypass\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\py4cytoscape_logger.py:133\u001b[0m, in \u001b[0;36mcy_log.<locals>.wrapper_log\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    131\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[0;32m    132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m--> 133\u001b[0m     \u001b[43mlog_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    134\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[0;32m    135\u001b[0m     log_finally()\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\py4cytoscape_logger.py:130\u001b[0m, in \u001b[0;36mcy_log.<locals>.wrapper_log\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    128\u001b[0m log_incoming(func, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m    129\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 130\u001b[0m     value \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# Call function being logged\u001b[39;00m\n\u001b[0;32m    131\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[0;32m    132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\style_bypasses.py:2726\u001b[0m, in \u001b[0;36mclear_network_zoom_bypass\u001b[1;34m(network, base_url)\u001b[0m\n\u001b[0;32m   2697\u001b[0m \u001b[38;5;129m@cy_log\u001b[39m\n\u001b[0;32m   2698\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mclear_network_zoom_bypass\u001b[39m(network\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, base_url\u001b[38;5;241m=\u001b[39mDEFAULT_BASE_URL):\n\u001b[0;32m   2699\u001b[0m \u001b[38;5;250m    \u001b[39m\u001b[38;5;124;03m\"\"\"Clear the bypass value for the scale factor for the network, effectively restoring prior default values.\u001b[39;00m\n\u001b[0;32m   2700\u001b[0m \n\u001b[0;32m   2701\u001b[0m \u001b[38;5;124;03m    Args:\u001b[39;00m\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m   2724\u001b[0m \u001b[38;5;124;03m        clearing this property will throw an exception.\u001b[39;00m\n\u001b[0;32m   2725\u001b[0m \u001b[38;5;124;03m    \"\"\"\u001b[39;00m\n\u001b[1;32m-> 2726\u001b[0m     res \u001b[38;5;241m=\u001b[39m \u001b[43mclear_network_property_bypass\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mNETWORK_SCALE_FACTOR\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnetwork\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnetwork\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   2727\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m res\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\py4cytoscape_logger.py:133\u001b[0m, in \u001b[0;36mcy_log.<locals>.wrapper_log\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    131\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[0;32m    132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m--> 133\u001b[0m     \u001b[43mlog_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    134\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[0;32m    135\u001b[0m     log_finally()\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\py4cytoscape_logger.py:130\u001b[0m, in \u001b[0;36mcy_log.<locals>.wrapper_log\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    128\u001b[0m log_incoming(func, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m    129\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 130\u001b[0m     value \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# Call function being logged\u001b[39;00m\n\u001b[0;32m    131\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[0;32m    132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\style_bypasses.py:516\u001b[0m, in \u001b[0;36mclear_network_property_bypass\u001b[1;34m(visual_property, network, base_url)\u001b[0m\n\u001b[0;32m    512\u001b[0m view_suid \u001b[38;5;241m=\u001b[39m network_views\u001b[38;5;241m.\u001b[39mget_network_views(net_suid, base_url\u001b[38;5;241m=\u001b[39mbase_url)[\u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m    514\u001b[0m visual_property \u001b[38;5;241m=\u001b[39m normalize_prop_name(visual_property)\n\u001b[1;32m--> 516\u001b[0m res \u001b[38;5;241m=\u001b[39m \u001b[43mcommands\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcyrest_delete\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mnetworks/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mnet_suid\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m/views/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mview_suid\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m/network/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mvisual_property\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m/bypass\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[0;32m    517\u001b[0m \u001b[43m                             \u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbase_url\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    518\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m res\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\py4cytoscape_logger.py:133\u001b[0m, in \u001b[0;36mcy_log.<locals>.wrapper_log\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    131\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[0;32m    132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m--> 133\u001b[0m     \u001b[43mlog_exception\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    134\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[0;32m    135\u001b[0m     log_finally()\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\py4cytoscape_logger.py:130\u001b[0m, in \u001b[0;36mcy_log.<locals>.wrapper_log\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    128\u001b[0m log_incoming(func, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m    129\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 130\u001b[0m     value \u001b[38;5;241m=\u001b[39m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;66;03m# Call function being logged\u001b[39;00m\n\u001b[0;32m    131\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m log_return(func, value)\n\u001b[0;32m    132\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\commands.py:118\u001b[0m, in \u001b[0;36mcyrest_delete\u001b[1;34m(operation, parameters, base_url, require_json)\u001b[0m\n\u001b[0;32m    116\u001b[0m             \u001b[38;5;28;01mreturn\u001b[39;00m r\u001b[38;5;241m.\u001b[39mtext\n\u001b[0;32m    117\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m requests\u001b[38;5;241m.\u001b[39mexceptions\u001b[38;5;241m.\u001b[39mRequestException \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m--> 118\u001b[0m     \u001b[43m_handle_error\u001b[49m\u001b[43m(\u001b[49m\u001b[43me\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\py4cytoscape\\commands.py:683\u001b[0m, in \u001b[0;36m_handle_error\u001b[1;34m(e, force_cy_error)\u001b[0m\n\u001b[0;32m    681\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m    682\u001b[0m         show_error(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mIn \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcaller\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mcontent\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m--> 683\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n",
      "\u001b[1;31mCyError\u001b[0m: In cyrest_delete(): Bypass Visual Property does not exist: NETWORK_SCALE_FACTOR"
     ]
    }
   ],
   "source": [
    "p4c.clear_network_zoom_bypass()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "234855d1-a961-4dd7-9b2e-a96d7acc1142",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.fit_content()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "79ccddf6-3b0f-4151-a333-05b6e7b5ed8a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.1950671670515094"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "zoom = p4c.get_network_zoom()\n",
    "zoom"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "dc8f2bcc-9836-4476-bfa4-1d83308375ac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.5660484088532423"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "zoom * 0.96"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "3e3106c6-d9f4-41cd-8a5a-452cd32b25c0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.set_network_zoom_bypass(zoom * 0.96, bypass=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "05a19acc-8af7-45d0-8902-1e9776824a38",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4647c594-46f1-4e12-9927-e73ca5a0486a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2e6878db-40c0-4ae6-89d6-9b1a5e50baaf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 39436 characters]",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.notebook_export_show_image()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "66128f17-16eb-43d3-9d63-bbac3f8f803a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'message': 'Visual Style applied.'}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.set_visual_style('Marquee')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ca0cc760-74e4-4c4a-b78a-c932ab16ab06",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 50224 characters]",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.notebook_export_show_image()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "24c29cb3-cf64-4fad-8b1a-b0962f1005b4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'message': 'Visual Style applied.'}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "style_name = \"myStyle\"\n",
    "defaults = {'NODE_SHAPE': \"diamond\", 'NODE_SIZE': 30, 'EDGE_TRANSPARENCY': 120, 'NODE_LABEL_POSITION': \"W,E,c,0.00,0.00\"}\n",
    "nodeLabels = p4c.map_visual_property('node label', 'id', 'p') #'p' means 'passthrough' mapping\n",
    "edgeWidth = p4c.map_visual_property('edge width', 'weight', 'p') #'p' means 'passthrough' mapping\n",
    "p4c.create_visual_style(style_name, defaults, [nodeLabels, edgeWidth])\n",
    "p4c.set_visual_style(style_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "1dfb553a-2367-463e-8a3d-0d232c2aedd0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 42192 characters]",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.notebook_export_show_image()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "5d535abb-83f0-40c8-b781-5b3129183ebf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Applying default style...\n",
      "Applying preferred layout\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "397"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nodes = pd.DataFrame(data={'id': [\"A\", \"B\", \"C\", \"D\"]})\n",
    "edges = pd.DataFrame(data={'source': [\"C\", \"B\", \"B\", \"B\"], 'target': [\"D\", \"A\", \"D\", \"C\"]})\n",
    "\n",
    "p4c.create_network_from_data_frames(nodes, edges, title=\"simple network\", collection=\"Biological Example\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "bb8bf383-7760-434e-ab3d-71b976024006",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 19076 characters]",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.notebook_export_show_image()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "1c4ab4f0-1f4d-4b9e-8b56-ec0f648531cb",
   "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>SUID</th>\n",
       "      <th>shared name</th>\n",
       "      <th>id</th>\n",
       "      <th>name</th>\n",
       "      <th>selected</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>427</th>\n",
       "      <td>427</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>A</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>430</th>\n",
       "      <td>430</td>\n",
       "      <td>B</td>\n",
       "      <td>B</td>\n",
       "      <td>B</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>433</th>\n",
       "      <td>433</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>436</th>\n",
       "      <td>436</td>\n",
       "      <td>D</td>\n",
       "      <td>D</td>\n",
       "      <td>D</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     SUID shared name id name  selected\n",
       "427   427           A  A    A     False\n",
       "430   430           B  B    B     False\n",
       "433   433           C  C    C     False\n",
       "436   436           D  D    D     False"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_table_columns()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "0a7b318d-b4e1-4eef-ab13-14e9b7bfa80e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['SUID', 'shared name', 'id', 'name', 'selected']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_table_column_names()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "29ba0973-1bc8-4987-b4ff-f3e50f9df573",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Attribute Circle Layout': 'attribute-circle',\n",
       " 'Stacked Node Layout': 'stacked-node-layout',\n",
       " 'Attribute Grid Layout': 'attribute-grid',\n",
       " 'Degree Sorted Circle Layout': 'degree-circle',\n",
       " 'Circular Layout': 'circular',\n",
       " 'Group Attributes Layout': 'attributes-layout',\n",
       " 'Edge-weighted Spring Embedded Layout': 'kamada-kawai',\n",
       " 'Prefuse Force Directed Layout': 'force-directed',\n",
       " 'Compound Spring Embedder (CoSE)': 'cose',\n",
       " 'Grid Layout': 'grid',\n",
       " 'Hierarchical Layout': 'hierarchical',\n",
       " 'Edge-weighted Force directed (BioLayout)': 'fruchterman-rheingold',\n",
       " 'Inverted Self-Organizing Map Layout': 'isom',\n",
       " 'Prefuse Force Directed OpenCL Layout': 'force-directed-cl'}"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_layout_name_mapping()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "63aba4a3-f53f-4eb0-ab6b-17bbd1b58e78",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['m_averageIterationsPerNode',\n",
       " 'm_nodeDistanceStrengthConstant',\n",
       " 'm_nodeDistanceRestLengthConstant',\n",
       " 'm_disconnectedNodeDistanceSpringStrength',\n",
       " 'm_disconnectedNodeDistanceSpringRestLength',\n",
       " 'm_anticollisionSpringStrength',\n",
       " 'm_layoutPass',\n",
       " 'singlePartition',\n",
       " 'unweighted',\n",
       " 'randomize']"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_layout_property_names('kamada-kawai')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "eec4f428-3abd-40da-a291-112b3e0d6f65",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'boolean'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_layout_property_type('kamada-kawai', 'randomize')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "98eb2412-5f24-4180-beac-2cadac9bb35e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.get_layout_property_value('kamada-kawai', 'randomize')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3bdb2b5f-609b-4bbf-8e42-a8ec07e5bda2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "fc3d4dd1-a132-4f08-adc3-add2eb25cc27",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "11beffb4-a21e-4b73-9c0c-a0ec57513ebd",
   "metadata": {},
   "outputs": [],
   "source": [
    "tp = Path.cwd()\n",
    "file = tp / 'test.svg'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "03696e83-9c87-4ec3-bba2-024f4747385a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'file': 'A:\\\\Arbeitsaufgaben\\\\lang-main\\\\test-notebooks.xml'}"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.export_visual_styles(str(tp))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "0e4068b3-7bf9-4093-8887-02b677a76fc1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'file': 'A:\\\\Arbeitsaufgaben\\\\lang-main\\\\test-notebooks\\\\test.svg'}"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p4c.export_image(str(file), type='SVG')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "be448cd8-022c-446b-9294-2d00bc445054",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "52792182-c8bc-4973-9682-36360604705b",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "# Find reason that TokenGraph weight sometimes is zero"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7e5c6d2c-2558-4c6a-9e0b-19e36279b4ce",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-24 14:22:25 +0000 | io:INFO | Loaded TOML config file successfully.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
      "  warnings.warn(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "from lang_main.constants import SAVE_PATH_FOLDER, SPCY_MODEL\n",
    "from lang_main.types import EntryPoints\n",
    "from lang_main import io\n",
    "from lang_main.analysis import tokens, graphs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f4cad9da-6570-41c5-9adb-032052e34a7d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-24 14:22:30 +0000 | io:INFO | Loaded file successfully.\n"
     ]
    }
   ],
   "source": [
    "p_df = io.get_entry_point(SAVE_PATH_FOLDER, EntryPoints.TIMELINE)\n",
    "(data,) = io.load_pickle(p_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c7c683a5-a6db-42b0-84f0-7806d30bd46f",
   "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>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>VorgangsBeschreibung</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>53</td>\n",
       "      <td>244</td>\n",
       "      <td>285 C, Webmaschine, SG 220 EMS</td>\n",
       "      <td>5</td>\n",
       "      <td>Greifer-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-19</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Kupplung schleift</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kupplung defekt</td>\n",
       "      <td>2019-03-20</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2019-03-19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>58</td>\n",
       "      <td>257</td>\n",
       "      <td>107, Webmaschine, OM 220 EOS</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-21</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Gegengewicht wieder anbringen</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Gegengewicht an der Webmaschine abgefallen</td>\n",
       "      <td>2019-03-21</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube ausgebohrt\\nGegengewicht wieder angeb...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-03-21</td>\n",
       "      <td>2019-03-21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>81</td>\n",
       "      <td>138</td>\n",
       "      <td>00138, Schärmaschine 9,</td>\n",
       "      <td>16</td>\n",
       "      <td>Schärmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>da ist etwas gebrochen. (Herr Heininger)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>zentrale Bremsenverstellung linke Gatterseite ...</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Bolzen gebrochen. Bolzen neu angefertig und di...</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>2019-03-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>82</td>\n",
       "      <td>0</td>\n",
       "      <td>Warenschau allgemein</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Klappbügel Portalkran H31 defekt</td>\n",
       "      <td>Warenschau allgemein</td>\n",
       "      <td>Allgemeine Reparaturarbeiten</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Feder ausgetauscht</td>\n",
       "      <td>Warenschau</td>\n",
       "      <td>Warenschau</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>2019-03-25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>76</td>\n",
       "      <td>0</td>\n",
       "      <td>Neben der Türe</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-22</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Schraube nix mer gut</td>\n",
       "      <td>Neben der Türe</td>\n",
       "      <td>Kettbaum</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schrauben ausgebohrt\\t\\nGewinde nachgeschnitten\\t</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>2019-03-22</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   VorgangsID  ObjektID                     HObjektText  ObjektArtID  \\\n",
       "0          53       244  285 C, Webmaschine, SG 220 EMS            5   \n",
       "1          58       257    107, Webmaschine, OM 220 EOS            3   \n",
       "2          81       138        00138, Schärmaschine 9,            16   \n",
       "3          82         0            Warenschau allgemein            0   \n",
       "4          76         0                  Neben der Türe            0   \n",
       "\n",
       "         ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "0  Greifer-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "1     Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "2        Schärmaschine              3  Reparaturauftrag (Portal)   \n",
       "3                  NaN              3  Reparaturauftrag (Portal)   \n",
       "4                  NaN              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "  VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  \\\n",
       "0    2019-03-19                 5                   0   \n",
       "1    2019-03-21                 5                   0   \n",
       "2    2019-03-25                 5                   0   \n",
       "3    2019-03-25                 5                   0   \n",
       "4    2019-03-22                 5                   0   \n",
       "\n",
       "                       VorgangsBeschreibung           VorgangsOrt  \\\n",
       "0                         Kupplung schleift                   NaN   \n",
       "1             Gegengewicht wieder anbringen                   NaN   \n",
       "2  da ist etwas gebrochen. (Herr Heininger)                   NaN   \n",
       "3          Klappbügel Portalkran H31 defekt  Warenschau allgemein   \n",
       "4                      Schraube nix mer gut        Neben der Türe   \n",
       "\n",
       "                                     VorgangsArtText ErledigungsDatum  \\\n",
       "0                                    Kupplung defekt       2019-03-20   \n",
       "1         Gegengewicht an der Webmaschine abgefallen       2019-03-21   \n",
       "2  zentrale Bremsenverstellung linke Gatterseite ...       2019-03-25   \n",
       "3                      Allgemeine Reparaturarbeiten        2019-03-25   \n",
       "4                                           Kettbaum       2019-03-25   \n",
       "\n",
       "  ErledigungsArtText                            ErledigungsBeschreibung  \\\n",
       "0      Reparatur UTT                                                NaN   \n",
       "1      Reparatur UTT  Schraube ausgebohrt\\nGegengewicht wieder angeb...   \n",
       "2      Reparatur UTT  Bolzen gebrochen. Bolzen neu angefertig und di...   \n",
       "3      Reparatur UTT                                 Feder ausgetauscht   \n",
       "4      Reparatur UTT  Schrauben ausgebohrt\\t\\nGewinde nachgeschnitten\\t   \n",
       "\n",
       "  MPMelderArbeitsplatz MPAbteilungBezeichnung Arbeitsbeginn ErstellungsDatum  \n",
       "0              Weberei                Weberei           NaT       2019-03-19  \n",
       "1              Weberei                Weberei    2019-03-21       2019-03-21  \n",
       "2              Vorwerk                Vorwerk    2019-03-25       2019-03-25  \n",
       "3           Warenschau             Warenschau    2019-03-25       2019-03-25  \n",
       "4              Vorwerk                Vorwerk    2019-03-25       2019-03-22  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "aba15410-474a-476d-bad5-c5ded56322be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-24 14:22:30 +0000 | io:INFO | Loaded file successfully.\n"
     ]
    }
   ],
   "source": [
    "p_tl = io.get_entry_point(SAVE_PATH_FOLDER, EntryPoints.TIMELINE_POST)\n",
    "cands, texts = io.load_pickle(p_tl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6c3d5ae4-d28b-4322-a41b-d0bfc647081b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7552,\n",
       " 8192,\n",
       " 119558,\n",
       " 647,\n",
       " 2310,\n",
       " 48781,\n",
       " 66323,\n",
       " 8214,\n",
       " 5405,\n",
       " 108961,\n",
       " 91173,\n",
       " 2985,\n",
       " 3881,\n",
       " 9917,\n",
       " 66751,\n",
       " 85442,\n",
       " 118602,\n",
       " 7243,\n",
       " 62416,\n",
       " 979,\n",
       " 214,\n",
       " 103,\n",
       " 123111,\n",
       " 81133,\n",
       " 88558,\n",
       " 14319,\n",
       " 14834,\n",
       " 2424,\n",
       " 101497,\n",
       " 25341,\n",
       " 69375)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cands[1654][1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "62ef88ef-c1cb-4dc9-b88d-be335984b393",
   "metadata": {},
   "outputs": [],
   "source": [
    "def pre_filter_data(\n",
    "    data,\n",
    "    idx,\n",
    "    obj_id,\n",
    "):\n",
    "    idx = int(idx)\n",
    "    obj_id = int(obj_id)\n",
    "    # data = data.copy()\n",
    "    cands_for_obj_id = cands[obj_id]\n",
    "    cands_choice = cands_for_obj_id[int(idx) - 1]\n",
    "    # data\n",
    "    data = data.loc[list(cands_choice)].sort_index()  # type: ignore\n",
    "\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0433246a-174b-4e6d-b432-9b3cd8861677",
   "metadata": {},
   "outputs": [],
   "source": [
    "# filtered = pre_filter_data(data, 2, 1654)\n",
    "# filtered = pre_filter_data(data, 1, 1809)\n",
    "filtered = pre_filter_data(data, 1, 59)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "7c90c295-c7bc-4c99-ab74-a30f4015cde8",
   "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>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>VorgangsBeschreibung</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>188</th>\n",
       "      <td>139361</td>\n",
       "      <td>59</td>\n",
       "      <td>514 C , Webmaschine, DL 280 EMS Breite 280 Bj....</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2021-09-16</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Stab muss getauscht werden</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Stabbreithalter Reparatur</td>\n",
       "      <td>2021-09-15</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>UTT-Reparatur</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2021-09-15</td>\n",
       "      <td>2021-09-16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6096</th>\n",
       "      <td>151017</td>\n",
       "      <td>59</td>\n",
       "      <td>514 C , Webmaschine, DL 280 EMS Breite 280 Bj....</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2022-02-10</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Stabbreithalter Reparatur</td>\n",
       "      <td>2022-02-10</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2022-02-10</td>\n",
       "      <td>2022-02-10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10470</th>\n",
       "      <td>587652</td>\n",
       "      <td>59</td>\n",
       "      <td>514 C , Webmaschine, DL 280 EMS Breite 280 Bj....</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2023-06-13</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Stabbreithalter Reparatur</td>\n",
       "      <td>2023-06-13</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2023-06-13</td>\n",
       "      <td>2023-06-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53974</th>\n",
       "      <td>260534</td>\n",
       "      <td>59</td>\n",
       "      <td>514 C , Webmaschine, DL 280 EMS Breite 280 Bj....</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2022-06-15</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Stabbreithalter Reparatur</td>\n",
       "      <td>2022-06-15</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2022-06-15</td>\n",
       "      <td>2022-06-15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>107542</th>\n",
       "      <td>531473</td>\n",
       "      <td>59</td>\n",
       "      <td>514 C , Webmaschine, DL 280 EMS Breite 280 Bj....</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2023-05-08</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Stabbreithalter Reparatur</td>\n",
       "      <td>2023-05-08</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Sichtkontrolle durchgeführt\\nstab wurde getaus...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2023-05-08</td>\n",
       "      <td>2023-05-08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122411</th>\n",
       "      <td>513489</td>\n",
       "      <td>59</td>\n",
       "      <td>514 C , Webmaschine, DL 280 EMS Breite 280 Bj....</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2023-02-15</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Stabbreithalter Reparatur</td>\n",
       "      <td>2023-02-15</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Stab wurde getauscht</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2023-02-15</td>\n",
       "      <td>2023-02-15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        VorgangsID  ObjektID  \\\n",
       "188         139361        59   \n",
       "6096        151017        59   \n",
       "10470       587652        59   \n",
       "53974       260534        59   \n",
       "107542      531473        59   \n",
       "122411      513489        59   \n",
       "\n",
       "                                              HObjektText  ObjektArtID  \\\n",
       "188     514 C , Webmaschine, DL 280 EMS Breite 280 Bj....            3   \n",
       "6096    514 C , Webmaschine, DL 280 EMS Breite 280 Bj....            3   \n",
       "10470   514 C , Webmaschine, DL 280 EMS Breite 280 Bj....            3   \n",
       "53974   514 C , Webmaschine, DL 280 EMS Breite 280 Bj....            3   \n",
       "107542  514 C , Webmaschine, DL 280 EMS Breite 280 Bj....            3   \n",
       "122411  514 C , Webmaschine, DL 280 EMS Breite 280 Bj....            3   \n",
       "\n",
       "           ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "188     Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "6096    Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "10470   Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "53974   Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "107542  Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "122411  Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "       VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  \\\n",
       "188       2021-09-16                 5                   0   \n",
       "6096      2022-02-10                 5                   0   \n",
       "10470     2023-06-13                 5                   0   \n",
       "53974     2022-06-15                 5                   0   \n",
       "107542    2023-05-08                 5                   0   \n",
       "122411    2023-02-15                 5                   0   \n",
       "\n",
       "              VorgangsBeschreibung VorgangsOrt            VorgangsArtText  \\\n",
       "188     Stab muss getauscht werden         NaN  Stabbreithalter Reparatur   \n",
       "6096          Stab wurde getauscht         NaN  Stabbreithalter Reparatur   \n",
       "10470         Stab wurde getauscht         NaN  Stabbreithalter Reparatur   \n",
       "53974         Stab wurde getauscht         NaN  Stabbreithalter Reparatur   \n",
       "107542        Stab wurde getauscht         NaN  Stabbreithalter Reparatur   \n",
       "122411        Stab wurde getauscht         NaN  Stabbreithalter Reparatur   \n",
       "\n",
       "       ErledigungsDatum       ErledigungsArtText  \\\n",
       "188          2021-09-15  Intern UTT - Reparatur    \n",
       "6096         2022-02-10  Intern UTT - Reparatur    \n",
       "10470        2023-06-13  Intern UTT - Reparatur    \n",
       "53974        2022-06-15  Intern UTT - Reparatur    \n",
       "107542       2023-05-08  Intern UTT - Reparatur    \n",
       "122411       2023-02-15  Intern UTT - Reparatur    \n",
       "\n",
       "                                  ErledigungsBeschreibung  \\\n",
       "188                                         UTT-Reparatur   \n",
       "6096                                 Stab wurde getauscht   \n",
       "10470                                Stab wurde getauscht   \n",
       "53974                                Stab wurde getauscht   \n",
       "107542  Sichtkontrolle durchgeführt\\nstab wurde getaus...   \n",
       "122411                               Stab wurde getauscht   \n",
       "\n",
       "       MPMelderArbeitsplatz MPAbteilungBezeichnung Arbeitsbeginn  \\\n",
       "188                 Weberei                Weberei    2021-09-15   \n",
       "6096                Weberei                Weberei    2022-02-10   \n",
       "10470               Weberei                Weberei    2023-06-13   \n",
       "53974               Weberei                Weberei    2022-06-15   \n",
       "107542              Weberei                Weberei    2023-05-08   \n",
       "122411              Weberei                Weberei    2023-02-15   \n",
       "\n",
       "       ErstellungsDatum  \n",
       "188          2021-09-16  \n",
       "6096         2022-02-10  \n",
       "10470        2023-06-13  \n",
       "53974        2022-06-15  \n",
       "107542       2023-05-08  \n",
       "122411       2023-02-15  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filtered"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "51c14b60-a979-4097-a364-3585cbb00b8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['VorgangsID', 'ObjektID', 'HObjektText', 'ObjektArtID', 'ObjektArtText',\n",
       "       'VorgangsTypID', 'VorgangsTypName', 'VorgangsDatum', 'VorgangsStatusId',\n",
       "       'VorgangsPrioritaet', 'VorgangsBeschreibung', 'VorgangsOrt',\n",
       "       'VorgangsArtText', 'ErledigungsDatum', 'ErledigungsArtText',\n",
       "       'ErledigungsBeschreibung', 'MPMelderArbeitsplatz',\n",
       "       'MPAbteilungBezeichnung', 'Arbeitsbeginn', 'ErstellungsDatum'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filtered.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a70700f3-f872-409b-9f2b-d6e36bed71f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "filtered['delta'] = filtered['ErledigungsDatum'] - filtered['ErstellungsDatum']\n",
    "filtered['delta'] = filtered['delta'].dt.days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f13099a1-539d-4f92-8c18-315b02a061af",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "65a14689-081d-42ed-be6a-e49731a14f59",
   "metadata": {},
   "outputs": [],
   "source": [
    "import plotly.express as px"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "03201127-e31f-43a0-9580-f74c52052ac9",
   "metadata": {},
   "outputs": [],
   "source": [
    "MARKERS = {\n",
    "    'size': 8,\n",
    "    'color': 'red',\n",
    "    'symbol': 'cross',\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "d221446d-6c83-45be-9fcb-fd926ac2a925",
   "metadata": {},
   "outputs": [],
   "source": [
    "HOVER_DATA_DELTA = {\n",
    "    'ErstellungsDatum': '|%d.%m.%Y',\n",
    "    'ErledigungsDatum': '|%d.%m.%Y',\n",
    "    'VorgangsDatum': '|%d.%m.%Y',\n",
    "    'delta': True,\n",
    "    'VorgangsBeschreibung': True,\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "0990eb39-a5ae-4f05-88d8-1a2624284a2d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "customdata": [
          [
           "2020-12-14T00:00:00",
           "2020-12-10T00:00:00",
           "Kettbaum schrauben abgerochen schrauben ausboren"
          ],
          [
           "2021-12-17T00:00:00",
           "2021-12-16T00:00:00",
           "Neue Löcher bohren und Gewinde schneiden. Kettbaum liegt vor der Schlosserei"
          ],
          [
           "2022-06-22T00:00:00",
           "2022-06-21T00:00:00",
           "Kettbaum Gewinde nach schneiden (liegt vor Schlosserei)"
          ],
          [
           "2022-12-13T00:00:00",
           "2022-12-12T00:00:00",
           "Kettbaum Gewinden kaputt, neue Gewinden machen bitte"
          ],
          [
           "2022-02-03T00:00:00",
           "2022-02-03T00:00:00",
           "Gewinde schneiden. Kette liegt vor der Schlosserei"
          ],
          [
           "2022-03-28T00:00:00",
           "2022-03-28T00:00:00",
           "Kettbaum Schraube defekt. Liegt vor Schlosserei"
          ],
          [
           "2022-01-26T00:00:00",
           "2022-01-26T00:00:00",
           "2 Kettbäume Schrauben ausbohren. Kettbäume liegen vor der Schlosserei"
          ],
          [
           "2021-12-16T00:00:00",
           "2021-12-15T00:00:00",
           "Kettbaum Schrauben gebrochen bitte rausbohren"
          ],
          [
           "2023-01-23T00:00:00",
           "2023-01-21T00:00:00",
           "Schraube abgebrochen! Kettbaum liegt vor der Schlosserei"
          ],
          [
           "2021-12-13T00:00:00",
           "2021-12-12T00:00:00",
           "Kettbaum bei seiten Gewinde neu schneiden"
          ],
          [
           "2020-02-10T00:00:00",
           "2020-02-10T00:00:00",
           "Kettbäume vor Schlosserei"
          ],
          [
           "2019-11-18T00:00:00",
           "2019-11-13T00:00:00",
           "3*Kettbaum Gewinde nachschneiden"
          ],
          [
           "2019-11-11T00:00:00",
           "2019-11-11T00:00:00",
           "2X Kettbaum Gewinden nachschneiden"
          ],
          [
           "2023-01-26T00:00:00",
           "2023-01-25T00:00:00",
           "Kettbaum Gewinde nach schneiden. Kette liegt vor der Schlosserei."
          ],
          [
           "2020-03-23T00:00:00",
           "2020-03-23T00:00:00",
           "Bei allen 3 Kettbäumen Gewinde neu Schneiden. Ketten liegen vor der Schlosserei"
          ],
          [
           "2020-03-23T00:00:00",
           "2020-03-22T00:00:00",
           "Neues Gewinde Schneiden. Kette liegt vor der Schlosserei"
          ],
          [
           "2020-06-24T00:00:00",
           "2020-06-24T00:00:00",
           "Kettbaum Gewinde defekt"
          ],
          [
           "2021-01-08T00:00:00",
           "2021-01-06T00:00:00",
           "Kettbaum gewinde nachschneiden (Kettbaum vor Schlosserei)"
          ],
          [
           "2022-09-16T00:00:00",
           "2022-09-12T00:00:00",
           "Kettbaum Schrauben rund 2X liegen vor Schlosserei"
          ],
          [
           "2020-01-10T00:00:00",
           "2020-01-09T00:00:00",
           "Gewinde vom Kettbaum nachschneiden (Kette liegt vor Schlosserei)"
          ],
          [
           "2020-01-13T00:00:00",
           "2020-01-10T00:00:00",
           "Kettbaum Schrauben prüfen"
          ],
          [
           "2021-07-08T00:00:00",
           "2021-07-06T00:00:00",
           "Neues Gewinde am Kettbaum Schneiden. Kette liegt vor der Schlosserei"
          ],
          [
           "2020-02-20T00:00:00",
           "2020-02-20T00:00:00",
           "Gewinde defekt. Kette liegt vor der Schlosserei."
          ],
          [
           "2022-04-01T00:00:00",
           "2022-04-01T00:00:00",
           "Kettbaum Gewinde Schneiden, liegt vor der Schlosserei. ( Volle Kette) . 471 Wartet auf die Kette zum Andrehen."
          ],
          [
           "2021-05-05T00:00:00",
           "2021-05-05T00:00:00",
           "Adabter Scheibe Gewinde schneiden. Liegt in der Schlosserei auf der Werkbank."
          ],
          [
           "2022-05-24T00:00:00",
           "2022-05-23T00:00:00",
           "Kettbaum vor der Schlosserei neue Löcher bohren und Gewinde schneiden"
          ],
          [
           "2022-01-31T00:00:00",
           "2022-01-30T00:00:00",
           "Gewinde vom Kettbaum defekt. Neue Löcher bohren + Gewinde schneiden"
          ],
          [
           "2023-03-13T00:00:00",
           "2023-03-12T00:00:00",
           "Kettbaum-Schrauben abgebrochen !"
          ],
          [
           "2022-03-24T00:00:00",
           "2022-03-24T00:00:00",
           "Kettbaum neue Löcher bohren und Gewinde schneiden"
          ],
          [
           "2022-04-26T00:00:00",
           "2022-04-25T00:00:00",
           "Kettbaum Gewinde defekt (liegt vor Schlosserei)"
          ],
          [
           "2023-05-11T00:00:00",
           "2023-05-11T00:00:00",
           "Gebrochene Kettbaum Scheibe auswechseln. Steht vor der Schlosserei."
          ]
         ],
         "hovertemplate": "ErstellungsDatum=%{x|%d.%m.%Y}<br>delta=%{y}<br>ErledigungsDatum=%{customdata[0]|%d.%m.%Y}<br>VorgangsDatum=%{customdata[1]|%d.%m.%Y}<br>VorgangsBeschreibung=%{customdata[2]}<extra></extra>",
         "legendgroup": "",
         "marker": {
          "color": "red",
          "size": 8,
          "symbol": "cross"
         },
         "mode": "markers",
         "name": "",
         "orientation": "v",
         "showlegend": false,
         "type": "scatter",
         "x": [
          "2020-12-10T00:00:00",
          "2021-12-16T00:00:00",
          "2022-06-21T00:00:00",
          "2022-12-12T00:00:00",
          "2022-02-03T00:00:00",
          "2022-03-28T00:00:00",
          "2022-01-26T00:00:00",
          "2021-12-15T00:00:00",
          "2023-01-21T00:00:00",
          "2021-12-12T00:00:00",
          "2020-02-10T00:00:00",
          "2019-11-13T00:00:00",
          "2019-11-11T00:00:00",
          "2023-01-25T00:00:00",
          "2020-03-23T00:00:00",
          "2020-03-22T00:00:00",
          "2020-06-24T00:00:00",
          "2021-01-06T00:00:00",
          "2022-09-12T00:00:00",
          "2020-01-09T00:00:00",
          "2020-01-10T00:00:00",
          "2021-07-06T00:00:00",
          "2020-02-20T00:00:00",
          "2022-04-01T00:00:00",
          "2021-05-05T00:00:00",
          "2022-05-23T00:00:00",
          "2022-01-30T00:00:00",
          "2023-03-12T00:00:00",
          "2022-03-24T00:00:00",
          "2022-04-25T00:00:00",
          "2023-05-11T00:00:00"
         ],
         "xaxis": "x",
         "y": [
          4,
          1,
          1,
          1,
          0,
          0,
          0,
          1,
          2,
          1,
          0,
          5,
          0,
          1,
          0,
          1,
          0,
          2,
          4,
          1,
          3,
          2,
          0,
          0,
          0,
          1,
          1,
          1,
          0,
          1,
          0
         ],
         "yaxis": "y"
        }
       ],
       "layout": {
        "autosize": true,
        "hovermode": "x unified",
        "legend": {
         "tracegroupgap": 0
        },
        "margin": {
         "t": 60
        },
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "xaxis": {
         "anchor": "y",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "range": [
          "2019-08-22 16:53:05.236",
          "2023-07-30 07:06:54.764"
         ],
         "tickformat": "%B\n%Y",
         "title": {
          "text": "ErstellungsDatum"
         },
         "type": "date"
        },
        "yaxis": {
         "anchor": "x",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "dtick": 1,
         "range": [
          -0.425531914893617,
          5.425531914893617
         ],
         "title": {
          "text": "delta"
         },
         "type": "linear"
        }
       }
      },
      "image/png": "[encoded data, 32880 characters]",
      "text/html": [
       "<div>                            <div id=\"1eafb9c2-4e4a-48cd-b91e-877cbaf8763e\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                require([\"plotly\"], function(Plotly) {                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"1eafb9c2-4e4a-48cd-b91e-877cbaf8763e\")) {                    Plotly.newPlot(                        \"1eafb9c2-4e4a-48cd-b91e-877cbaf8763e\",                        [{\"customdata\":[[\"2020-12-14T00:00:00\",\"2020-12-10T00:00:00\",\"Kettbaum schrauben abgerochen schrauben ausboren\"],[\"2021-12-17T00:00:00\",\"2021-12-16T00:00:00\",\"Neue L\\u00f6cher bohren und Gewinde schneiden. Kettbaum liegt vor der Schlosserei\"],[\"2022-06-22T00:00:00\",\"2022-06-21T00:00:00\",\"Kettbaum Gewinde nach schneiden (liegt vor Schlosserei)\"],[\"2022-12-13T00:00:00\",\"2022-12-12T00:00:00\",\"Kettbaum Gewinden kaputt, neue Gewinden machen bitte\"],[\"2022-02-03T00:00:00\",\"2022-02-03T00:00:00\",\"Gewinde schneiden. Kette liegt vor der Schlosserei\"],[\"2022-03-28T00:00:00\",\"2022-03-28T00:00:00\",\"Kettbaum Schraube defekt. Liegt vor Schlosserei\"],[\"2022-01-26T00:00:00\",\"2022-01-26T00:00:00\",\"2 Kettb\\u00e4ume Schrauben ausbohren. Kettb\\u00e4ume liegen vor der Schlosserei\"],[\"2021-12-16T00:00:00\",\"2021-12-15T00:00:00\",\"Kettbaum Schrauben gebrochen bitte rausbohren\"],[\"2023-01-23T00:00:00\",\"2023-01-21T00:00:00\",\"Schraube abgebrochen! Kettbaum liegt vor der Schlosserei\"],[\"2021-12-13T00:00:00\",\"2021-12-12T00:00:00\",\"Kettbaum bei seiten Gewinde neu schneiden\"],[\"2020-02-10T00:00:00\",\"2020-02-10T00:00:00\",\"Kettb\\u00e4ume vor Schlosserei\"],[\"2019-11-18T00:00:00\",\"2019-11-13T00:00:00\",\"3*Kettbaum Gewinde nachschneiden\"],[\"2019-11-11T00:00:00\",\"2019-11-11T00:00:00\",\"2X Kettbaum Gewinden nachschneiden\"],[\"2023-01-26T00:00:00\",\"2023-01-25T00:00:00\",\"Kettbaum Gewinde nach schneiden. Kette liegt vor der Schlosserei.\"],[\"2020-03-23T00:00:00\",\"2020-03-23T00:00:00\",\"Bei allen 3 Kettb\\u00e4umen Gewinde neu Schneiden. Ketten liegen vor der Schlosserei\"],[\"2020-03-23T00:00:00\",\"2020-03-22T00:00:00\",\"Neues Gewinde Schneiden. Kette liegt vor der Schlosserei\"],[\"2020-06-24T00:00:00\",\"2020-06-24T00:00:00\",\"Kettbaum Gewinde defekt\"],[\"2021-01-08T00:00:00\",\"2021-01-06T00:00:00\",\"Kettbaum gewinde nachschneiden (Kettbaum vor Schlosserei)\"],[\"2022-09-16T00:00:00\",\"2022-09-12T00:00:00\",\"Kettbaum Schrauben rund 2X liegen vor Schlosserei\"],[\"2020-01-10T00:00:00\",\"2020-01-09T00:00:00\",\"Gewinde vom Kettbaum nachschneiden (Kette liegt vor Schlosserei)\"],[\"2020-01-13T00:00:00\",\"2020-01-10T00:00:00\",\"Kettbaum Schrauben pr\\u00fcfen\"],[\"2021-07-08T00:00:00\",\"2021-07-06T00:00:00\",\"Neues Gewinde am Kettbaum Schneiden. Kette liegt vor der Schlosserei\"],[\"2020-02-20T00:00:00\",\"2020-02-20T00:00:00\",\"Gewinde defekt. Kette liegt vor der Schlosserei.\"],[\"2022-04-01T00:00:00\",\"2022-04-01T00:00:00\",\"Kettbaum Gewinde Schneiden, liegt vor der Schlosserei. ( Volle Kette) . 471 Wartet auf die Kette zum Andrehen.\"],[\"2021-05-05T00:00:00\",\"2021-05-05T00:00:00\",\"Adabter Scheibe Gewinde schneiden. Liegt in der Schlosserei auf der Werkbank.\"],[\"2022-05-24T00:00:00\",\"2022-05-23T00:00:00\",\"Kettbaum vor der Schlosserei neue L\\u00f6cher bohren und Gewinde schneiden\"],[\"2022-01-31T00:00:00\",\"2022-01-30T00:00:00\",\"Gewinde vom Kettbaum defekt. Neue L\\u00f6cher bohren + Gewinde schneiden\"],[\"2023-03-13T00:00:00\",\"2023-03-12T00:00:00\",\"Kettbaum-Schrauben abgebrochen !\"],[\"2022-03-24T00:00:00\",\"2022-03-24T00:00:00\",\"Kettbaum neue L\\u00f6cher bohren und Gewinde schneiden\"],[\"2022-04-26T00:00:00\",\"2022-04-25T00:00:00\",\"Kettbaum Gewinde defekt (liegt vor Schlosserei)\"],[\"2023-05-11T00:00:00\",\"2023-05-11T00:00:00\",\"Gebrochene Kettbaum Scheibe auswechseln. Steht vor der Schlosserei.\"]],\"hovertemplate\":\"ErstellungsDatum=%{x|%d.%m.%Y}\\u003cbr\\u003edelta=%{y}\\u003cbr\\u003eErledigungsDatum=%{customdata[0]|%d.%m.%Y}\\u003cbr\\u003eVorgangsDatum=%{customdata[1]|%d.%m.%Y}\\u003cbr\\u003eVorgangsBeschreibung=%{customdata[2]}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"\",\"marker\":{\"color\":\"red\",\"symbol\":\"cross\",\"size\":8},\"mode\":\"markers\",\"name\":\"\",\"orientation\":\"v\",\"showlegend\":false,\"x\":[\"2020-12-10T00:00:00\",\"2021-12-16T00:00:00\",\"2022-06-21T00:00:00\",\"2022-12-12T00:00:00\",\"2022-02-03T00:00:00\",\"2022-03-28T00:00:00\",\"2022-01-26T00:00:00\",\"2021-12-15T00:00:00\",\"2023-01-21T00:00:00\",\"2021-12-12T00:00:00\",\"2020-02-10T00:00:00\",\"2019-11-13T00:00:00\",\"2019-11-11T00:00:00\",\"2023-01-25T00:00:00\",\"2020-03-23T00:00:00\",\"2020-03-22T00:00:00\",\"2020-06-24T00:00:00\",\"2021-01-06T00:00:00\",\"2022-09-12T00:00:00\",\"2020-01-09T00:00:00\",\"2020-01-10T00:00:00\",\"2021-07-06T00:00:00\",\"2020-02-20T00:00:00\",\"2022-04-01T00:00:00\",\"2021-05-05T00:00:00\",\"2022-05-23T00:00:00\",\"2022-01-30T00:00:00\",\"2023-03-12T00:00:00\",\"2022-03-24T00:00:00\",\"2022-04-25T00:00:00\",\"2023-05-11T00:00:00\"],\"xaxis\":\"x\",\"y\":[4,1,1,1,0,0,0,1,2,1,0,5,0,1,0,1,0,2,4,1,3,2,0,0,0,1,1,1,0,1,0],\"yaxis\":\"y\",\"type\":\"scatter\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"ErstellungsDatum\"},\"tickformat\":\"%B\\n%Y\"},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"delta\"},\"dtick\":1},\"legend\":{\"tracegroupgap\":0},\"margin\":{\"t\":60},\"hovermode\":\"x unified\"},                        {\"responsive\": true}                    ).then(function(){\n",
       "                            \n",
       "var gd = document.getElementById('1eafb9c2-4e4a-48cd-b91e-877cbaf8763e');\n",
       "var x = new MutationObserver(function (mutations, observer) {{\n",
       "        var display = window.getComputedStyle(gd).display;\n",
       "        if (!display || display === 'none') {{\n",
       "            console.log([gd, 'removed!']);\n",
       "            Plotly.purge(gd);\n",
       "            observer.disconnect();\n",
       "        }}\n",
       "}});\n",
       "\n",
       "// Listen for the removal of the full notebook cells\n",
       "var notebookContainer = gd.closest('#notebook-container');\n",
       "if (notebookContainer) {{\n",
       "    x.observe(notebookContainer, {childList: true});\n",
       "}}\n",
       "\n",
       "// Listen for the clearing of the current output cell\n",
       "var outputEl = gd.closest('.output');\n",
       "if (outputEl) {{\n",
       "    x.observe(outputEl, {childList: true});\n",
       "}}\n",
       "\n",
       "                        })                };                });            </script>        </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = px.scatter(filtered, x='ErstellungsDatum', y='delta', hover_data=HOVER_DATA_DELTA)\n",
    "#fig = px.timeline(filtered, x_start='ErstellungsDatum', x_end='ErledigungsDatum', y='VorgangsID')\n",
    "fig.update_traces(marker=MARKERS)\n",
    "fig.update_xaxes(tickformat='%B\\n%Y')\n",
    "#fig.update_yaxes(type='category')\n",
    "fig.update_yaxes(dtick=1)\n",
    "fig.update_layout(hovermode='x unified')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "cd71b556-592d-4c7e-a401-a66358b3e802",
   "metadata": {},
   "outputs": [],
   "source": [
    "scatt = go.Scatter(x=filtered['ErstellungsDatum'], y=filtered['delta'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aad3c784-363a-4355-b6e0-3d9caed46bc2",
   "metadata": {},
   "outputs": [],
   "source": [
    "scatt.update"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "83ff5f68-5bbc-4c5e-aace-c19152ba61cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "type": "scatter",
         "x": [
          "2020-12-10T00:00:00",
          "2021-12-16T00:00:00",
          "2022-06-21T00:00:00",
          "2022-12-12T00:00:00",
          "2022-02-03T00:00:00",
          "2022-03-28T00:00:00",
          "2022-01-26T00:00:00",
          "2021-12-15T00:00:00",
          "2023-01-21T00:00:00",
          "2021-12-12T00:00:00",
          "2020-02-10T00:00:00",
          "2019-11-13T00:00:00",
          "2019-11-11T00:00:00",
          "2023-01-25T00:00:00",
          "2020-03-23T00:00:00",
          "2020-03-22T00:00:00",
          "2020-06-24T00:00:00",
          "2021-01-06T00:00:00",
          "2022-09-12T00:00:00",
          "2020-01-09T00:00:00",
          "2020-01-10T00:00:00",
          "2021-07-06T00:00:00",
          "2020-02-20T00:00:00",
          "2022-04-01T00:00:00",
          "2021-05-05T00:00:00",
          "2022-05-23T00:00:00",
          "2022-01-30T00:00:00",
          "2023-03-12T00:00:00",
          "2022-03-24T00:00:00",
          "2022-04-25T00:00:00",
          "2023-05-11T00:00:00"
         ],
         "y": [
          4,
          1,
          1,
          1,
          0,
          0,
          0,
          1,
          2,
          1,
          0,
          5,
          0,
          1,
          0,
          1,
          0,
          2,
          4,
          1,
          3,
          2,
          0,
          0,
          0,
          1,
          1,
          1,
          0,
          1,
          0
         ]
        }
       ],
       "layout": {
        "autosize": true,
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "xaxis": {
         "autorange": true,
         "range": [
          "2019-11-11",
          "2023-05-11"
         ],
         "type": "date"
        },
        "yaxis": {
         "autorange": true,
         "range": [
          -0.2777777777777778,
          5.277777777777778
         ],
         "type": "linear"
        }
       }
      },
      "image/png": "[encoded data, 58732 characters]",
      "text/html": [
       "<div>                            <div id=\"75527243-657d-47a2-ba3d-1a7b6e8ddf86\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                require([\"plotly\"], function(Plotly) {                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"75527243-657d-47a2-ba3d-1a7b6e8ddf86\")) {                    Plotly.newPlot(                        \"75527243-657d-47a2-ba3d-1a7b6e8ddf86\",                        [{\"x\":[\"2020-12-10T00:00:00\",\"2021-12-16T00:00:00\",\"2022-06-21T00:00:00\",\"2022-12-12T00:00:00\",\"2022-02-03T00:00:00\",\"2022-03-28T00:00:00\",\"2022-01-26T00:00:00\",\"2021-12-15T00:00:00\",\"2023-01-21T00:00:00\",\"2021-12-12T00:00:00\",\"2020-02-10T00:00:00\",\"2019-11-13T00:00:00\",\"2019-11-11T00:00:00\",\"2023-01-25T00:00:00\",\"2020-03-23T00:00:00\",\"2020-03-22T00:00:00\",\"2020-06-24T00:00:00\",\"2021-01-06T00:00:00\",\"2022-09-12T00:00:00\",\"2020-01-09T00:00:00\",\"2020-01-10T00:00:00\",\"2021-07-06T00:00:00\",\"2020-02-20T00:00:00\",\"2022-04-01T00:00:00\",\"2021-05-05T00:00:00\",\"2022-05-23T00:00:00\",\"2022-01-30T00:00:00\",\"2023-03-12T00:00:00\",\"2022-03-24T00:00:00\",\"2022-04-25T00:00:00\",\"2023-05-11T00:00:00\"],\"y\":[4,1,1,1,0,0,0,1,2,1,0,5,0,1,0,1,0,2,4,1,3,2,0,0,0,1,1,1,0,1,0],\"type\":\"scatter\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}}},                        {\"responsive\": true}                    ).then(function(){\n",
       "                            \n",
       "var gd = document.getElementById('75527243-657d-47a2-ba3d-1a7b6e8ddf86');\n",
       "var x = new MutationObserver(function (mutations, observer) {{\n",
       "        var display = window.getComputedStyle(gd).display;\n",
       "        if (!display || display === 'none') {{\n",
       "            console.log([gd, 'removed!']);\n",
       "            Plotly.purge(gd);\n",
       "            observer.disconnect();\n",
       "        }}\n",
       "}});\n",
       "\n",
       "// Listen for the removal of the full notebook cells\n",
       "var notebookContainer = gd.closest('#notebook-container');\n",
       "if (notebookContainer) {{\n",
       "    x.observe(notebookContainer, {childList: true});\n",
       "}}\n",
       "\n",
       "// Listen for the clearing of the current output cell\n",
       "var outputEl = gd.closest('.output');\n",
       "if (outputEl) {{\n",
       "    x.observe(outputEl, {childList: true});\n",
       "}}\n",
       "\n",
       "                        })                };                });            </script>        </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = go.Figure()\n",
    "fig.add_trace(scatt)\n",
    "fig.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6825ed5b-3800-4fb7-8ba7-ea4fd6a846eb",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "06841e37-df70-4d59-8883-2d11161ab47c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "alignmentgroup": "True",
         "base": [
          "2020-12-10T00:00:00",
          "2021-12-16T00:00:00",
          "2022-06-21T00:00:00",
          "2022-12-12T00:00:00",
          "2022-02-03T00:00:00",
          "2022-03-28T00:00:00",
          "2022-01-26T00:00:00",
          "2021-12-15T00:00:00",
          "2023-01-21T00:00:00",
          "2021-12-12T00:00:00",
          "2020-02-10T00:00:00",
          "2019-11-13T00:00:00",
          "2019-11-11T00:00:00",
          "2023-01-25T00:00:00",
          "2020-03-23T00:00:00",
          "2020-03-22T00:00:00",
          "2020-06-24T00:00:00",
          "2021-01-06T00:00:00",
          "2022-09-12T00:00:00",
          "2020-01-09T00:00:00",
          "2020-01-10T00:00:00",
          "2021-07-06T00:00:00",
          "2020-02-20T00:00:00",
          "2022-04-01T00:00:00",
          "2021-05-05T00:00:00",
          "2022-05-23T00:00:00",
          "2022-01-30T00:00:00",
          "2023-03-12T00:00:00",
          "2022-03-24T00:00:00",
          "2022-04-25T00:00:00",
          "2023-05-11T00:00:00"
         ],
         "hovertemplate": "ErstellungsDatum=%{base}<br>ErledigungsDatum=%{x}<br>VorgangsID=%{y}<extra></extra>",
         "legendgroup": "",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "",
         "offsetgroup": "",
         "orientation": "h",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": [
          345600000,
          86400000,
          86400000,
          86400000,
          0,
          0,
          0,
          86400000,
          172800000,
          86400000,
          0,
          432000000,
          0,
          86400000,
          0,
          86400000,
          0,
          172800000,
          345600000,
          86400000,
          259200000,
          172800000,
          0,
          0,
          0,
          86400000,
          86400000,
          86400000,
          0,
          86400000,
          0
         ],
         "xaxis": "x",
         "y": [
          70133,
          146532,
          260631,
          496050,
          149786,
          246447,
          149582,
          146522,
          508696,
          146448,
          35177,
          20810,
          20794,
          508973,
          38567,
          38566,
          46602,
          92682,
          273263,
          30320,
          30347,
          133495,
          35862,
          246860,
          123784,
          259615,
          149651,
          518785,
          246256,
          254123,
          531578
         ],
         "yaxis": "y"
        }
       ],
       "layout": {
        "autosize": true,
        "barmode": "overlay",
        "legend": {
         "tracegroupgap": 0
        },
        "margin": {
         "t": 60
        },
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "#E5ECF6",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "white",
             "linecolor": "white",
             "minorgridcolor": "white",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "heatmapgl": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmapgl"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "#E5ECF6",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "white"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "#E5ECF6",
          "polar": {
           "angularaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "radialaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "yaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           },
           "zaxis": {
            "backgroundcolor": "#E5ECF6",
            "gridcolor": "white",
            "gridwidth": 2,
            "linecolor": "white",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "white"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           },
           "bgcolor": "#E5ECF6",
           "caxis": {
            "gridcolor": "white",
            "linecolor": "white",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "white",
           "linecolor": "white",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "white",
           "zerolinewidth": 2
          }
         }
        },
        "xaxis": {
         "anchor": "y",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "range": [
          "2019-09-01 01:20",
          "2023-07-20 22:40"
         ],
         "tickformat": "%B\n%Y",
         "type": "date"
        },
        "yaxis": {
         "anchor": "x",
         "autorange": true,
         "domain": [
          0,
          1
         ],
         "range": [
          -0.5,
          30.5
         ],
         "title": {
          "text": "VorgangsID"
         },
         "type": "category"
        }
       }
      },
      "image/png": "[encoded data, 36732 characters]",
      "text/html": [
       "<div>                            <div id=\"cd137535-45bb-4ca1-98a5-50e849527307\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                require([\"plotly\"], function(Plotly) {                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"cd137535-45bb-4ca1-98a5-50e849527307\")) {                    Plotly.newPlot(                        \"cd137535-45bb-4ca1-98a5-50e849527307\",                        [{\"alignmentgroup\":\"True\",\"base\":[\"2020-12-10T00:00:00\",\"2021-12-16T00:00:00\",\"2022-06-21T00:00:00\",\"2022-12-12T00:00:00\",\"2022-02-03T00:00:00\",\"2022-03-28T00:00:00\",\"2022-01-26T00:00:00\",\"2021-12-15T00:00:00\",\"2023-01-21T00:00:00\",\"2021-12-12T00:00:00\",\"2020-02-10T00:00:00\",\"2019-11-13T00:00:00\",\"2019-11-11T00:00:00\",\"2023-01-25T00:00:00\",\"2020-03-23T00:00:00\",\"2020-03-22T00:00:00\",\"2020-06-24T00:00:00\",\"2021-01-06T00:00:00\",\"2022-09-12T00:00:00\",\"2020-01-09T00:00:00\",\"2020-01-10T00:00:00\",\"2021-07-06T00:00:00\",\"2020-02-20T00:00:00\",\"2022-04-01T00:00:00\",\"2021-05-05T00:00:00\",\"2022-05-23T00:00:00\",\"2022-01-30T00:00:00\",\"2023-03-12T00:00:00\",\"2022-03-24T00:00:00\",\"2022-04-25T00:00:00\",\"2023-05-11T00:00:00\"],\"hovertemplate\":\"ErstellungsDatum=%{base}\\u003cbr\\u003eErledigungsDatum=%{x}\\u003cbr\\u003eVorgangsID=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"\",\"marker\":{\"color\":\"#636efa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"\",\"offsetgroup\":\"\",\"orientation\":\"h\",\"showlegend\":false,\"textposition\":\"auto\",\"x\":[345600000.0,86400000.0,86400000.0,86400000.0,0.0,0.0,0.0,86400000.0,172800000.0,86400000.0,0.0,432000000.0,0.0,86400000.0,0.0,86400000.0,0.0,172800000.0,345600000.0,86400000.0,259200000.0,172800000.0,0.0,0.0,0.0,86400000.0,86400000.0,86400000.0,0.0,86400000.0,0.0],\"xaxis\":\"x\",\"y\":[70133,146532,260631,496050,149786,246447,149582,146522,508696,146448,35177,20810,20794,508973,38567,38566,46602,92682,273263,30320,30347,133495,35862,246860,123784,259615,149651,518785,246256,254123,531578],\"yaxis\":\"y\",\"type\":\"bar\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"type\":\"date\",\"tickformat\":\"%B\\n%Y\"},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"VorgangsID\"},\"type\":\"category\"},\"legend\":{\"tracegroupgap\":0},\"margin\":{\"t\":60},\"barmode\":\"overlay\"},                        {\"responsive\": true}                    ).then(function(){\n",
       "                            \n",
       "var gd = document.getElementById('cd137535-45bb-4ca1-98a5-50e849527307');\n",
       "var x = new MutationObserver(function (mutations, observer) {{\n",
       "        var display = window.getComputedStyle(gd).display;\n",
       "        if (!display || display === 'none') {{\n",
       "            console.log([gd, 'removed!']);\n",
       "            Plotly.purge(gd);\n",
       "            observer.disconnect();\n",
       "        }}\n",
       "}});\n",
       "\n",
       "// Listen for the removal of the full notebook cells\n",
       "var notebookContainer = gd.closest('#notebook-container');\n",
       "if (notebookContainer) {{\n",
       "    x.observe(notebookContainer, {childList: true});\n",
       "}}\n",
       "\n",
       "// Listen for the clearing of the current output cell\n",
       "var outputEl = gd.closest('.output');\n",
       "if (outputEl) {{\n",
       "    x.observe(outputEl, {childList: true});\n",
       "}}\n",
       "\n",
       "                        })                };                });            </script>        </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#fig = px.scatter(filtered, x='ErstellungsDatum', y='delta')\n",
    "fig = px.timeline(filtered, x_start='ErstellungsDatum', x_end='ErledigungsDatum', y='VorgangsID')\n",
    "fig.update_xaxes(tickformat='%B\\n%Y')\n",
    "fig.update_yaxes(type='category')\n",
    "#fig.update_yaxes(tickformat=',d', dtick=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c1bd744d-50a6-49c1-8559-3f71b416e18c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "81a6d2d2-51c1-4c49-8451-5f38dd39c90a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c07e03d5-b2c7-4c7e-a6ff-2257c586e7ba",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "453b461b-644c-4d9e-b5ff-faef6fa4698c",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "# Wertigkeit von Maßnahmen"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "37e08060-3b88-4215-b705-c274d04f1976",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-31 10:35:55 +0000 | io:INFO | Loaded TOML config file successfully.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:441: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
      "  warnings.warn(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\transformers\\utils\\generic.py:309: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.\n",
      "  _torch_pytree._register_pytree_node(\n",
      "A:\\Arbeitsaufgaben\\lang-main\\.venv\\Lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "from lang_main import io\n",
    "from lang_main.analysis.graphs import rescale_edge_weights, get_graph_metadata\n",
    "from lang_main.types import EntryPoints\n",
    "from lang_main.constants import SAVE_PATH_FOLDER\n",
    "from lang_main.analysis.shared import entry_wise_cleansing\n",
    "\n",
    "from pathlib import Path\n",
    "import pickle\n",
    "import base64\n",
    "import os\n",
    "from logging import NullHandler\n",
    "\n",
    "import numpy as np\n",
    "import networkx as nx\n",
    "\n",
    "import py4cytoscape as p4c\n",
    "#import py4cytoscape.py4cytoscape_logger_settings as p4c_logging\n",
    "#p4c.set_summary_logger(False)\n",
    "#p4c_logging._SUMMARY_LOG_LEVEL = 'ERROR'\n",
    "# p4c_logging._DETAIL_LOG_LEVEL = 'ERROR'\n",
    "#p4c.py4cytoscape_logger.detail_logger.setLevel('ERROR')\n",
    "#p4c.py4cytoscape_logger.detail_logger.removeHandler(p4c.py4cytoscape_logger.detail_handler)\n",
    "#p4c.py4cytoscape_logger.detail_logger.addHandler(NullHandler())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dda237bc-9835-4db2-9825-9e97991de60e",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main.analysis.timeline import filter_timeline_cands, cleanup_descriptions, calc_delta_to_next_failure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b0de4b11-d120-4827-8668-9c101a95d051",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2024-07-31 10:36:04 +0000 | io:INFO | Loaded file successfully.\n",
      "2024-07-31 10:36:04 +0000 | io:INFO | Loaded file successfully.\n"
     ]
    }
   ],
   "source": [
    "p_df = io.get_entry_point(SAVE_PATH_FOLDER, EntryPoints.TIMELINE_POST)\n",
    "# p_df = io.get_entry_point(SAVE_PATH_FOLDER, EntryPoints.TIMELINE)\n",
    "(data,) = io.load_pickle(p_df)\n",
    "# p_tl = Path(r'../results/test_20240619/TIMELINE_POSTPROCESSING.pkl').resolve()\n",
    "p_tl = io.get_entry_point(SAVE_PATH_FOLDER, EntryPoints.TIMELINE_CANDS)\n",
    "cands, texts = io.load_pickle(p_tl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "be9d9dd7-47a6-42ea-99e3-290fe3d40844",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['VorgangsID', 'ObjektID', 'HObjektText', 'ObjektArtID', 'ObjektArtText',\n",
       "       'VorgangsTypID', 'VorgangsTypName', 'VorgangsDatum', 'VorgangsStatusId',\n",
       "       'VorgangsPrioritaet', 'VorgangsBeschreibung', 'VorgangsOrt',\n",
       "       'VorgangsArtText', 'ErledigungsDatum', 'ErledigungsArtText',\n",
       "       'ErledigungsBeschreibung', 'MPMelderArbeitsplatz',\n",
       "       'MPAbteilungBezeichnung', 'Arbeitsbeginn', 'ErstellungsDatum',\n",
       "       'delta_to_repair'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "756c9465-2aed-4463-ab1a-34c78742b95d",
   "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>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>...</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "      <th>delta_to_repair</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>53</td>\n",
       "      <td>244</td>\n",
       "      <td>285 C, Webmaschine, SG 220 EMS</td>\n",
       "      <td>5</td>\n",
       "      <td>Greifer-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-19</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kupplung defekt</td>\n",
       "      <td>2019-03-20</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>N.V.</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2019-03-19</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>58</td>\n",
       "      <td>257</td>\n",
       "      <td>107, Webmaschine, OM 220 EOS</td>\n",
       "      <td>3</td>\n",
       "      <td>Luft-Webmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-21</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Gegengewicht an der Webmaschine abgefallen</td>\n",
       "      <td>2019-03-21</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube ausgebohrt. Gegengewicht wieder angeb...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-03-21</td>\n",
       "      <td>2019-03-21</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>81</td>\n",
       "      <td>138</td>\n",
       "      <td>00138, Schärmaschine 9,</td>\n",
       "      <td>16</td>\n",
       "      <td>Schärmaschine</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>zentrale Bremsenverstellung linke Gatterseite ...</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Bolzen gebrochen. Bolzen neu angefertig und di...</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>82</td>\n",
       "      <td>0</td>\n",
       "      <td>Warenschau allgemein</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>Warenschau allgemein</td>\n",
       "      <td>Allgemeine Reparaturarbeiten</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Feder ausgetauscht</td>\n",
       "      <td>Warenschau</td>\n",
       "      <td>Warenschau</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>76</td>\n",
       "      <td>0</td>\n",
       "      <td>Neben der Türe</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-03-22</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>Neben der Türe</td>\n",
       "      <td>Kettbaum</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schrauben ausgebohrt . Gewinde nachgeschnitten</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>Vorwerk</td>\n",
       "      <td>2019-03-25</td>\n",
       "      <td>2019-03-22</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   VorgangsID  ObjektID                     HObjektText  ObjektArtID  \\\n",
       "0          53       244  285 C, Webmaschine, SG 220 EMS            5   \n",
       "1          58       257    107, Webmaschine, OM 220 EOS            3   \n",
       "2          81       138        00138, Schärmaschine 9,            16   \n",
       "3          82         0            Warenschau allgemein            0   \n",
       "4          76         0                  Neben der Türe            0   \n",
       "\n",
       "         ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "0  Greifer-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "1     Luft-Webmaschine              3  Reparaturauftrag (Portal)   \n",
       "2        Schärmaschine              3  Reparaturauftrag (Portal)   \n",
       "3                  NaN              3  Reparaturauftrag (Portal)   \n",
       "4                  NaN              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "  VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  ...  \\\n",
       "0    2019-03-19                 5                   0  ...   \n",
       "1    2019-03-21                 5                   0  ...   \n",
       "2    2019-03-25                 5                   0  ...   \n",
       "3    2019-03-25                 5                   0  ...   \n",
       "4    2019-03-22                 5                   0  ...   \n",
       "\n",
       "            VorgangsOrt                                    VorgangsArtText  \\\n",
       "0                   NaN                                    Kupplung defekt   \n",
       "1                   NaN         Gegengewicht an der Webmaschine abgefallen   \n",
       "2                   NaN  zentrale Bremsenverstellung linke Gatterseite ...   \n",
       "3  Warenschau allgemein                      Allgemeine Reparaturarbeiten    \n",
       "4        Neben der Türe                                           Kettbaum   \n",
       "\n",
       "  ErledigungsDatum ErledigungsArtText  \\\n",
       "0       2019-03-20      Reparatur UTT   \n",
       "1       2019-03-21      Reparatur UTT   \n",
       "2       2019-03-25      Reparatur UTT   \n",
       "3       2019-03-25      Reparatur UTT   \n",
       "4       2019-03-25      Reparatur UTT   \n",
       "\n",
       "                             ErledigungsBeschreibung MPMelderArbeitsplatz  \\\n",
       "0                                               N.V.              Weberei   \n",
       "1  Schraube ausgebohrt. Gegengewicht wieder angeb...              Weberei   \n",
       "2  Bolzen gebrochen. Bolzen neu angefertig und di...              Vorwerk   \n",
       "3                                 Feder ausgetauscht           Warenschau   \n",
       "4     Schrauben ausgebohrt . Gewinde nachgeschnitten              Vorwerk   \n",
       "\n",
       "  MPAbteilungBezeichnung Arbeitsbeginn ErstellungsDatum delta_to_repair  \n",
       "0                Weberei           NaT       2019-03-19               1  \n",
       "1                Weberei    2019-03-21       2019-03-21               0  \n",
       "2                Vorwerk    2019-03-25       2019-03-25               0  \n",
       "3             Warenschau    2019-03-25       2019-03-25               0  \n",
       "4                Vorwerk    2019-03-25       2019-03-22               3  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c1a4b962-8b14-4f9b-9a3f-522c52b5c325",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_clean = data.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cd8fdcf4-18e6-4e38-b839-fc04872a3966",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1960df45-058c-40f1-baed-9ab19375d404",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "803555d7-57f3-4b4b-b657-caa81aca1c88",
   "metadata": {},
   "outputs": [],
   "source": [
    "string_cols_postproc = [\n",
    "    'VorgangsBeschreibung',\n",
    "    'ErledigungsBeschreibung'\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "ebf16eef-e1f4-4ae8-a6a3-09889bb42439",
   "metadata": {},
   "outputs": [],
   "source": [
    "data[string_cols_postproc] = data[string_cols_postproc].fillna('N.V.').copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "8edea7e8-283a-499d-b7b4-00002e691a30",
   "metadata": {},
   "outputs": [],
   "source": [
    "data[string_cols_postproc] = data[string_cols_postproc].map(clean_strings_dataframes).copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b3e03239-52fd-41cd-8f94-c13b5236adae",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7ab104ae-518e-422f-87be-f75203b6669a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "adc7b98c-d8ce-4c68-8a48-864ff8a64264",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = filter_timeline_cands(data_clean, cands, 1654, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "689bd3d6-2d58-4944-9c46-8548aa34f63e",
   "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>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>...</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "      <th>delta_to_repair</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>57937</th>\n",
       "      <td>24650</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-12-02</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2019-12-03</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>lager entfernt und neu eingebaut</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-12-03</td>\n",
       "      <td>2019-12-02</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57927</th>\n",
       "      <td>24704</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-12-03</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2019-12-04</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Zylinderkopfschrauben am Kettbaumadapter ausge...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-12-04</td>\n",
       "      <td>2019-12-03</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7579</th>\n",
       "      <td>25414</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-12-13</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2019-12-16</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube ausgebohrt und gewinde nachgeschitten.</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-12-16</td>\n",
       "      <td>2019-12-13</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66749</th>\n",
       "      <td>30359</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-01-12</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube von Adapter entfernt</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>2020-01-12</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1680</th>\n",
       "      <td>49908</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>Extern - Reparatur</td>\n",
       "      <td>Kettbaum Lagerauflage ist defekt und nicht meh...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       VorgangsID  ObjektID                             HObjektText  \\\n",
       "57937       24650      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "57927       24704      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "7579        25414      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "66749       30359      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "1680        49908      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "\n",
       "       ObjektArtID  ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "57937           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "57927           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "7579            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "66749           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "1680            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "      VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  ... VorgangsOrt  \\\n",
       "57937    2019-12-02                 2                   0  ...         NaN   \n",
       "57927    2019-12-03                 5                   0  ...         NaN   \n",
       "7579     2019-12-13                 5                   0  ...         NaN   \n",
       "66749    2020-01-12                 5                   0  ...         NaN   \n",
       "1680     2020-07-13                 5                   0  ...         NaN   \n",
       "\n",
       "        VorgangsArtText ErledigungsDatum  ErledigungsArtText  \\\n",
       "57937  Kettbaum-Adapter       2019-12-03       Reparatur UTT   \n",
       "57927  Kettbaum-Adapter       2019-12-04       Reparatur UTT   \n",
       "7579   Kettbaum-Adapter       2019-12-16       Reparatur UTT   \n",
       "66749  Kettbaum-Adapter       2020-01-13       Reparatur UTT   \n",
       "1680   Kettbaum-Adapter       2020-07-13  Extern - Reparatur   \n",
       "\n",
       "                                 ErledigungsBeschreibung MPMelderArbeitsplatz  \\\n",
       "57937                   lager entfernt und neu eingebaut              Weberei   \n",
       "57927  Zylinderkopfschrauben am Kettbaumadapter ausge...              Weberei   \n",
       "7579     Schraube ausgebohrt und gewinde nachgeschitten.              Weberei   \n",
       "66749                      Schraube von Adapter entfernt              Weberei   \n",
       "1680   Kettbaum Lagerauflage ist defekt und nicht meh...              Weberei   \n",
       "\n",
       "      MPAbteilungBezeichnung Arbeitsbeginn ErstellungsDatum delta_to_repair  \n",
       "57937                Weberei    2019-12-03       2019-12-02               1  \n",
       "57927                Weberei    2019-12-04       2019-12-03               1  \n",
       "7579                 Weberei    2019-12-16       2019-12-13               3  \n",
       "66749                Weberei    2020-01-13       2020-01-12               1  \n",
       "1680                 Weberei    2020-07-13       2020-07-13               0  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "121f0ca2-43d5-46d4-a5a0-66c4bbf1ce0a",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_delta = calc_delta_to_next_failure(df, date_feature='ErstellungsDatum', name_delta_feature='delta')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9bcf4372-5b94-4e74-a440-6a5cdd1ec0da",
   "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>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>...</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "      <th>delta_to_repair</th>\n",
       "      <th>delta</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117758</th>\n",
       "      <td>272716</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2022-08-28</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2022-08-29</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Schraube ausgebohrt und Gewinde nachgeschnitten</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2022-08-29</td>\n",
       "      <td>2022-08-28</td>\n",
       "      <td>1</td>\n",
       "      <td>198 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66749</th>\n",
       "      <td>30359</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-01-12</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube von Adapter entfernt</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>2020-01-12</td>\n",
       "      <td>1</td>\n",
       "      <td>183 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119480</th>\n",
       "      <td>253945</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>2</td>\n",
       "      <td>Störungsmeldung</td>\n",
       "      <td>2022-04-22</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2022-04-25</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Eine seite neue Gewinde gebohrt und geschnitte...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2022-04-22</td>\n",
       "      <td>2022-04-22</td>\n",
       "      <td>3</td>\n",
       "      <td>128 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46790</th>\n",
       "      <td>103707</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Kettbaum-Adapter schrauben entfernt und gewind...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>0</td>\n",
       "      <td>103 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1680</th>\n",
       "      <td>49908</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>Extern - Reparatur</td>\n",
       "      <td>Kettbaum Lagerauflage ist defekt und nicht meh...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>0</td>\n",
       "      <td>72 days</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        VorgangsID  ObjektID                             HObjektText  \\\n",
       "117758      272716      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "66749        30359      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "119480      253945      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "46790       103707      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "1680         49908      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "\n",
       "        ObjektArtID  ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "117758           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "66749            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "119480           90  UTT allgemein              2            Störungsmeldung   \n",
       "46790            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "1680             90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "       VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  ...  \\\n",
       "117758    2022-08-28                 5                   0  ...   \n",
       "66749     2020-01-12                 5                   0  ...   \n",
       "119480    2022-04-22                 5                   0  ...   \n",
       "46790     2021-02-16                 5                   0  ...   \n",
       "1680      2020-07-13                 5                   0  ...   \n",
       "\n",
       "         VorgangsArtText ErledigungsDatum       ErledigungsArtText  \\\n",
       "117758  Kettbaum-Adapter       2022-08-29  Intern UTT - Reparatur    \n",
       "66749   Kettbaum-Adapter       2020-01-13            Reparatur UTT   \n",
       "119480  Kettbaum-Adapter       2022-04-25  Intern UTT - Reparatur    \n",
       "46790   Kettbaum-Adapter       2021-02-16  Intern UTT - Reparatur    \n",
       "1680    Kettbaum-Adapter       2020-07-13       Extern - Reparatur   \n",
       "\n",
       "                                  ErledigungsBeschreibung  \\\n",
       "117758    Schraube ausgebohrt und Gewinde nachgeschnitten   \n",
       "66749                       Schraube von Adapter entfernt   \n",
       "119480  Eine seite neue Gewinde gebohrt und geschnitte...   \n",
       "46790   Kettbaum-Adapter schrauben entfernt und gewind...   \n",
       "1680    Kettbaum Lagerauflage ist defekt und nicht meh...   \n",
       "\n",
       "       MPMelderArbeitsplatz MPAbteilungBezeichnung Arbeitsbeginn  \\\n",
       "117758              Weberei                Weberei    2022-08-29   \n",
       "66749               Weberei                Weberei    2020-01-13   \n",
       "119480                  NaN                    NaN    2022-04-22   \n",
       "46790               Weberei                Weberei    2021-02-16   \n",
       "1680                Weberei                Weberei    2020-07-13   \n",
       "\n",
       "       ErstellungsDatum delta_to_repair    delta  \n",
       "117758       2022-08-28               1 198 days  \n",
       "66749        2020-01-12               1 183 days  \n",
       "119480       2022-04-22               3 128 days  \n",
       "46790        2021-02-16               0 103 days  \n",
       "1680         2020-07-13               0  72 days  \n",
       "\n",
       "[5 rows x 22 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_delta.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "8de699a4-16bc-4f66-9d4d-0d9f0384db61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "117758    198\n",
       "66749     183\n",
       "119480    128\n",
       "46790     103\n",
       "1680       72\n",
       "43412      70\n",
       "100461     66\n",
       "2774       60\n",
       "122902     59\n",
       "111241     55\n",
       "83         54\n",
       "6798       45\n",
       "67562      38\n",
       "78986      32\n",
       "7579       30\n",
       "96080      22\n",
       "55024      14\n",
       "98277      11\n",
       "57927      10\n",
       "1743       10\n",
       "8084        7\n",
       "4846        6\n",
       "55952       5\n",
       "32229       5\n",
       "78778       3\n",
       "46791       2\n",
       "57937       1\n",
       "2980        0\n",
       "43411       0\n",
       "87479       0\n",
       "Name: delta, dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_delta['delta'].dt.days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b63b688d-29ac-4962-a49c-68417c5e16c6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f30e465-6c19-4425-b3c8-7f02b6de41e0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "1b2516c2-ec45-4ed0-8e39-1db3ad4929a2",
   "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>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>VorgangsBeschreibung</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>57937</th>\n",
       "      <td>24650</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-12-02</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>Kettbaum-Adapter-Lager defekt. (Martino inform...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2019-12-03</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>lager entfernt und neu eingebaut</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-12-03</td>\n",
       "      <td>2019-12-02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57927</th>\n",
       "      <td>24704</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-12-03</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Schrauben rund. Bitte ausbohren. Kette steht v...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2019-12-04</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Zylinderkopfschrauben am Kettbaumadapter ausge...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-12-04</td>\n",
       "      <td>2019-12-03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7579</th>\n",
       "      <td>25414</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2019-12-13</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Schraube rund.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2019-12-16</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube ausgebohrt und gewinde nachgeschitten.</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2019-12-16</td>\n",
       "      <td>2019-12-13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66749</th>\n",
       "      <td>30359</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-01-12</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Schraube von Adapter entfernen. Abgebrochener ...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube von Adapter entfernt</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>2020-01-12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1680</th>\n",
       "      <td>49908</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>Kettbaum Adapter Lager erneuern.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>Extern - Reparatur</td>\n",
       "      <td>Kettbaum Lagerauflage ist defekt und nicht meh...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>2020-07-13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       VorgangsID  ObjektID                             HObjektText  \\\n",
       "57937       24650      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "57927       24704      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "7579        25414      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "66749       30359      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "1680        49908      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "\n",
       "       ObjektArtID  ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "57937           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "57927           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "7579            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "66749           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "1680            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "      VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  \\\n",
       "57937    2019-12-02                 2                   0   \n",
       "57927    2019-12-03                 5                   0   \n",
       "7579     2019-12-13                 5                   0   \n",
       "66749    2020-01-12                 5                   0   \n",
       "1680     2020-07-13                 5                   0   \n",
       "\n",
       "                                    VorgangsBeschreibung VorgangsOrt  \\\n",
       "57937  Kettbaum-Adapter-Lager defekt. (Martino inform...         NaN   \n",
       "57927  Schrauben rund. Bitte ausbohren. Kette steht v...         NaN   \n",
       "7579                                      Schraube rund.         NaN   \n",
       "66749  Schraube von Adapter entfernen. Abgebrochener ...         NaN   \n",
       "1680                    Kettbaum Adapter Lager erneuern.         NaN   \n",
       "\n",
       "        VorgangsArtText ErledigungsDatum  ErledigungsArtText  \\\n",
       "57937  Kettbaum-Adapter       2019-12-03       Reparatur UTT   \n",
       "57927  Kettbaum-Adapter       2019-12-04       Reparatur UTT   \n",
       "7579   Kettbaum-Adapter       2019-12-16       Reparatur UTT   \n",
       "66749  Kettbaum-Adapter       2020-01-13       Reparatur UTT   \n",
       "1680   Kettbaum-Adapter       2020-07-13  Extern - Reparatur   \n",
       "\n",
       "                                 ErledigungsBeschreibung MPMelderArbeitsplatz  \\\n",
       "57937                   lager entfernt und neu eingebaut              Weberei   \n",
       "57927  Zylinderkopfschrauben am Kettbaumadapter ausge...              Weberei   \n",
       "7579     Schraube ausgebohrt und gewinde nachgeschitten.              Weberei   \n",
       "66749                      Schraube von Adapter entfernt              Weberei   \n",
       "1680   Kettbaum Lagerauflage ist defekt und nicht meh...              Weberei   \n",
       "\n",
       "      MPAbteilungBezeichnung Arbeitsbeginn ErstellungsDatum  \n",
       "57937                Weberei    2019-12-03       2019-12-02  \n",
       "57927                Weberei    2019-12-04       2019-12-03  \n",
       "7579                 Weberei    2019-12-16       2019-12-13  \n",
       "66749                Weberei    2020-01-13       2020-01-12  \n",
       "1680                 Weberei    2020-07-13       2020-07-13  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.sort_values(by='ErstellungsDatum', ascending=True)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "725bb900-7c3d-4f82-9de1-73fb127a377c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Timestamp('2023-06-13 00:00:00')"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "last_val = df['ErstellungsDatum'].iat[-1]\n",
    "last_val"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "468a8c2b-59ce-48dc-ac94-41fbe12f174f",
   "metadata": {},
   "outputs": [],
   "source": [
    "shifted = df['ErstellungsDatum'].shift(-1, fill_value=last_val)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "dc44e019-19d7-46d6-9a4a-e619ac9ccfdc",
   "metadata": {},
   "outputs": [],
   "source": [
    "delta = shifted - df['ErstellungsDatum']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "c0aa7a33-56ba-4299-835c-245bb7d14aeb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "57937      1 days\n",
       "57927     10 days\n",
       "7579      30 days\n",
       "66749    183 days\n",
       "1680      72 days\n",
       "32229      5 days\n",
       "83        54 days\n",
       "1743      10 days\n",
       "43411      0 days\n",
       "43412     70 days\n",
       "55952      5 days\n",
       "46791      2 days\n",
       "46790    103 days\n",
       "96080     22 days\n",
       "78778      3 days\n",
       "67562     38 days\n",
       "100461    66 days\n",
       "2774      60 days\n",
       "6798      45 days\n",
       "4846       0 days\n",
       "2980       6 days\n",
       "8084       7 days\n",
       "98277     11 days\n",
       "111241    55 days\n",
       "55024     14 days\n",
       "119480   128 days\n",
       "117758   198 days\n",
       "122902    59 days\n",
       "78986     32 days\n",
       "87479      0 days\n",
       "Name: ErstellungsDatum, dtype: timedelta64[ns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "delta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c257fdc8-c4e7-4ef9-9bc8-3ab509e91ec3",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['delta_to_next_failure'] = delta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "bd00d516-cf46-4cf2-88fc-50444c237c3b",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_delta = df.sort_values(by='delta_to_next_failure', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "9c791440-9aaf-4d0c-97c3-2f3fa5c9584e",
   "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>VorgangsID</th>\n",
       "      <th>ObjektID</th>\n",
       "      <th>HObjektText</th>\n",
       "      <th>ObjektArtID</th>\n",
       "      <th>ObjektArtText</th>\n",
       "      <th>VorgangsTypID</th>\n",
       "      <th>VorgangsTypName</th>\n",
       "      <th>VorgangsDatum</th>\n",
       "      <th>VorgangsStatusId</th>\n",
       "      <th>VorgangsPrioritaet</th>\n",
       "      <th>...</th>\n",
       "      <th>VorgangsOrt</th>\n",
       "      <th>VorgangsArtText</th>\n",
       "      <th>ErledigungsDatum</th>\n",
       "      <th>ErledigungsArtText</th>\n",
       "      <th>ErledigungsBeschreibung</th>\n",
       "      <th>MPMelderArbeitsplatz</th>\n",
       "      <th>MPAbteilungBezeichnung</th>\n",
       "      <th>Arbeitsbeginn</th>\n",
       "      <th>ErstellungsDatum</th>\n",
       "      <th>delta_to_next_failure</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117758</th>\n",
       "      <td>272716</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2022-08-28</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2022-08-29</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Schraube ausgebohrt und Gewinde nachgeschnitten</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2022-08-29</td>\n",
       "      <td>2022-08-28</td>\n",
       "      <td>198 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66749</th>\n",
       "      <td>30359</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-01-12</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>Reparatur UTT</td>\n",
       "      <td>Schraube von Adapter entfernt</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-01-13</td>\n",
       "      <td>2020-01-12</td>\n",
       "      <td>183 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119480</th>\n",
       "      <td>253945</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>2</td>\n",
       "      <td>Störungsmeldung</td>\n",
       "      <td>2022-04-22</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2022-04-25</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Eine seite neue Gewinde gebohrt und geschnitte...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2022-04-22</td>\n",
       "      <td>2022-04-22</td>\n",
       "      <td>128 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46790</th>\n",
       "      <td>103707</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>Intern UTT - Reparatur</td>\n",
       "      <td>Kettbaum-Adapter schrauben  entfernt und gewin...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>2021-02-16</td>\n",
       "      <td>103 days</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1680</th>\n",
       "      <td>49908</td>\n",
       "      <td>1654</td>\n",
       "      <td>WEBEREI ALLGEMEIN, Weberei allgemein,</td>\n",
       "      <td>90</td>\n",
       "      <td>UTT allgemein</td>\n",
       "      <td>3</td>\n",
       "      <td>Reparaturauftrag (Portal)</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Kettbaum-Adapter</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>Extern - Reparatur</td>\n",
       "      <td>Kettbaum Lagerauflage ist defekt und nicht meh...</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>Weberei</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>2020-07-13</td>\n",
       "      <td>72 days</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        VorgangsID  ObjektID                             HObjektText  \\\n",
       "117758      272716      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "66749        30359      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "119480      253945      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "46790       103707      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "1680         49908      1654  WEBEREI ALLGEMEIN, Weberei allgemein,    \n",
       "\n",
       "        ObjektArtID  ObjektArtText  VorgangsTypID            VorgangsTypName  \\\n",
       "117758           90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "66749            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "119480           90  UTT allgemein              2            Störungsmeldung   \n",
       "46790            90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "1680             90  UTT allgemein              3  Reparaturauftrag (Portal)   \n",
       "\n",
       "       VorgangsDatum  VorgangsStatusId  VorgangsPrioritaet  ... VorgangsOrt  \\\n",
       "117758    2022-08-28                 5                   0  ...         NaN   \n",
       "66749     2020-01-12                 5                   0  ...         NaN   \n",
       "119480    2022-04-22                 5                   0  ...         NaN   \n",
       "46790     2021-02-16                 5                   0  ...         NaN   \n",
       "1680      2020-07-13                 5                   0  ...         NaN   \n",
       "\n",
       "         VorgangsArtText ErledigungsDatum       ErledigungsArtText  \\\n",
       "117758  Kettbaum-Adapter       2022-08-29  Intern UTT - Reparatur    \n",
       "66749   Kettbaum-Adapter       2020-01-13            Reparatur UTT   \n",
       "119480  Kettbaum-Adapter       2022-04-25  Intern UTT - Reparatur    \n",
       "46790   Kettbaum-Adapter       2021-02-16  Intern UTT - Reparatur    \n",
       "1680    Kettbaum-Adapter       2020-07-13       Extern - Reparatur   \n",
       "\n",
       "                                  ErledigungsBeschreibung  \\\n",
       "117758   Schraube ausgebohrt und Gewinde nachgeschnitten    \n",
       "66749                       Schraube von Adapter entfernt   \n",
       "119480  Eine seite neue Gewinde gebohrt und geschnitte...   \n",
       "46790   Kettbaum-Adapter schrauben  entfernt und gewin...   \n",
       "1680    Kettbaum Lagerauflage ist defekt und nicht meh...   \n",
       "\n",
       "       MPMelderArbeitsplatz MPAbteilungBezeichnung Arbeitsbeginn  \\\n",
       "117758              Weberei                Weberei    2022-08-29   \n",
       "66749               Weberei                Weberei    2020-01-13   \n",
       "119480                  NaN                    NaN    2022-04-22   \n",
       "46790               Weberei                Weberei    2021-02-16   \n",
       "1680                Weberei                Weberei    2020-07-13   \n",
       "\n",
       "       ErstellungsDatum delta_to_next_failure  \n",
       "117758       2022-08-28              198 days  \n",
       "66749        2020-01-12              183 days  \n",
       "119480       2022-04-22              128 days  \n",
       "46790        2021-02-16              103 days  \n",
       "1680         2020-07-13               72 days  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_delta.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "93d28d94-cf2a-4d96-bd9a-c6898f85f883",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_delta['ErledigungsBeschreibung'] = df_delta['ErledigungsBeschreibung'].fillna('N.V.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "403d0b49-f6e9-4d0d-92ef-45dbe81514a1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "21dfc078-3613-4422-97b1-4503b824f075",
   "metadata": {},
   "outputs": [],
   "source": [
    "potential_successful = df_delta[['delta_to_next_failure', 'ErledigungsBeschreibung']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "dddfd07c-51ed-4632-90cd-ffd6264404d1",
   "metadata": {},
   "outputs": [],
   "source": [
    "potential_successful.columns = ['Zeitspanne bis zum nächsten Ereignis [Tage]', 'Maßnahme']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "e0ca4427-6744-47df-b2e0-40ea49cd6182",
   "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>Zeitspanne bis zum nächsten Ereignis [Tage]</th>\n",
       "      <th>Maßnahme</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117758</th>\n",
       "      <td>198 days</td>\n",
       "      <td>Schraube ausgebohrt und Gewinde nachgeschnitten</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66749</th>\n",
       "      <td>183 days</td>\n",
       "      <td>Schraube von Adapter entfernt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119480</th>\n",
       "      <td>128 days</td>\n",
       "      <td>Eine seite neue Gewinde gebohrt und geschnitte...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46790</th>\n",
       "      <td>103 days</td>\n",
       "      <td>Kettbaum-Adapter schrauben  entfernt und gewin...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1680</th>\n",
       "      <td>72 days</td>\n",
       "      <td>Kettbaum Lagerauflage ist defekt und nicht meh...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43412</th>\n",
       "      <td>70 days</td>\n",
       "      <td>Zylinderschraube rausgebohrt und Gewinde nachg...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100461</th>\n",
       "      <td>66 days</td>\n",
       "      <td>N.V.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2774</th>\n",
       "      <td>60 days</td>\n",
       "      <td>abgbrochene Schrauben entfernt und alle Gewind...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>122902</th>\n",
       "      <td>59 days</td>\n",
       "      <td>Schraube ausgebohrt und Gewinde nachgeschnitten</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>111241</th>\n",
       "      <td>55 days</td>\n",
       "      <td>Neues Lager 6312 2Rs C3 eingebaut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83</th>\n",
       "      <td>54 days</td>\n",
       "      <td>Schraube ausgebohrt und Gewinde nach geschnitten.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6798</th>\n",
       "      <td>45 days</td>\n",
       "      <td>Neues Lochbild mit Schablone gebohrt, da abgeb...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67562</th>\n",
       "      <td>38 days</td>\n",
       "      <td>Schraube ausgebohrt.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78986</th>\n",
       "      <td>32 days</td>\n",
       "      <td>Schrauben ausgebohrt und Gewinde neu geschnitten.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7579</th>\n",
       "      <td>30 days</td>\n",
       "      <td>Schraube ausgebohrt und gewinde nachgeschitten.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96080</th>\n",
       "      <td>22 days</td>\n",
       "      <td>Zylinderkopfschrauben mit Innensechskant 3 Stü...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55024</th>\n",
       "      <td>14 days</td>\n",
       "      <td>Schraube von Kettbaumadapter ausgebohrt</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98277</th>\n",
       "      <td>11 days</td>\n",
       "      <td>erledigt.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57927</th>\n",
       "      <td>10 days</td>\n",
       "      <td>Zylinderkopfschrauben am Kettbaumadapter ausge...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1743</th>\n",
       "      <td>10 days</td>\n",
       "      <td>N.V.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8084</th>\n",
       "      <td>7 days</td>\n",
       "      <td>Altes Lager demontiert und neues montiert.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2980</th>\n",
       "      <td>6 days</td>\n",
       "      <td>Schrauben ausgebohrt und alle anderen Gewinde ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55952</th>\n",
       "      <td>5 days</td>\n",
       "      <td>Schrauben entfernt. alle gewinde nachgeschnitten</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32229</th>\n",
       "      <td>5 days</td>\n",
       "      <td>N.V.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78778</th>\n",
       "      <td>3 days</td>\n",
       "      <td>Kettbaum Schraube ausgebohrt und Gewinde nach ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46791</th>\n",
       "      <td>2 days</td>\n",
       "      <td>Neue Bohrlöcher angebracht, Gewinde geschnitte...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57937</th>\n",
       "      <td>1 days</td>\n",
       "      <td>lager entfernt und neu eingebaut</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4846</th>\n",
       "      <td>0 days</td>\n",
       "      <td>Schraube entfernt und alle anderen Gewinde nac...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43411</th>\n",
       "      <td>0 days</td>\n",
       "      <td>TK doppelt siehe tk 67187.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87479</th>\n",
       "      <td>0 days</td>\n",
       "      <td>Drei Schraubenköpfe aufgebohrt und Adapter run...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Zeitspanne bis zum nächsten Ereignis [Tage]  \\\n",
       "117758                                    198 days   \n",
       "66749                                     183 days   \n",
       "119480                                    128 days   \n",
       "46790                                     103 days   \n",
       "1680                                       72 days   \n",
       "43412                                      70 days   \n",
       "100461                                     66 days   \n",
       "2774                                       60 days   \n",
       "122902                                     59 days   \n",
       "111241                                     55 days   \n",
       "83                                         54 days   \n",
       "6798                                       45 days   \n",
       "67562                                      38 days   \n",
       "78986                                      32 days   \n",
       "7579                                       30 days   \n",
       "96080                                      22 days   \n",
       "55024                                      14 days   \n",
       "98277                                      11 days   \n",
       "57927                                      10 days   \n",
       "1743                                       10 days   \n",
       "8084                                        7 days   \n",
       "2980                                        6 days   \n",
       "55952                                       5 days   \n",
       "32229                                       5 days   \n",
       "78778                                       3 days   \n",
       "46791                                       2 days   \n",
       "57937                                       1 days   \n",
       "4846                                        0 days   \n",
       "43411                                       0 days   \n",
       "87479                                       0 days   \n",
       "\n",
       "                                                 Maßnahme  \n",
       "117758    Schraube ausgebohrt und Gewinde nachgeschnitten  \n",
       "66749                       Schraube von Adapter entfernt  \n",
       "119480  Eine seite neue Gewinde gebohrt und geschnitte...  \n",
       "46790   Kettbaum-Adapter schrauben  entfernt und gewin...  \n",
       "1680    Kettbaum Lagerauflage ist defekt und nicht meh...  \n",
       "43412   Zylinderschraube rausgebohrt und Gewinde nachg...  \n",
       "100461                                               N.V.  \n",
       "2774    abgbrochene Schrauben entfernt und alle Gewind...  \n",
       "122902    Schraube ausgebohrt und Gewinde nachgeschnitten  \n",
       "111241                  Neues Lager 6312 2Rs C3 eingebaut  \n",
       "83      Schraube ausgebohrt und Gewinde nach geschnitten.  \n",
       "6798    Neues Lochbild mit Schablone gebohrt, da abgeb...  \n",
       "67562                                Schraube ausgebohrt.  \n",
       "78986   Schrauben ausgebohrt und Gewinde neu geschnitten.  \n",
       "7579      Schraube ausgebohrt und gewinde nachgeschitten.  \n",
       "96080   Zylinderkopfschrauben mit Innensechskant 3 Stü...  \n",
       "55024             Schraube von Kettbaumadapter ausgebohrt  \n",
       "98277                                           erledigt.  \n",
       "57927   Zylinderkopfschrauben am Kettbaumadapter ausge...  \n",
       "1743                                                 N.V.  \n",
       "8084           Altes Lager demontiert und neues montiert.  \n",
       "2980    Schrauben ausgebohrt und alle anderen Gewinde ...  \n",
       "55952    Schrauben entfernt. alle gewinde nachgeschnitten  \n",
       "32229                                                N.V.  \n",
       "78778   Kettbaum Schraube ausgebohrt und Gewinde nach ...  \n",
       "46791   Neue Bohrlöcher angebracht, Gewinde geschnitte...  \n",
       "57937                    lager entfernt und neu eingebaut  \n",
       "4846    Schraube entfernt und alle anderen Gewinde nac...  \n",
       "43411                          TK doppelt siehe tk 67187.  \n",
       "87479   Drei Schraubenköpfe aufgebohrt und Adapter run...  "
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "potential_successful"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "cb645b89-c904-4f12-a829-30ddd9f1bbd8",
   "metadata": {},
   "outputs": [],
   "source": [
    "t_str = potential_successful.loc[55952, 'Maßnahme']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "8ad3e3da-f7ff-417f-96f6-2b2817d852c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "t_str = 'Schrauben entfernt \\nalle gewinde nachgeschnitten\\t\\n'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "e844ed05-b623-45e8-b3d5-46e94db052e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Schrauben entfernt \\nalle gewinde nachgeschnitten\\t\\n'"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t_str"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "dbd0b2e6-b01c-40c0-a0fa-67be9f5329e1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "e1568d24-56c1-4dd1-b144-339b8b58289a",
   "metadata": {},
   "outputs": [],
   "source": [
    "pattern = re.compile(r' *[\\t\\n\\r\\f\\v]+')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "bc7bf0b4-5278-43a3-a5c1-93f9d0f2322f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Schrauben entfernt. alle gewinde nachgeschnitten. '"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pattern.sub('. ', t_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "4b877452-daef-47cc-aa19-b117d301bcd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from lang_main.analysis.shared import clean_strings_dataframes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "e95e71fd-f335-4339-b587-1933b5cc5082",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\foersterflorian\\AppData\\Local\\Temp\\ipykernel_14020\\1258675024.py:1: SettingWithCopyWarning: \n",
      "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",
      "  potential_successful['Maßnahme'] = potential_successful['Maßnahme'].apply(clean_strings_dataframes)\n"
     ]
    }
   ],
   "source": [
    "potential_successful['Maßnahme'] = potential_successful['Maßnahme'].apply(clean_strings_dataframes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de68b504-d587-420d-91e3-11859ca1eb9e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.11.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
