master
Michael Murtaugh 4 years ago
parent fff78b8e72
commit 0ece0ee4e8

@ -1,13 +1,36 @@
{ {
"cells": [ "cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tales to tell\n",
"\n",
"module: [graphviz](https://graphviz.readthedocs.io/en/stable/)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"https://pygraphviz.github.io/documentation/pygraphviz-1.6/"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"from graphviz import Digraph"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from graphviz import Digraph\n",
"# Create Digraph object\n",
"dot = Digraph()" "dot = Digraph()"
] ]
}, },
@ -78,6 +101,607 @@
"dot" "dot"
] ]
}, },
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"text = \"\"\"I have a tale to tell\n",
"Sometimes it gets so hard to hide it well\n",
"I was not ready for the fall\n",
"Too blind to see the writing on the wall\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I\n",
"have\n",
"a\n",
"tale\n",
"to\n",
"tell\n",
"Sometimes\n",
"it\n",
"gets\n",
"so\n",
"hard\n",
"to\n",
"hide\n",
"it\n",
"well\n",
"I\n",
"was\n",
"not\n",
"ready\n",
"for\n",
"the\n",
"fall\n",
"Too\n",
"blind\n",
"to\n",
"see\n",
"the\n",
"writing\n",
"on\n",
"the\n",
"wall\n"
]
}
],
"source": [
"for word in text.split():\n",
" print (word)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"https://docs.python.org/3/library/itertools.html#recipes"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from itertools import tee\n",
"def pairwise(iterable):\n",
" \"s -> (s0,s1), (s1,s2), (s2, s3), ...\"\n",
" a, b = tee(iterable)\n",
" next(b, None)\n",
" return zip(a, b)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I have\n",
"have a\n",
"a tale\n",
"tale to\n",
"to tell\n",
"tell Sometimes\n",
"Sometimes it\n",
"it gets\n",
"gets so\n",
"so hard\n",
"hard to\n",
"to hide\n",
"hide it\n",
"it well\n",
"well I\n",
"I was\n",
"was not\n",
"not ready\n",
"ready for\n",
"for the\n",
"the fall\n",
"fall Too\n",
"Too blind\n",
"blind to\n",
"to see\n",
"see the\n",
"the writing\n",
"writing on\n",
"on the\n",
"the wall\n"
]
}
],
"source": [
"for w1, w2 in pairwise(text.split()):\n",
" print (w1, w2)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"for w1, w2 in pairwise(text.split()):\n",
" dot.edge(w1, w2)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<!-- Generated by graphviz version 2.40.1 (20161225.0304)\n",
" -->\n",
"<!-- Title: %3 Pages: 1 -->\n",
"<svg width=\"603pt\" height=\"764pt\"\n",
" viewBox=\"0.00 0.00 603.00 764.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 760)\">\n",
"<title>%3</title>\n",
"<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"-4,4 -4,-760 599,-760 599,4 -4,4\"/>\n",
"<!-- I -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>I</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"298\" cy=\"-738\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"298\" y=\"-734.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">I</text>\n",
"</g>\n",
"<!-- have -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>have</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"220\" cy=\"-666\" rx=\"32.4942\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"220\" y=\"-662.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">have</text>\n",
"</g>\n",
"<!-- I&#45;&gt;have -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>I&#45;&gt;have</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M281.8383,-723.0816C271.0767,-713.1477 256.7328,-699.9072 244.5692,-688.6793\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"246.6724,-685.8575 236.9504,-681.6465 241.9244,-691.0012 246.6724,-685.8575\"/>\n",
"</g>\n",
"<!-- was -->\n",
"<g id=\"node14\" class=\"node\">\n",
"<title>was</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"359\" cy=\"-666\" rx=\"28.6953\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"359\" y=\"-662.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">was</text>\n",
"</g>\n",
"<!-- I&#45;&gt;was -->\n",
"<g id=\"edge16\" class=\"edge\">\n",
"<title>I&#45;&gt;was</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M311.5379,-722.0209C319.5933,-712.5128 329.9633,-700.2728 338.9544,-689.6604\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"341.7062,-691.8268 345.5,-681.9345 336.3653,-687.3019 341.7062,-691.8268\"/>\n",
"</g>\n",
"<!-- a -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>a</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"185\" cy=\"-594\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"185\" y=\"-590.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">a</text>\n",
"</g>\n",
"<!-- have&#45;&gt;a -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
"<title>have&#45;&gt;a</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M211.5275,-648.5708C207.4003,-640.0807 202.3507,-629.6929 197.7689,-620.2674\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"200.9143,-618.7322 193.3945,-611.2687 194.6187,-621.7926 200.9143,-618.7322\"/>\n",
"</g>\n",
"<!-- tale -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>tale</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"115\" cy=\"-522\" rx=\"28.6953\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"115\" y=\"-518.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">tale</text>\n",
"</g>\n",
"<!-- a&#45;&gt;tale -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>a&#45;&gt;tale</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M170.1548,-578.7307C160.6334,-568.9372 148.0931,-556.0387 137.3763,-545.0156\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"139.788,-542.4753 130.3077,-537.7451 134.769,-547.3548 139.788,-542.4753\"/>\n",
"</g>\n",
"<!-- to -->\n",
"<g id=\"node5\" class=\"node\">\n",
"<title>to</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"108\" cy=\"-450\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"108\" y=\"-446.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">to</text>\n",
"</g>\n",
"<!-- tale&#45;&gt;to -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>tale&#45;&gt;to</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M113.2336,-503.8314C112.485,-496.131 111.5947,-486.9743 110.7627,-478.4166\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"114.2415,-478.0276 109.7902,-468.4133 107.2744,-478.7051 114.2415,-478.0276\"/>\n",
"</g>\n",
"<!-- tell -->\n",
"<g id=\"node6\" class=\"node\">\n",
"<title>tell</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"157\" cy=\"-378\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"157\" y=\"-374.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">tell</text>\n",
"</g>\n",
"<!-- to&#45;&gt;tell -->\n",
"<g id=\"edge5\" class=\"edge\">\n",
"<title>to&#45;&gt;tell</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M119.3647,-433.3008C125.4873,-424.3043 133.1637,-413.0247 139.9841,-403.0029\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"142.9641,-404.845 145.6969,-394.6087 137.1771,-400.9066 142.9641,-404.845\"/>\n",
"</g>\n",
"<!-- hide -->\n",
"<g id=\"node12\" class=\"node\">\n",
"<title>hide</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"97\" cy=\"-306\" rx=\"30.5947\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"97\" y=\"-302.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">hide</text>\n",
"</g>\n",
"<!-- to&#45;&gt;hide -->\n",
"<g id=\"edge12\" class=\"edge\">\n",
"<title>to&#45;&gt;hide</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M106.6068,-431.7623C104.7306,-407.201 101.3731,-363.2474 99.1659,-334.3541\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"102.6334,-333.794 98.3818,-324.0896 95.6538,-334.3272 102.6334,-333.794\"/>\n",
"</g>\n",
"<!-- see -->\n",
"<g id=\"node22\" class=\"node\">\n",
"<title>see</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"238\" cy=\"-378\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"238\" y=\"-374.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">see</text>\n",
"</g>\n",
"<!-- to&#45;&gt;see -->\n",
"<g id=\"edge25\" class=\"edge\">\n",
"<title>to&#45;&gt;see</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M128.8867,-438.432C150.398,-426.518 184.114,-407.8446 208.3749,-394.4077\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"210.1129,-397.4462 217.1651,-389.5393 206.7214,-391.3226 210.1129,-397.4462\"/>\n",
"</g>\n",
"<!-- Sometimes -->\n",
"<g id=\"node7\" class=\"node\">\n",
"<title>Sometimes</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"208\" cy=\"-306\" rx=\"62.2891\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"208\" y=\"-302.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">Sometimes</text>\n",
"</g>\n",
"<!-- tell&#45;&gt;Sometimes -->\n",
"<g id=\"edge6\" class=\"edge\">\n",
"<title>tell&#45;&gt;Sometimes</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M168.5727,-361.6621C174.7554,-352.9336 182.5138,-341.9805 189.5092,-332.1047\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"192.4773,-333.9695 195.4014,-323.7862 186.7651,-329.9234 192.4773,-333.9695\"/>\n",
"</g>\n",
"<!-- it -->\n",
"<g id=\"node8\" class=\"node\">\n",
"<title>it</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"204\" cy=\"-234\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"204\" y=\"-230.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">it</text>\n",
"</g>\n",
"<!-- Sometimes&#45;&gt;it -->\n",
"<g id=\"edge7\" class=\"edge\">\n",
"<title>Sometimes&#45;&gt;it</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M206.9906,-287.8314C206.5628,-280.131 206.0541,-270.9743 205.5787,-262.4166\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"209.0724,-262.2037 205.023,-252.4133 202.0831,-262.592 209.0724,-262.2037\"/>\n",
"</g>\n",
"<!-- gets -->\n",
"<g id=\"node9\" class=\"node\">\n",
"<title>gets</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"194\" cy=\"-162\" rx=\"30.5947\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"194\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">gets</text>\n",
"</g>\n",
"<!-- it&#45;&gt;gets -->\n",
"<g id=\"edge8\" class=\"edge\">\n",
"<title>it&#45;&gt;gets</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M201.4766,-215.8314C200.4071,-208.131 199.1353,-198.9743 197.9468,-190.4166\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"201.3999,-189.8367 196.5574,-180.4133 194.4664,-190.7997 201.3999,-189.8367\"/>\n",
"</g>\n",
"<!-- well -->\n",
"<g id=\"node13\" class=\"node\">\n",
"<title>well</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"287\" cy=\"-162\" rx=\"29.795\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"287\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">well</text>\n",
"</g>\n",
"<!-- it&#45;&gt;well -->\n",
"<g id=\"edge14\" class=\"edge\">\n",
"<title>it&#45;&gt;well</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M220.7963,-219.4297C232.6429,-209.1531 248.7123,-195.2134 262.0525,-183.6412\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"264.6834,-185.9924 269.9438,-176.7957 260.0964,-180.7047 264.6834,-185.9924\"/>\n",
"</g>\n",
"<!-- so -->\n",
"<g id=\"node10\" class=\"node\">\n",
"<title>so</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"186\" cy=\"-90\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"186\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">so</text>\n",
"</g>\n",
"<!-- gets&#45;&gt;so -->\n",
"<g id=\"edge9\" class=\"edge\">\n",
"<title>gets&#45;&gt;so</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M191.9813,-143.8314C191.1257,-136.131 190.1083,-126.9743 189.1574,-118.4166\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"192.6289,-117.9656 188.0459,-108.4133 185.6717,-118.7386 192.6289,-117.9656\"/>\n",
"</g>\n",
"<!-- hard -->\n",
"<g id=\"node11\" class=\"node\">\n",
"<title>hard</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"101\" cy=\"-18\" rx=\"32.4942\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"101\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">hard</text>\n",
"</g>\n",
"<!-- so&#45;&gt;hard -->\n",
"<g id=\"edge10\" class=\"edge\">\n",
"<title>so&#45;&gt;hard</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M169.2067,-75.7751C157.0734,-65.4975 140.4625,-51.4271 126.6713,-39.7451\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"128.8249,-36.9824 118.9322,-33.1896 124.3004,-42.3238 128.8249,-36.9824\"/>\n",
"</g>\n",
"<!-- hard&#45;&gt;to -->\n",
"<g id=\"edge11\" class=\"edge\">\n",
"<title>hard&#45;&gt;to</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M78.4193,-31.3041C63.7176,-40.9698 45.0932,-55.2578 33,-72 8.0535,-106.5367 0,-119.3959 0,-162 0,-306 0,-306 0,-306 0,-359.7872 48.8205,-406.3418 80.8135,-431.0753\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"78.8409,-433.9709 88.9404,-437.1728 83.042,-428.3716 78.8409,-433.9709\"/>\n",
"</g>\n",
"<!-- hide&#45;&gt;it -->\n",
"<g id=\"edge13\" class=\"edge\">\n",
"<title>hide&#45;&gt;it</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M117.1259,-292.4574C133.8494,-281.2041 157.8169,-265.0765 176.3429,-252.6104\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"178.3425,-255.4835 184.6851,-246.997 174.4345,-249.6759 178.3425,-255.4835\"/>\n",
"</g>\n",
"<!-- well&#45;&gt;I -->\n",
"<g id=\"edge15\" class=\"edge\">\n",
"<title>well&#45;&gt;I</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M288.5527,-180.1898C291.5849,-217.3334 298,-304.5925 298,-378 298,-594 298,-594 298,-594 298,-634.124 298,-680.5369 298,-709.5823\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"294.5001,-709.8146 298,-719.8146 301.5001,-709.8147 294.5001,-709.8146\"/>\n",
"</g>\n",
"<!-- not -->\n",
"<g id=\"node15\" class=\"node\">\n",
"<title>not</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"366\" cy=\"-594\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"366\" y=\"-590.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">not</text>\n",
"</g>\n",
"<!-- was&#45;&gt;not -->\n",
"<g id=\"edge17\" class=\"edge\">\n",
"<title>was&#45;&gt;not</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M360.7664,-647.8314C361.515,-640.131 362.4053,-630.9743 363.2373,-622.4166\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"366.7256,-622.7051 364.2098,-612.4133 359.7585,-622.0276 366.7256,-622.7051\"/>\n",
"</g>\n",
"<!-- ready -->\n",
"<g id=\"node16\" class=\"node\">\n",
"<title>ready</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"373\" cy=\"-522\" rx=\"37.0935\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"373\" y=\"-518.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">ready</text>\n",
"</g>\n",
"<!-- not&#45;&gt;ready -->\n",
"<g id=\"edge18\" class=\"edge\">\n",
"<title>not&#45;&gt;ready</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M367.7664,-575.8314C368.515,-568.131 369.4053,-558.9743 370.2373,-550.4166\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"373.7256,-550.7051 371.2098,-540.4133 366.7585,-550.0276 373.7256,-550.7051\"/>\n",
"</g>\n",
"<!-- for -->\n",
"<g id=\"node17\" class=\"node\">\n",
"<title>for</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"376\" cy=\"-450\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"376\" y=\"-446.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">for</text>\n",
"</g>\n",
"<!-- ready&#45;&gt;for -->\n",
"<g id=\"edge19\" class=\"edge\">\n",
"<title>ready&#45;&gt;for</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M373.757,-503.8314C374.0779,-496.131 374.4594,-486.9743 374.816,-478.4166\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"378.3133,-478.5503 375.2328,-468.4133 371.3194,-478.2589 378.3133,-478.5503\"/>\n",
"</g>\n",
"<!-- the -->\n",
"<g id=\"node18\" class=\"node\">\n",
"<title>the</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"400\" cy=\"-306\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"400\" y=\"-302.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">the</text>\n",
"</g>\n",
"<!-- for&#45;&gt;the -->\n",
"<g id=\"edge20\" class=\"edge\">\n",
"<title>for&#45;&gt;the</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M378.9911,-432.0535C383.0871,-407.4774 390.4832,-363.1008 395.3171,-334.0974\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"398.7795,-334.6121 396.9712,-324.1727 391.8748,-333.4612 398.7795,-334.6121\"/>\n",
"</g>\n",
"<!-- fall -->\n",
"<g id=\"node19\" class=\"node\">\n",
"<title>fall</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"568\" cy=\"-234\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"568\" y=\"-230.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">fall</text>\n",
"</g>\n",
"<!-- the&#45;&gt;fall -->\n",
"<g id=\"edge21\" class=\"edge\">\n",
"<title>the&#45;&gt;fall</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M423.5947,-296.9677C450.1808,-286.6473 494.5713,-268.9839 532,-252 533.7658,-251.1987 535.5718,-250.3597 537.3885,-249.5004\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"538.9549,-252.6307 546.4251,-245.1176 535.9001,-246.3324 538.9549,-252.6307\"/>\n",
"</g>\n",
"<!-- writing -->\n",
"<g id=\"node23\" class=\"node\">\n",
"<title>writing</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"479\" cy=\"-234\" rx=\"44.393\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"479\" y=\"-230.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">writing</text>\n",
"</g>\n",
"<!-- the&#45;&gt;writing -->\n",
"<g id=\"edge27\" class=\"edge\">\n",
"<title>the&#45;&gt;writing</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M415.9868,-291.4297C426.6384,-281.722 440.8765,-268.7455 453.1235,-257.5837\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"455.7929,-259.8863 460.8262,-250.5634 451.0777,-254.7127 455.7929,-259.8863\"/>\n",
"</g>\n",
"<!-- wall -->\n",
"<g id=\"node25\" class=\"node\">\n",
"<title>wall</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"349\" cy=\"-234\" rx=\"29.795\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"349\" y=\"-230.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">wall</text>\n",
"</g>\n",
"<!-- the&#45;&gt;wall -->\n",
"<g id=\"edge30\" class=\"edge\">\n",
"<title>the&#45;&gt;wall</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M388.4273,-289.6621C382.0628,-280.6768 374.0285,-269.3343 366.8756,-259.2362\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"369.5171,-256.9101 360.8808,-250.7729 363.8049,-260.9562 369.5171,-256.9101\"/>\n",
"</g>\n",
"<!-- Too -->\n",
"<g id=\"node20\" class=\"node\">\n",
"<title>Too</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"545\" cy=\"-162\" rx=\"27.0966\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"545\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">Too</text>\n",
"</g>\n",
"<!-- fall&#45;&gt;Too -->\n",
"<g id=\"edge22\" class=\"edge\">\n",
"<title>fall&#45;&gt;Too</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M562.3146,-216.2022C559.7437,-208.1541 556.6466,-198.4588 553.7868,-189.5067\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"557.0768,-188.3033 550.6997,-179.8425 550.4087,-190.4334 557.0768,-188.3033\"/>\n",
"</g>\n",
"<!-- blind -->\n",
"<g id=\"node21\" class=\"node\">\n",
"<title>blind</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"76\" cy=\"-90\" rx=\"34.394\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"76\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">blind</text>\n",
"</g>\n",
"<!-- Too&#45;&gt;blind -->\n",
"<g id=\"edge23\" class=\"edge\">\n",
"<title>Too&#45;&gt;blind</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M519.1989,-155.454C503.5925,-151.6799 483.2478,-147.0864 465,-144 326.062,-120.5002 288.7296,-132.7004 150,-108 139.149,-106.068 127.5185,-103.4857 116.7666,-100.8814\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"117.3305,-97.4151 106.7814,-98.3983 115.6411,-104.2082 117.3305,-97.4151\"/>\n",
"</g>\n",
"<!-- blind&#45;&gt;to -->\n",
"<g id=\"edge24\" class=\"edge\">\n",
"<title>blind&#45;&gt;to</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M68.1264,-107.7865C56.9959,-134.5941 38,-187.201 38,-234 38,-306 38,-306 38,-306 38,-352.1522 67.4441,-399.0102 88.1397,-426.2454\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"85.5826,-428.6569 94.5033,-434.3728 91.0941,-424.3414 85.5826,-428.6569\"/>\n",
"</g>\n",
"<!-- see&#45;&gt;the -->\n",
"<g id=\"edge26\" class=\"edge\">\n",
"<title>see&#45;&gt;the</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M260.5254,-367.9887C288.4956,-355.5575 336.3843,-334.2736 368.1162,-320.1706\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"369.6887,-323.3019 377.4054,-316.0421 366.8457,-316.9052 369.6887,-323.3019\"/>\n",
"</g>\n",
"<!-- on -->\n",
"<g id=\"node24\" class=\"node\">\n",
"<title>on</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"429\" cy=\"-162\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"429\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">on</text>\n",
"</g>\n",
"<!-- writing&#45;&gt;on -->\n",
"<g id=\"edge28\" class=\"edge\">\n",
"<title>writing&#45;&gt;on</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M466.8964,-216.5708C460.7891,-207.7763 453.2678,-196.9457 446.54,-187.2577\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"449.2267,-184.9902 440.6479,-178.7729 443.4771,-188.983 449.2267,-184.9902\"/>\n",
"</g>\n",
"<!-- on&#45;&gt;the -->\n",
"<g id=\"edge29\" class=\"edge\">\n",
"<title>on&#45;&gt;the</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M425.3402,-180.1727C420.3665,-204.8697 411.4269,-249.2595 405.605,-278.1684\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"402.1575,-277.5593 403.6142,-288.0535 409.0197,-278.9413 402.1575,-277.5593\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<graphviz.dot.Digraph at 0x7f8dfa48b748>"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dot"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'tale.pdf'"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dot.render(\"tale\")"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[0;31mSignature:\u001b[0m\n",
"\u001b[0mdot\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mfilename\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mdirectory\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mview\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mcleanup\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mformat\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mrenderer\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mformatter\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mquiet\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mquiet_view\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m\n",
"Save the source to file and render with the Graphviz engine.\n",
"\n",
"Args:\n",
" filename: Filename for saving the source (defaults to ``name`` + ``'.gv'``)\n",
" directory: (Sub)directory for source saving and rendering.\n",
" view (bool): Open the rendered result with the default application.\n",
" cleanup (bool): Delete the source file after rendering.\n",
" format: The output format used for rendering (``'pdf'``, ``'png'``, etc.).\n",
" renderer: The output renderer used for rendering (``'cairo'``, ``'gd'``, ...).\n",
" formatter: The output formatter used for rendering (``'cairo'``, ``'gd'``, ...).\n",
" quiet (bool): Suppress ``stderr`` output from the layout subprocess.\n",
" quiet_view (bool): Suppress ``stderr`` output from the viewer process\n",
" (implies ``view=True``, ineffective on Windows).\n",
"Returns:\n",
" The (possibly relative) path of the rendered file.\n",
"Raises:\n",
" ValueError: If ``format``, ``renderer``, or ``formatter`` are not known.\n",
" graphviz.RequiredArgumentError: If ``formatter`` is given but ``renderer`` is None.\n",
" graphviz.ExecutableNotFound: If the Graphviz executable is not found.\n",
" subprocess.CalledProcessError: If the exit status is non-zero.\n",
" RuntimeError: If viewer opening is requested but not supported.\n",
"\n",
"The layout command is started from the directory of ``filepath``, so that\n",
"references to external files (e.g. ``[image=...]``) can be given as paths\n",
"relative to the DOT source file.\n",
"\u001b[0;31mFile:\u001b[0m /opt/tljh/user/lib/python3.7/site-packages/graphviz/files.py\n",
"\u001b[0;31mType:\u001b[0m method\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"dot.render?"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"# Example of using the graph as a generator ??"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,

Loading…
Cancel
Save