Skip to content

Commit

Permalink
Removed graph layout option settings. (#14)
Browse files Browse the repository at this point in the history
Set engine to "sfdp" and added configurations for clearer clustering.
  • Loading branch information
traceyyoshima authored Aug 23, 2023
1 parent c5b27c9 commit 44534d5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 45 deletions.
76 changes: 39 additions & 37 deletions moderne_visualizations_misc/cobol_relationships.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "fe0ea925",
"metadata": {
"collapsed": false,
Expand All @@ -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
Expand All @@ -36,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "def9e15f-7027-4ca6-88c0-84e67ca9417b",
"metadata": {
"ExecuteTime": {
Expand All @@ -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",
Expand All @@ -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\"<<b>{value}</b><br/><i>({docType})</i>>\"\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",
Expand All @@ -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",
Expand All @@ -171,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.6"
}
},
"nbformat": 4,
Expand Down
8 changes: 0 additions & 8 deletions moderne_visualizations_misc/specs/cobol_relationships.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

0 comments on commit 44534d5

Please sign in to comment.