From 44534d57b2b47632e80266e485e95f02df0ff48a Mon Sep 17 00:00:00 2001 From: Tracey Yoshima Date: Wed, 23 Aug 2023 12:12:48 -0600 Subject: [PATCH] Removed graph layout option settings. (#14) Set engine to "sfdp" and added configurations for clearer clustering. --- .../cobol_relationships.ipynb | 76 ++++++++++--------- .../specs/cobol_relationships.yml | 8 -- 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/moderne_visualizations_misc/cobol_relationships.ipynb b/moderne_visualizations_misc/cobol_relationships.ipynb index 034b68b..4fd1cbe 100644 --- a/moderne_visualizations_misc/cobol_relationships.ipynb +++ b/moderne_visualizations_misc/cobol_relationships.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "fe0ea925", "metadata": { "collapsed": false, @@ -13,13 +13,12 @@ "outputs": [], "source": [ "node_shape: str = \"ellipse\"\n", - "filter_resources_related_to: str = \"\"\n", - "default_engine: str = \"sfdp\"" + "filter_resources_related_to: str = \"\"" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "1934da7b", "metadata": { "collapsed": false @@ -36,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "def9e15f-7027-4ca6-88c0-84e67ca9417b", "metadata": { "ExecuteTime": { @@ -47,8 +46,11 @@ "outputs": [], "source": [ "graphviz.set_jupyter_format(\"svg\")\n", - "graphviz.set_default_engine(default_engine)\n", - "dot = graphviz.Digraph(\"cobol-relationships\", comment=\"COBOL relationships\")\n", + "dot = graphviz.Digraph(\n", + " \"cobol-relationships\", comment=\"COBOL relationships\", engine=\"sfdp\"\n", + ")\n", + "\n", + "dot.graph_attr = dot.graph_attr = {\"overlap\": \"prism\", \"smoothing\": \"graph_dist\"}\n", "\n", "# clean dependent field remove all content up to first slash\n", "df[\"dependent\"] = df[\"dependent\"].apply(lambda x: re.sub(r\"^.*\\/\", \"\", x))\n", @@ -60,60 +62,60 @@ " ]\n", "\n", "\n", - "def style_node(isMissing, dependencyType):\n", - " if isMissing == \"true\":\n", + "def style_node(is_missing, dependency_type):\n", + " if is_missing == \"true\":\n", " return palette.__moderneColorMap[\"red\"][200]\n", - " if dependencyType == \"COBOL\":\n", + " if dependency_type == \"COBOL\":\n", " return palette.__moderneColorMap[\"blue\"][400]\n", - " if dependencyType == \"COPYBOOK\":\n", + " if dependency_type == \"COPYBOOK\":\n", " return palette.__moderneColorMap[\"blue\"][200]\n", - " if dependencyType == \"LINKEDIT\":\n", + " if dependency_type == \"LINKEDIT\":\n", " return palette.__moderneColorMap[\"yellow\"][200]\n", - " if dependencyType == \"BINDPACKAGE\":\n", + " if dependency_type == \"BINDPACKAGE\":\n", " return palette.__moderneColorMap[\"green\"][200]\n", - " if dependencyType == \"BINDPLAN\":\n", + " if dependency_type == \"BINDPLAN\":\n", " return palette.__moderneColorMap[\"green\"][400]\n", - " if dependencyType == \"SQL_TABLE\":\n", + " if dependency_type == \"SQL_TABLE\":\n", " return palette.__moderneColorMap[\"indigo\"][100]\n", - " if dependencyType == \"SQL_CURSOR\":\n", + " if dependency_type == \"SQL_CURSOR\":\n", " return palette.__moderneColorMap[\"indigo\"][300]\n", " return \"white\"\n", "\n", "\n", - "def addAnnotation(value, docType):\n", + "def add_annotation(value, docType):\n", " return f\"<{value}
({docType})>\"\n", "\n", "\n", "def map_relationship(row):\n", - " if isNode(row):\n", + " if is_node(row):\n", " dot.node(\n", - " makeNode(row[\"dependent\"], row[\"dependentType\"]),\n", + " make_node(row[\"dependent\"], row[\"dependentType\"]),\n", " shape=node_shape,\n", - " label=addAnnotation(row[\"dependent\"], row[\"dependentType\"]),\n", + " label=add_annotation(row[\"dependent\"], row[\"dependentType\"]),\n", " style=\"filled\",\n", " fillcolor=style_node(row[\"dependencyMissing\"], row[\"dependentType\"]),\n", " )\n", " dot.node(\n", - " makeNode(row[\"dependency\"], row[\"dependencyType\"]),\n", + " make_node(row[\"dependency\"], row[\"dependencyType\"]),\n", " shape=node_shape,\n", - " label=addAnnotation(row[\"dependency\"], row[\"dependencyType\"]),\n", + " label=add_annotation(row[\"dependency\"], row[\"dependencyType\"]),\n", " style=\"filled\",\n", " fillcolor=style_node(row[\"dependencyMissing\"], row[\"dependencyType\"]),\n", " )\n", " dot.edge(\n", - " makeNode(row[\"dependent\"], row[\"dependentType\"]),\n", - " makeNode(row[\"dependency\"], row[\"dependencyType\"]),\n", - " makeLabel(\n", + " make_node(row[\"dependent\"], row[\"dependentType\"]),\n", + " make_node(row[\"dependency\"], row[\"dependencyType\"]),\n", + " make_label(\n", " row[\"action\"], row[\"actionMetadata\"] if \"actionMetadata\" in df else None\n", " ),\n", " )\n", "\n", "\n", "# Prevent multiple redundant relationships from being created when multiple COBOL sources access the same copybook\n", - "copyChainPairs = {}\n", + "copy_chain_pairs = {}\n", "\n", "\n", - "def isNode(row):\n", + "def is_node(row):\n", " if (\n", " isinstance(row[\"dependent\"], str)\n", " and isinstance(row[\"dependentType\"], str)\n", @@ -124,27 +126,27 @@ " ):\n", " dependent = row[\"dependent\"]\n", " dependency = row[\"dependency\"]\n", - " if dependent not in copyChainPairs:\n", - " copyChainPairs[dependent] = {}\n", - " copyChainPairs[dependent][dependency] = dependency\n", + " if dependent not in copy_chain_pairs:\n", + " copy_chain_pairs[dependent] = {}\n", + " copy_chain_pairs[dependent][dependency] = dependency\n", " return True\n", - " elif dependency not in copyChainPairs[dependent]:\n", - " copyChainPairs[dependent][dependency] = dependency\n", + " elif dependency not in copy_chain_pairs[dependent]:\n", + " copy_chain_pairs[dependent][dependency] = dependency\n", " return True\n", " else:\n", " return True\n", "\n", "\n", - "def makeNode(resource, type):\n", + "def make_node(resource, type):\n", " if isinstance(resource, str) and isinstance(type, str):\n", " return resource + \" \" + type\n", " else:\n", " return resource\n", "\n", "\n", - "def makeLabel(action, actionMetadata):\n", - " if isinstance(actionMetadata, str):\n", - " return action + \" \" + f\"({actionMetadata})\"\n", + "def make_label(action, action_metadata):\n", + " if isinstance(action_metadata, str):\n", + " return action + \" \" + f\"({action_metadata})\"\n", " else:\n", " return action\n", "\n", @@ -171,7 +173,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.10.6" } }, "nbformat": 4, diff --git a/moderne_visualizations_misc/specs/cobol_relationships.yml b/moderne_visualizations_misc/specs/cobol_relationships.yml index dbb3062..8022af6 100644 --- a/moderne_visualizations_misc/specs/cobol_relationships.yml +++ b/moderne_visualizations_misc/specs/cobol_relationships.yml @@ -7,14 +7,6 @@ description: > recipe: org.openrewrite.cobol.search.FindRelationships dataTable: org.openrewrite.cobol.table.CobolRelationships options: - - default_engine: - displayName: Layout engine - description: "Various algorithms for projecting abstract graphs into a space for visualization. (default: sfdp)" - valid: - - sfdp - - dot - - circo - required: false - node_shape: displayName: Node shape description: "The shape of the nodes in the diagram. (default: ellipse)"