verify Cyto API conn, add docs

This commit is contained in:
Florian Förster
2024-07-19 10:31:17 +02:00
parent d2165afbfd
commit 578c543a3e
6 changed files with 255 additions and 398 deletions

View File

@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "af118d77-d87a-4687-be5b-e810a24c403e",
"metadata": {},
"outputs": [
@@ -21,7 +21,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2024-07-17 16:02:39 +0000 | io:INFO | Loaded TOML config file successfully.\n"
"2024-07-19 05:54:50 +0000 | io:INFO | Loaded TOML config file successfully.\n"
]
},
{
@@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "4256081a-6364-4e8f-8cfd-799912ca6b94",
"metadata": {},
"outputs": [],
@@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"id": "e9a92ad6-5e63-49c4-b9e7-9f81da8549fe",
"metadata": {},
"outputs": [],
@@ -90,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"id": "c2421d89-ed8c-41dd-b363-ad5b5b716704",
"metadata": {},
"outputs": [
@@ -98,7 +98,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2024-07-17 16:02:46 +0000 | io:INFO | Loaded file successfully.\n"
"2024-07-19 05:54:58 +0000 | io:INFO | Loaded file successfully.\n"
]
}
],
@@ -167,7 +167,7 @@
{
"data": {
"text/plain": [
"{}"
"{'degree_weighted': 186350}"
]
},
"execution_count": 9,
@@ -181,15 +181,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "8d36d22e-73fd-44fe-ab08-98f8186bc6b2",
"metadata": {},
"outputs": [],
"source": []
"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": 10,
"execution_count": 11,
"id": "1e61aca3-efea-4e38-8174-5ca4b2585256",
"metadata": {},
"outputs": [],
@@ -202,7 +215,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"id": "5d83c04c-03ab-4086-a4e9-ae430e4c6090",
"metadata": {},
"outputs": [
@@ -210,7 +223,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2024-07-17 06:04:17 +0000 | io:INFO | Loaded file successfully.\n"
"2024-07-19 05:56:10 +0000 | io:INFO | Loaded file successfully.\n"
]
}
],
@@ -220,7 +233,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"id": "4718b54e-0891-4f70-8c67-90c439bc8bfd",
"metadata": {},
"outputs": [],
@@ -230,7 +243,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 14,
"id": "ddcb4ff0-eac4-45ba-9c6e-83ada4b0276c",
"metadata": {},
"outputs": [
@@ -240,7 +253,7 @@
"TokenGraph(name: TokenGraph, number of nodes: 6859, number of edges: 25499)"
]
},
"execution_count": 13,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@@ -251,17 +264,28 @@
},
{
"cell_type": "code",
"execution_count": 25,
"id": "97c46ca7-ca9f-4d11-8d86-cfbd819b7573",
"execution_count": 15,
"id": "3d514552-3b55-41d1-af80-a1b559711608",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tkg.rescaled_weights = False"
"tkg.rescaled_weights"
]
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 16,
"id": "b73844e0-4242-4a8c-b552-48f10df34cc0",
"metadata": {},
"outputs": [],
@@ -271,23 +295,23 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 17,
"id": "593b9f87-4e9f-45e4-9367-55347924357b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'num_nodes': 6028,\n",
" 'num_edges': 17950,\n",
"{'num_nodes': 6859,\n",
" 'num_edges': 25499,\n",
" 'min_edge_weight': 0.0952,\n",
" 'max_edge_weight': 1.0,\n",
" 'node_memory': 382321,\n",
" 'edge_memory': 1005200,\n",
" 'total_memory': 1387521}"
" 'node_memory': 433996,\n",
" 'edge_memory': 1427944,\n",
" 'total_memory': 1861940}"
]
},
"execution_count": 28,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -298,23 +322,23 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 18,
"id": "aed4354a-69e4-4215-bd4b-a6c7c37c3ac5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'num_nodes': 6028,\n",
" 'num_edges': 17554,\n",
" 'min_edge_weight': 0.09520000219345093,\n",
" 'max_edge_weight': 1.7527999877929688,\n",
" 'node_memory': 382321,\n",
" 'edge_memory': 983024,\n",
" 'total_memory': 1365345}"
"{'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": 29,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@@ -325,23 +349,23 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 19,
"id": "587de2ae-26ed-42f5-a8bd-104f9cbf1490",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'num_nodes': 6028,\n",
" 'num_edges': 17554,\n",
"{'num_nodes': 6859,\n",
" 'num_edges': 24796,\n",
" 'min_edge_weight': 0.0952,\n",
" 'max_edge_weight': 1.0,\n",
" 'node_memory': 382321,\n",
" 'edge_memory': 983024,\n",
" 'total_memory': 1365345}"
" 'node_memory': 433996,\n",
" 'edge_memory': 1388576,\n",
" 'total_memory': 1822572}"
]
},
"execution_count": 30,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@@ -350,16 +374,6 @@
"get_graph_metadata(undirected)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "f6fc2c6a-2171-411d-92f1-4ab694adda7b",
"metadata": {},
"outputs": [],
"source": [
"Gtest = rescale_edge_weights(tkg)"
]
},
{
"cell_type": "markdown",
"id": "859be6a3-a919-433a-a0a7-f4d74cdc6bf7",
@@ -377,7 +391,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 20,
"id": "f381b25a-6149-4a2a-876c-4cbd8bb9bd04",
"metadata": {},
"outputs": [
@@ -401,7 +415,7 @@
"source": [
"break_early = True\n",
"i = 0\n",
"for n1, n2, w in Gtest.edges.data('weight'):\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",
@@ -411,38 +425,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"id": "c45a8136-2a81-4ede-a087-cf86ce85d939",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'TokenGraph' object has no attribute 'rescaled_weights'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[14], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mGtest\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_undirected\u001b[49m\u001b[43m(\u001b[49m\u001b[43minplace\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
"File \u001b[1;32mA:\\Arbeitsaufgaben\\lang-main\\src\\lang_main\\analysis\\graphs.py:481\u001b[0m, in \u001b[0;36mTokenGraph.to_undirected\u001b[1;34m(self, inplace, logging)\u001b[0m\n\u001b[0;32m 479\u001b[0m \u001b[38;5;66;03m# cast to integer edge weights only if edges were not rescaled previously\u001b[39;00m\n\u001b[0;32m 480\u001b[0m cast_int: \u001b[38;5;28mbool\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m--> 481\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrescaled_weights\u001b[49m:\n\u001b[0;32m 482\u001b[0m cast_int \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[0;32m 484\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_undirected \u001b[38;5;241m=\u001b[39m convert_graph_to_undirected(\n\u001b[0;32m 485\u001b[0m graph\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 486\u001b[0m logging\u001b[38;5;241m=\u001b[39mlogging,\n\u001b[0;32m 487\u001b[0m cast_int\u001b[38;5;241m=\u001b[39mcast_int,\n\u001b[0;32m 488\u001b[0m )\n",
"\u001b[1;31mAttributeError\u001b[0m: 'TokenGraph' object has no attribute 'rescaled_weights'"
]
}
],
"source": [
"Gtest.to_undirected(inplace=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "303d8d0c-9320-4739-adf6-ac9ba82731de",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 21,
"id": "a7929935-3bd2-4eb8-907c-4d37251f11ea",
"metadata": {},
"outputs": [
@@ -452,21 +435,21 @@
"text": [
"Wartungstätigkeit Vorgabe 1.0\n",
"Wartungstätigkeit Maschinenhersteller 1.0\n",
"Wartungstätigkeit sehen 0.2533999979496002\n",
"Wartungstätigkeit Maschinenbediener 0.8215000033378601\n",
"Wartungstätigkeit Laserabteilung 0.8215000033378601\n",
"Wartungstätigkeit Arbeitsplan 0.8219000101089478\n",
"Wartungstätigkeit abarbeiten 0.8215000033378601\n",
"Wartungstätigkeit Webmaschinenkontrollliste 0.2533999979496002\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.9180999994277954\n"
"Vorgabe Wartungsplan 0.9181\n"
]
}
],
"source": [
"break_early = True\n",
"i = 0\n",
"for n1, n2, w in Gtest.undirected.edges.data('weight'):\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",
@@ -474,298 +457,6 @@
" i += 1"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "4df89d59-3832-4b6d-9eae-b3220b6f7e5b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'num_nodes': 6028,\n",
" 'num_edges': 17554,\n",
" 'min_edge_weight': 0.09520000219345093,\n",
" 'max_edge_weight': 1.7527999877929688,\n",
" 'node_memory': 382321,\n",
" 'edge_memory': 983024,\n",
" 'total_memory': 1365345}"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Gtest.metadata_undirected"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11b9a5b4-8319-44e8-b0eb-0434f952a28e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 23,
"id": "c63770ed-5748-4484-816f-22d0e327af73",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'weight' not in Gtest['Wartungstätigkeit']['Vorgabe']"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "62e5d9f4-69c8-4990-9a64-6e2f40031d6f",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "ca7c4578-c9bb-4b0b-b261-e0208d6cb970",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"id": "adf02de4-f22c-499f-91bf-ac1be1b3186f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'num_nodes': 6028,\n",
" 'num_edges': 17950,\n",
" 'min_edge_weight': 0.0952,\n",
" 'max_edge_weight': 1.0,\n",
" 'node_memory': 382321,\n",
" 'edge_memory': 1005200,\n",
" 'total_memory': 1387521}"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Gtest.metadata_directed"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9e939c9c-ba9e-4576-9d85-afba8481af93",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 21,
"id": "bfafdc8b-418d-4dd8-b986-d36082ba870e",
"metadata": {},
"outputs": [],
"source": [
"c_comps = nx.connected_components(Gtest.undirected)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "abf5603d-dab9-49a0-8c86-d2429a36d24d",
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
},
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5714\n",
"2\n",
"2\n",
"2\n",
"3\n",
"4\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"3\n",
"4\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"3\n",
"2\n",
"2\n",
"4\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"4\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"4\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n",
"3\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"3\n",
"2\n",
"2\n",
"2\n"
]
}
],
"source": [
"for comp in c_comps:\n",
" print(len(comp))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "80db8d16-fa48-417d-91b0-37e5b32f3b74",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,