{ "cells": [ { "cell_type": "code", "execution_count": 8, "source": [ "!pip install graphviz -Uq\n", "\n", "\n", "import graphviz\n", "\n", "g = graphviz.Digraph('G', engine='fdp')\n", "\n", "g.node('A')\n", "g.node('B')\n", "\n", "with g.subgraph(name='cluster0') as c0:\n", " c0.edge('f', 'g')\n", " c0.edge('q', 'f')\n", " # c0.edge('f', 'A')\n", "\n", "g.edge('B', 'cluster0')\n", "\n", "g" ], "outputs": [ { "output_type": "execute_result", "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.47.3 (0)\n -->\n<!-- Title: G Pages: 1 -->\n<svg width=\"230pt\" height=\"147pt\"\n viewBox=\"0.00 0.00 230.00 147.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 143)\">\n<title>G</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-143 226,-143 226,4 -4,4\"/>\n<g id=\"clust1\" class=\"cluster\">\n<title>cluster0</title>\n<polygon fill=\"none\" stroke=\"black\" points=\"0.11,0.06 0.11,-138.94 137.11,-138.94 137.11,0.06 0.11,0.06\"/>\n</g>\n<!-- A -->\n<g id=\"node1\" class=\"node\">\n<title>A</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"195.24\" cy=\"-115.64\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"195.24\" y=\"-111.94\" font-family=\"Times,serif\" font-size=\"14.00\">A</text>\n</g>\n<!-- B -->\n<g id=\"node2\" class=\"node\">\n<title>B</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"175.66\" cy=\"-53.45\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"175.66\" y=\"-49.75\" font-family=\"Times,serif\" font-size=\"14.00\">B</text>\n</g>\n<!-- __0:cluster0 -->\n<!-- B->__0:cluster0 -->\n<g id=\"edge4\" class=\"edge\">\n<title>B->__0:cluster0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M149.2,-57.4C148.62,-57.49 148.03,-57.58 147.44,-57.66\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"146.82,-54.22 137.45,-59.16 147.86,-61.14 146.82,-54.22\"/>\n</g>\n<!-- f -->\n<g id=\"node3\" class=\"node\">\n<title>f</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"35.47\" cy=\"-77.15\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"35.47\" y=\"-73.45\" font-family=\"Times,serif\" font-size=\"14.00\">f</text>\n</g>\n<!-- g -->\n<g id=\"node4\" class=\"node\">\n<title>g</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"101.78\" cy=\"-112.98\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"101.78\" y=\"-109.28\" font-family=\"Times,serif\" font-size=\"14.00\">g</text>\n</g>\n<!-- f->g -->\n<g id=\"edge1\" class=\"edge\">\n<title>f->g</title>\n<path fill=\"none\" stroke=\"black\" d=\"M56.45,-88.49C61.28,-91.1 66.52,-93.93 71.66,-96.71\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"70.24,-99.92 80.7,-101.6 73.57,-93.76 70.24,-99.92\"/>\n</g>\n<!-- q -->\n<g id=\"node5\" class=\"node\">\n<title>q</title>\n<ellipse fill=\"none\" stroke=\"black\" cx=\"36.34\" cy=\"-25.59\" rx=\"27\" ry=\"18\"/>\n<text text-anchor=\"middle\" x=\"36.34\" y=\"-21.89\" font-family=\"Times,serif\" font-size=\"14.00\">q</text>\n</g>\n<!-- q->f -->\n<g id=\"edge2\" class=\"edge\">\n<title>q->f</title>\n<path fill=\"none\" stroke=\"black\" d=\"M36.04,-43.63C36.01,-45.34 35.98,-47.11 35.95,-48.89\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"32.45,-48.98 35.77,-59.04 39.44,-49.1 32.45,-48.98\"/>\n</g>\n</g>\n</svg>\n", "text/plain": [ "<graphviz.dot.Digraph at 0x7fb0a9c138b0>" ] }, "metadata": {}, "execution_count": 8 } ], "metadata": {} } ], "metadata": { "orig_nbformat": 4, "language_info": { "name": "python", "version": "3.9.4", "mimetype": "text/x-python", "codemirror_mode": { "name": "ipython", "version": 3 }, "pygments_lexer": "ipython3", "nbconvert_exporter": "python", "file_extension": ".py" }, "kernelspec": { "name": "python3", "display_name": "Python 3.9.4 64-bit ('py3': conda)" }, "interpreter": { "hash": "5ddcf14c786c671500c086f61f0b66d0417d6c58ff12753e346e191a84f72b84" } }, "nbformat": 4, "nbformat_minor": 2 }