Skip to content

Instantly share code, notes, and snippets.

@kobus-v-schoor
Created September 30, 2020 08:40
Show Gist options
  • Save kobus-v-schoor/2d3598d7447057ad6169182edded699b to your computer and use it in GitHub Desktop.
Save kobus-v-schoor/2d3598d7447057ad6169182edded699b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from graphviz import Digraph"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"dot = Digraph()\n",
"dot.node('A')\n",
"dot.node('B')\n",
"dot.node('C')\n",
"dot.edges(['AB', 'BC', 'BA', 'CA'])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"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=\"89pt\" height=\"188pt\"\n",
" viewBox=\"0.00 0.00 89.00 188.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 184)\">\n",
"<title>%3</title>\n",
"<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"-4,4 -4,-184 85,-184 85,4 -4,4\"/>\n",
"<!-- A -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>A</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"27\" cy=\"-162\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"27\" y=\"-158.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">A</text>\n",
"</g>\n",
"<!-- B -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>B</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"27\" cy=\"-90\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"27\" y=\"-86.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">B</text>\n",
"</g>\n",
"<!-- A&#45;&gt;B -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>A&#45;&gt;B</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M21.0843,-144.2022C20.2798,-136.1807 20.0571,-126.5231 20.4162,-117.5957\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"23.9097,-117.8099 21.105,-107.593 16.9262,-117.3289 23.9097,-117.8099\"/>\n",
"</g>\n",
"<!-- B&#45;&gt;A -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>B&#45;&gt;A</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M32.895,-107.593C33.7094,-115.5865 33.942,-125.2363 33.5928,-134.1759\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"30.0976,-133.9891 32.9157,-144.2022 37.0817,-134.4608 30.0976,-133.9891\"/>\n",
"</g>\n",
"<!-- C -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>C</title>\n",
"<ellipse fill=\"none\" stroke=\"#000000\" cx=\"54\" cy=\"-18\" rx=\"27\" ry=\"18\"/>\n",
"<text text-anchor=\"middle\" x=\"54\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">C</text>\n",
"</g>\n",
"<!-- B&#45;&gt;C -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
"<title>B&#45;&gt;C</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M33.6742,-72.2022C36.7476,-64.0064 40.4616,-54.1024 43.8695,-45.0145\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"47.1685,-46.1853 47.4026,-35.593 40.6142,-43.7274 47.1685,-46.1853\"/>\n",
"</g>\n",
"<!-- C&#45;&gt;A -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>C&#45;&gt;A</title>\n",
"<path fill=\"none\" stroke=\"#000000\" d=\"M59.7309,-35.644C64.8096,-54.0794 70.3717,-83.6528 63,-108 59.7339,-118.7873 53.5236,-129.3892 47.1687,-138.3037\"/>\n",
"<polygon fill=\"#000000\" stroke=\"#000000\" points=\"44.3715,-136.1999 41.1229,-146.2844 49.9513,-140.4268 44.3715,-136.1999\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
"<graphviz.dot.Digraph at 0x7f9201703630>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dot"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment