diff --git a/src/lang_main/cytoscape_config/template_test.cys b/src/lang_main/cytoscape_config/template_test.cys index ee1eb00..4cead42 100644 Binary files a/src/lang_main/cytoscape_config/template_test.cys and b/src/lang_main/cytoscape_config/template_test.cys differ diff --git a/src/lang_main/loggers.py b/src/lang_main/loggers.py index eecb00b..bc4a992 100644 --- a/src/lang_main/loggers.py +++ b/src/lang_main/loggers.py @@ -10,6 +10,7 @@ LOGGING_LEVEL_GRAPHS: Final[LoggingLevels] = LoggingLevels.INFO LOGGING_LEVEL_TIMELINE: Final[LoggingLevels] = LoggingLevels.DEBUG LOGGING_LEVEL_TOKEN_ANALYSIS: Final[LoggingLevels] = LoggingLevels.INFO LOGGING_LEVEL_SHARED_HELPERS: Final[LoggingLevels] = LoggingLevels.INFO +LOGGING_LEVEL_RENDERING: Final[LoggingLevels] = LoggingLevels.INFO logger_shared_helpers = logging.getLogger('lang_main.shared') logger_shared_helpers.setLevel(LOGGING_LEVEL_SHARED_HELPERS) @@ -23,3 +24,5 @@ logger_token_analysis.setLevel(LOGGING_LEVEL_TOKEN_ANALYSIS) logger_preprocess.setLevel(LOGGING_LEVEL_PREPROCESS) logger_pipelines = logging.getLogger('lang_main.pipelines') logger_pipelines.setLevel(LOGGING_LEVEL_PIPELINES) +logger_rendering = logging.getLogger('lang_main.render') +logger_rendering.setLevel(LOGGING_LEVEL_RENDERING) diff --git a/src/lang_main/pipelines/base.py b/src/lang_main/pipelines/base.py index fb17250..d05fc6b 100644 --- a/src/lang_main/pipelines/base.py +++ b/src/lang_main/pipelines/base.py @@ -295,14 +295,15 @@ class Pipeline(BasePipeline): else: args = ret - if args is not None and action_kwargs: + if args is not None: ret = action(*args, **action_kwargs) - elif args is not None: - ret = action(*args) - elif args is None and action_kwargs: - ret = action(**action_kwargs) + # elif args is not None: + # ret = action(*args) + # elif args is None and action_kwargs: + # ret = action(**action_kwargs) else: - ret = action() + # ret = action() + ret = action(**action_kwargs) if ret is not None and not isinstance(ret, tuple): ret = (ret,) diff --git a/src/lang_main/pipelines/predefined.py b/src/lang_main/pipelines/predefined.py index f2f2cbf..fc37efd 100644 --- a/src/lang_main/pipelines/predefined.py +++ b/src/lang_main/pipelines/predefined.py @@ -182,6 +182,7 @@ def build_tk_graph_rescaling_pipe() -> Pipeline: return pipe_graph_rescaling +# ** token analysis: rendering def build_tk_graph_rendering_pipe() -> Pipeline: pipe_graph_rendering = Pipeline( name='Graph_Static-Rendering', diff --git a/src/lang_main/render/cytoscape.py b/src/lang_main/render/cytoscape.py index 7560ce6..ca45ee1 100644 --- a/src/lang_main/render/cytoscape.py +++ b/src/lang_main/render/cytoscape.py @@ -5,6 +5,8 @@ from typing import cast import py4cytoscape as p4c from networkx import DiGraph, Graph +from py4cytoscape.exceptions import CyError +from requests.exceptions import RequestException from lang_main.constants import ( CYTO_BASE_NETWORK_NAME, @@ -19,6 +21,7 @@ from lang_main.constants import ( PROPERTY_NAME_DEGREE_WEIGHTED, SAVE_PATH_FOLDER, ) +from lang_main.loggers import logger_rendering as logger from lang_main.types import ( CytoExportFileTypes, CytoExportPageSizes, @@ -29,9 +32,40 @@ from lang_main.types import ( # ** Cytoscape API related, using py4cytoscape +def verify_connection(): + """Cytoscape: checks if CyREST and Cytoscape versions are compatible nad + if Cytoscape API endpoint is reachable + + Raises + ------ + CyError + incompatible CyREST or Cytoscape versions + RequestException + API endpoint not reachable + """ + try: + p4c.cytoscape_ping() + except CyError as error: + logger.error('[CyError] CyREST or Cytoscape version not supported.') + raise error + except RequestException as error: + logger.error('[CytoAPIConnection] Connection to CyREST API failed.') + raise error + + def import_to_cytoscape( graph: DiGraph | Graph, ) -> None: + """Cytoscape: import NetworkX graph as new network collection + + Parameters + ---------- + graph : DiGraph | Graph + NetworkX graph object + """ + logger.debug('Checking Cytoscape connection...') + verify_connection() + logger.debug('Importing network to Cytoscape...') p4c.delete_all_networks() p4c.create_network_from_networkx( graph, @@ -39,9 +73,11 @@ def import_to_cytoscape( collection=CYTO_COLLECTION_NAME, ) p4c.analyze_network(directed=False) + logger.debug('Importing network to Cytoscape successful.') def reset_current_network_to_base() -> None: + """resets to currently selected network in Cytoscape back to the base one""" p4c.set_current_network(CYTO_BASE_NETWORK_NAME) @@ -51,7 +87,21 @@ def export_network_to_image( network_name: str = CYTO_BASE_NETWORK_NAME, pdf_export_page_size: CytoExportPageSizes = 'A4', ) -> None: - # target_folder = Path.cwd() / 'results' + """Cytoscape: export current selected view as image + + Parameters + ---------- + filename : str + export filename + filetype : CytoExportFileTypes, optional + export filetype supported by Cytoscape, by default 'SVG' + network_name : str, optional + network to export, by default CYTO_BASE_NETWORK_NAME + pdf_export_page_size : CytoExportPageSizes, optional + page size which should be used for PDF exports supported by Cytoscape, + by default 'A4' + """ + logger.debug('Exporting image to file...') target_folder = SAVE_PATH_FOLDER if not target_folder.exists(): target_folder.mkdir(parents=True) @@ -70,6 +120,7 @@ def export_network_to_image( export_text_as_font=text_as_font, page_size=pdf_export_page_size, ) + logger.debug('Exporting image to file successful.') def layout_network( @@ -77,15 +128,52 @@ def layout_network( layout_properties: CytoLayoutProperties = CYTO_LAYOUT_PROPERTIES, network_name: str = CYTO_BASE_NETWORK_NAME, ) -> None: + """Cytoscape: apply a supported layout algorithm to currently selected + network + + Parameters + ---------- + layout_name : CytoLayouts, optional + layout algorithm supported by Cytoscape (name of the CyREST API, does not + necessarily match the name in the Cytoscape UI), + by default CYTO_LAYOUT_NAME + layout_properties : CytoLayoutProperties, optional + configuration of parameters for the given layout algorithm, by default CYTO_LAYOUT_PROPERTIES + network_name : str, optional + network to apply the layout algorithm on, by default CYTO_BASE_NETWORK_NAME + """ + logger.debug('Applying layout to network...') p4c.set_layout_properties(layout_name, layout_properties) p4c.layout_network(layout_name=layout_name, network=network_name) p4c.fit_content(selected_only=False, network=network_name) + logger.debug('Layout application to network successful.') def apply_style_to_network( + style_name: str = CYTO_STYLESHEET_NAME, pth_to_stylesheet: Path = CYTO_PATH_STYLESHEET, network_name: str = CYTO_BASE_NETWORK_NAME, ) -> None: + """Cytoscape: apply a chosen Cytoscape style to the defined network + + Parameters + ---------- + style_name : str, optional + Cytoscape name of the style which should be applied, + by default CYTO_STYLESHEET_NAME + pth_to_stylesheet : Path, optional + path where the stylesheet definition in Cytoscape's XML format can + be found, + by default CYTO_PATH_STYLESHEET + network_name : str, optional + network to apply the style on, by default CYTO_BASE_NETWORK_NAME + + Raises + ------ + FileNotFoundError + if provided stylesheet can not be found under the provided path + """ + logger.debug('Applying style to network...') styles_avail = cast(list[str], p4c.get_visual_style_names()) if CYTO_STYLESHEET_NAME not in styles_avail: if not pth_to_stylesheet.exists(): @@ -96,15 +184,36 @@ def apply_style_to_network( ) p4c.import_visual_styles(str(pth_to_stylesheet)) - p4c.set_visual_style(CYTO_STYLESHEET_NAME, network=network_name) + p4c.set_visual_style(style_name, network=network_name) time.sleep(1) # if not waited image export could be without applied style p4c.fit_content(selected_only=False, network=network_name) + logger.debug('Style application to network successful.') def get_subgraph_node_selection( network_name: str = CYTO_BASE_NETWORK_NAME, property_degree_weighted: str = PROPERTY_NAME_DEGREE_WEIGHTED, + num_subgraphs: int = CYTO_NUMBER_SUBGRAPHS, ) -> list[CytoNodeID]: + """Cytoscape: obtain the relevant nodes for iterative subgraph generation + + Parameters + ---------- + network_name : str, optional + network to retrieve the nodes from, by default CYTO_BASE_NETWORK_NAME + property_degree_weighted : str, optional + property name which contains the weighted degree, + by default PROPERTY_NAME_DEGREE_WEIGHTED + num_subgraphs : int, optional + number of relevant nodes which form the basis to generate subgraphs from, + by default CYTO_NUMBER_SUBGRAPHS + + Returns + ------- + list[CytoNodeID] + list containing all relevant Cytoscape nodes + """ + logger.debug('Selecting nodes for subgraph generation...') node_table = p4c.get_table_columns(network=network_name) node_table['stress_norm'] = node_table['Stress'] / node_table['Stress'].max() node_table[CYTO_SELECTION_PROPERTY] = ( @@ -113,22 +222,42 @@ def get_subgraph_node_selection( * node_table['stress_norm'] ) node_table = node_table.sort_values(by=CYTO_SELECTION_PROPERTY, ascending=False) - node_table_choice = node_table.iloc[:CYTO_NUMBER_SUBGRAPHS, :] + node_table_choice = node_table.iloc[:num_subgraphs, :] + logger.debug('Selection of nodes for subgraph generation successful.') return node_table_choice['SUID'].to_list() def select_neighbours_of_node( node: CytoNodeID, + neighbour_iter_depth: int = CYTO_ITER_NEIGHBOUR_DEPTH, network_name: str = CYTO_BASE_NETWORK_NAME, ) -> None: + """Cytoscape: iterative selection of a node's neighbouring nodes and + their connecting edges + + Parameters + ---------- + node : CytoNodeID + node which neighbours should be selected + neighbour_iter_depth : int, optional + indicates how many levels of neighbours should be choosen, e.g. 1 --> only + first-level neighbours are considered which are directly connected to the node, + 2 --> all nodes with iteration depth of 1 are chosen and additionally their + direct neighbours, + by default CYTO_ITER_NEIGHBOUR_DEPTH + network_name : str, optional + network to perform action on, by default CYTO_BASE_NETWORK_NAME + """ + logger.debug('Selecting node neighbours for %s...', node) p4c.clear_selection(network=network_name) p4c.select_nodes(node, network=network_name) - for _ in range(CYTO_ITER_NEIGHBOUR_DEPTH): + for _ in range(neighbour_iter_depth): _ = p4c.select_first_neighbors(network=network_name) _ = p4c.select_edges_connecting_selected_nodes() + logger.debug('Selection of node neighbours for %s successful.', node) def make_subnetwork( @@ -136,6 +265,19 @@ def make_subnetwork( network_name: str = CYTO_BASE_NETWORK_NAME, export_image: bool = True, ) -> None: + """Cytoscape: generate a new subnetwork based on the currently + selected nodes and edges + + Parameters + ---------- + index : int + id-like property to identify the subnetwork relative to its parent + network_name : str, optional + network to generate subnetwork from, by default CYTO_BASE_NETWORK_NAME + export_image : bool, optional + trigger image export of newly generated subnetwork, by default True + """ + logger.debug('Generating subnetwork with index %d...', index) subnetwork_name = network_name + f'_sub_{index+1}' p4c.create_subnetwork( nodes='selected', @@ -146,14 +288,33 @@ def make_subnetwork( p4c.set_current_network(subnetwork_name) p4c.fit_content(selected_only=False, network=subnetwork_name) if export_image: + time.sleep(1) export_network_to_image(filename=subnetwork_name, network_name=subnetwork_name) + logger.debug('Generation of subnetwork with index %d successful.', index) + def build_subnetworks( nodes_to_analyse: Iterable[CytoNodeID], network_name: str = CYTO_BASE_NETWORK_NAME, export_image: bool = True, ) -> None: + """Cytoscape: iteratively build subnetworks from a collection of nodes + and their respective neighbouring nodes + + Parameters + ---------- + nodes_to_analyse : Iterable[CytoNodeID] + collection of nodes to make subnetworks from, for each node a dedicated + subnetwork will be generated + network_name : str, optional + network which contains the provided nodes, + by default CYTO_BASE_NETWORK_NAME + export_image : bool, optional + trigger image export of newly generated subnetworks, by default True + """ + logger.debug('Generating all subnetworks for node selection...') for idx, node in enumerate(nodes_to_analyse): select_neighbours_of_node(node=node, network_name=network_name) make_subnetwork(index=idx, network_name=network_name, export_image=export_image) + logger.debug('Generation of all subnetworks for node selection successful.') diff --git a/test-notebooks/misc.ipynb b/test-notebooks/misc.ipynb index a1a04ad..b9b554b 100644 --- a/test-notebooks/misc.ipynb +++ b/test-notebooks/misc.ipynb @@ -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,