{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# DRAFT: Visualizing XVHLScaffold\n",
"\n",
"This notebook uses GraphViz to visualize rows in the XVHLScaffold,\n",
"and demonstrate how the `swap()` function works."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import scaffold_graph_tests\n",
"import importlib; importlib.reload(scaffold_graph_tests)\n",
"from scaffold_graph_tests import *"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Row Swapping with Independent Nodes\n",
"\n",
"This is one of the simplest possible examples.\n",
"\n",
"When a node on either row is independent, it simply stays in place as the rows are swapped.\n",
"\n",
"Note that nodes are _always_ independent of the rows above them, because edges in the scaffold always point downward."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"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.38.0 (20140413.2041)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"586pt\" height=\"284pt\"\n viewBox=\"0.00 0.00 586.00 284.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 280)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-280 582,-280 582,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"289\" y=\"-7.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">diagram 0. independent nodes</text>\n<g id=\"clust1\" class=\"cluster\"><title>cluster_before</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"8,-31 8,-268 285,-268 285,-31 8,-31\"/>\n<text text-anchor=\"middle\" x=\"34.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">before</text>\n</g>\n<g id=\"clust6\" class=\"cluster\"><title>cluster_after</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"293,-31 293,-268 570,-268 570,-31 293,-31\"/>\n<text text-anchor=\"middle\" x=\"313.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">after</text>\n</g>\n<!-- bz0 -->\n<g id=\"node1\" class=\"node\"><title>bz0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- bz1 -->\n<g id=\"node2\" class=\"node\"><title>bz1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"168\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- bz0->bz1 -->\n<!-- bn1 -->\n<g id=\"node6\" class=\"node\"><title>bn1</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"121\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- bz0->bn1 -->\n<g id=\"edge13\" class=\"edge\"><title>bz0->bn1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M121,-204.338C121,-199.124 121,-193.049 121,-187.293\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"123.625,-187.252 121,-179.752 118.375,-187.252 123.625,-187.252\"/>\n</g>\n<!-- bn2 -->\n<g id=\"node8\" class=\"node\"><title>bn2</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"215\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- bz0->bn2 -->\n<g id=\"edge14\" class=\"edge\"><title>bz0->bn2</title>\n<path fill=\"none\" stroke=\"#cccccc\" stroke-dasharray=\"5,2\" d=\"M130.357,-207.449C146.826,-188.877 181.093,-150.236 200.598,-128.241\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"202.669,-129.862 205.681,-122.509 198.741,-126.378 202.669,-129.862\"/>\n</g>\n<!-- bz2 -->\n<g id=\"node3\" class=\"node\"><title>bz2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"215\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- bz1->bz2 -->\n<!-- bz3 -->\n<g id=\"node4\" class=\"node\"><title>bz3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- bz2->bz3 -->\n<!-- bz -->\n<g id=\"node5\" class=\"node\"><title>bz</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- bz->bz0 -->\n<!-- bd -->\n<g id=\"node7\" class=\"node\"><title>bd</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d</text>\n</g>\n<!-- bz->bd -->\n<!-- ba0 -->\n<g id=\"node10\" class=\"node\"><title>ba0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- bn1->ba0 -->\n<g id=\"edge15\" class=\"edge\"><title>bn1->ba0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M121,-150.142C121,-132.029 121,-100.135 121,-79.0337\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"123.625,-79.0259 121,-71.5259 118.375,-79.0259 123.625,-79.0259\"/>\n</g>\n<!-- ba1 -->\n<g id=\"node11\" class=\"node\"><title>ba1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"168\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- bn1->ba1 -->\n<g id=\"edge16\" class=\"edge\"><title>bn1->ba1</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M126.576,-151.424C134.668,-133.175 149.739,-99.1838 159.3,-77.6217\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"161.791,-78.4798 162.431,-70.5595 156.991,-76.3517 161.791,-78.4798\"/>\n</g>\n<!-- bd->bn1 -->\n<!-- bu -->\n<g id=\"node9\" class=\"node\"><title>bu</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u</text>\n</g>\n<!-- bd->bu -->\n<!-- ba2 -->\n<g id=\"node12\" class=\"node\"><title>ba2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"215\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- bn2->ba2 -->\n<g id=\"edge17\" class=\"edge\"><title>bn2->ba2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M215,-96.3376C215,-91.1243 215,-85.0495 215,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"217.625,-79.2516 215,-71.7517 212.375,-79.2517 217.625,-79.2516\"/>\n</g>\n<!-- ba3 -->\n<g id=\"node13\" class=\"node\"><title>ba3</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"262\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a3</text>\n</g>\n<!-- bn2->ba3 -->\n<g id=\"edge18\" class=\"edge\"><title>bn2->ba3</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M224.286,-99.7265C230.852,-92.4619 239.789,-82.5736 247.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"249.652,-75.5764 252.734,-68.2522 245.757,-72.0561 249.652,-75.5764\"/>\n</g>\n<!-- ba -->\n<g id=\"node14\" class=\"node\"><title>ba</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- bu->ba -->\n<!-- ba0->ba1 -->\n<!-- ba1->ba2 -->\n<!-- ba2->ba3 -->\n<!-- ba->ba0 -->\n<!-- az0 -->\n<g id=\"node15\" class=\"node\"><title>az0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- az1 -->\n<g id=\"node16\" class=\"node\"><title>az1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"453\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- az0->az1 -->\n<!-- an1 -->\n<g id=\"node20\" class=\"node\"><title>an1</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"406\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- az0->an1 -->\n<g id=\"edge31\" class=\"edge\"><title>az0->an1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M406,-204.142C406,-186.029 406,-154.135 406,-133.034\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"408.625,-133.026 406,-125.526 403.375,-133.026 408.625,-133.026\"/>\n</g>\n<!-- an2 -->\n<g id=\"node22\" class=\"node\"><title>an2</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"455\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"455\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- az0->an2 -->\n<g id=\"edge32\" class=\"edge\"><title>az0->an2</title>\n<path fill=\"none\" stroke=\"#cccccc\" stroke-dasharray=\"5,2\" d=\"M415.448,-207.974C422.407,-200.588 432.012,-190.395 440.014,-181.903\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"442.013,-183.61 445.246,-176.351 438.192,-180.009 442.013,-183.61\"/>\n</g>\n<!-- az2 -->\n<g id=\"node17\" class=\"node\"><title>az2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"500\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- az1->az2 -->\n<!-- az3 -->\n<g id=\"node18\" class=\"node\"><title>az3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- az2->az3 -->\n<!-- az -->\n<g id=\"node19\" class=\"node\"><title>az</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- az->az0 -->\n<!-- au -->\n<g id=\"node23\" class=\"node\"><title>au</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u'</text>\n</g>\n<!-- az->au -->\n<!-- aa0 -->\n<g id=\"node24\" class=\"node\"><title>aa0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- an1->aa0 -->\n<g id=\"edge33\" class=\"edge\"><title>an1->aa0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M406,-96.3376C406,-91.1243 406,-85.0495 406,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"408.625,-79.2516 406,-71.7517 403.375,-79.2517 408.625,-79.2516\"/>\n</g>\n<!-- aa1 -->\n<g id=\"node25\" class=\"node\"><title>aa1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"453\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- an1->aa1 -->\n<g id=\"edge34\" class=\"edge\"><title>an1->aa1</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M415.286,-99.7265C421.852,-92.4619 430.789,-82.5736 438.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"440.652,-75.5764 443.734,-68.2522 436.757,-72.0561 440.652,-75.5764\"/>\n</g>\n<!-- ad -->\n<g id=\"node21\" class=\"node\"><title>ad</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d'</text>\n</g>\n<!-- aa -->\n<g id=\"node28\" class=\"node\"><title>aa</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- ad->aa -->\n<!-- aa2 -->\n<g id=\"node26\" class=\"node\"><title>aa2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"500\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- an2->aa2 -->\n<g id=\"edge35\" class=\"edge\"><title>an2->aa2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M460.339,-151.424C468.086,-133.175 482.516,-99.1838 491.67,-77.6217\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"494.154,-78.4889 494.668,-70.5595 489.321,-76.4373 494.154,-78.4889\"/>\n</g>\n<!-- aa3 -->\n<g id=\"node27\" class=\"node\"><title>aa3</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"547\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a3</text>\n</g>\n<!-- an2->aa3 -->\n<g id=\"edge36\" class=\"edge\"><title>an2->aa3</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M464.158,-153.449C480.277,-134.877 513.814,-96.2361 532.904,-74.2405\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"534.946,-75.8933 537.879,-68.5085 530.981,-72.4521 534.946,-75.8933\"/>\n</g>\n<!-- au->ad -->\n<!-- au->an2 -->\n<!-- aa0->aa1 -->\n<!-- aa1->aa2 -->\n<!-- aa2->aa3 -->\n<!-- aa->aa0 -->\n</g>\n</svg>\n",
"text/plain": [
"[Digraph]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ite_scaffold(\"independent nodes\",\n",
" before = {\n",
" 'rd': [1], 'ru': [2],\n",
" 'ites': [[z0, 1, 2], [1, a0, a1], [2, a2, a3]]},\n",
" after = {\n",
" 'ru': [2], 'rd': [1],\n",
" 'ites': [[z0, 1, 2], [1, a0, a1], [2, a2, a3]]})\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Each node maintains a reference count. This includes an internal count of the number of incoming edges in the graph,\n",
"plus an external count for reference stored outside the graph (generally, a in a rust variable).\n",
"\n",
"If a node's reference count is zero after its row is swapped, the node is removed from the graph, or \"garbage collected\".\n",
"\n",
"For example, in the graph below, node `#1` is removed because it had no incoming references to begin with.\n",
"This causes the refcounts of `a0` and `#2` to decrease by 1, and so node `#2` is removed because its refcount is now 0.\n",
"\n",
"It appears that node `a0` also has a refcount of 0, but it is not garbage collected because row `a` was not involved in the swap."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"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.38.0 (20140413.2041)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"586pt\" height=\"284pt\"\n viewBox=\"0.00 0.00 586.00 284.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 280)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-280 582,-280 582,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"289\" y=\"-7.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">diagram 1. garbage collection</text>\n<g id=\"clust1\" class=\"cluster\"><title>cluster_before</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"8,-31 8,-268 285,-268 285,-31 8,-31\"/>\n<text text-anchor=\"middle\" x=\"34.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">before</text>\n</g>\n<g id=\"clust6\" class=\"cluster\"><title>cluster_after</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"293,-31 293,-268 570,-268 570,-31 293,-31\"/>\n<text text-anchor=\"middle\" x=\"313.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">after</text>\n</g>\n<!-- bz0 -->\n<g id=\"node1\" class=\"node\"><title>bz0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- bz1 -->\n<g id=\"node2\" class=\"node\"><title>bz1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"168\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- bz0->bz1 -->\n<!-- bz2 -->\n<g id=\"node3\" class=\"node\"><title>bz2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"215\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- bz1->bz2 -->\n<!-- bz3 -->\n<g id=\"node4\" class=\"node\"><title>bz3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- bz2->bz3 -->\n<!-- bz -->\n<g id=\"node5\" class=\"node\"><title>bz</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- bz->bz0 -->\n<!-- bd -->\n<g id=\"node7\" class=\"node\"><title>bd</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d</text>\n</g>\n<!-- bz->bd -->\n<!-- bn1 -->\n<g id=\"node6\" class=\"node\"><title>bn1</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"121\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- bn2 -->\n<g id=\"node8\" class=\"node\"><title>bn2</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"168\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- bn1->bn2 -->\n<g id=\"edge14\" class=\"edge\"><title>bn1->bn2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M130.286,-153.726C136.852,-146.462 145.789,-136.574 153.316,-128.246\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"155.652,-129.576 158.734,-122.252 151.757,-126.056 155.652,-129.576\"/>\n</g>\n<!-- ba0 -->\n<g id=\"node10\" class=\"node\"><title>ba0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- bn1->ba0 -->\n<g id=\"edge13\" class=\"edge\"><title>bn1->ba0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M121,-150.142C121,-132.029 121,-100.135 121,-79.0337\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"123.625,-79.0259 121,-71.5259 118.375,-79.0259 123.625,-79.0259\"/>\n</g>\n<!-- bd->bn1 -->\n<!-- bu -->\n<g id=\"node9\" class=\"node\"><title>bu</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u</text>\n</g>\n<!-- bd->bu -->\n<!-- ba1 -->\n<g id=\"node11\" class=\"node\"><title>ba1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"168\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- bn2->ba1 -->\n<g id=\"edge15\" class=\"edge\"><title>bn2->ba1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M168,-96.3376C168,-91.1243 168,-85.0495 168,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"170.625,-79.2516 168,-71.7517 165.375,-79.2517 170.625,-79.2516\"/>\n</g>\n<!-- ba2 -->\n<g id=\"node12\" class=\"node\"><title>ba2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"215\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- bn2->ba2 -->\n<g id=\"edge16\" class=\"edge\"><title>bn2->ba2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M177.286,-99.7265C183.852,-92.4619 192.789,-82.5736 200.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"202.652,-75.5764 205.734,-68.2522 198.757,-72.0561 202.652,-75.5764\"/>\n</g>\n<!-- ba -->\n<g id=\"node14\" class=\"node\"><title>ba</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- bu->ba -->\n<!-- ba0->ba1 -->\n<!-- ba1->ba2 -->\n<!-- ba3 -->\n<g id=\"node13\" class=\"node\"><title>ba3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">a3</text>\n</g>\n<!-- ba2->ba3 -->\n<!-- ba->ba0 -->\n<!-- az0 -->\n<g id=\"node15\" class=\"node\"><title>az0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- az1 -->\n<g id=\"node16\" class=\"node\"><title>az1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"453\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- az0->az1 -->\n<!-- az2 -->\n<g id=\"node17\" class=\"node\"><title>az2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"500\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- az1->az2 -->\n<!-- az3 -->\n<g id=\"node18\" class=\"node\"><title>az3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- az2->az3 -->\n<!-- az -->\n<g id=\"node19\" class=\"node\"><title>az</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- az->az0 -->\n<!-- au -->\n<g id=\"node21\" class=\"node\"><title>au</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u'</text>\n</g>\n<!-- az->au -->\n<!-- ad -->\n<g id=\"node20\" class=\"node\"><title>ad</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d'</text>\n</g>\n<!-- aa -->\n<g id=\"node26\" class=\"node\"><title>aa</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- ad->aa -->\n<!-- au->ad -->\n<!-- aa0 -->\n<g id=\"node22\" class=\"node\"><title>aa0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- aa1 -->\n<g id=\"node23\" class=\"node\"><title>aa1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"453\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- aa0->aa1 -->\n<!-- aa2 -->\n<g id=\"node24\" class=\"node\"><title>aa2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"500\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- aa1->aa2 -->\n<!-- aa3 -->\n<g id=\"node25\" class=\"node\"><title>aa3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">a3</text>\n</g>\n<!-- aa2->aa3 -->\n<!-- aa->aa0 -->\n</g>\n</svg>\n",
"text/plain": [
"[Digraph]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ite_scaffold(\"garbage collection\",\n",
" before = {\n",
" 'rd': [1], 'ru': [2],\n",
" 'ites': [[z0, un, un], [1, a0, 2], [2, a1, a2]]},\n",
" after = {\n",
" 'ru': [], 'rd': [],\n",
" 'ites': [[z0, un, un], [a0, un, un], [a1, un, un], [a2, un, un]]})\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Row Swapping with Dependent Nodes\n",
"\n",
"### Dependent on one side\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"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.38.0 (20140413.2041)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"586pt\" height=\"284pt\"\n viewBox=\"0.00 0.00 586.00 284.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 280)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-280 582,-280 582,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"289\" y=\"-7.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">diagram 2. dependent on one side</text>\n<g id=\"clust1\" class=\"cluster\"><title>cluster_before</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"8,-31 8,-268 285,-268 285,-31 8,-31\"/>\n<text text-anchor=\"middle\" x=\"34.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">before</text>\n</g>\n<g id=\"clust6\" class=\"cluster\"><title>cluster_after</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"293,-31 293,-268 570,-268 570,-31 293,-31\"/>\n<text text-anchor=\"middle\" x=\"313.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">after</text>\n</g>\n<!-- bz0 -->\n<g id=\"node1\" class=\"node\"><title>bz0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- bz1 -->\n<g id=\"node2\" class=\"node\"><title>bz1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"168\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- bz0->bz1 -->\n<!-- bn1 -->\n<g id=\"node6\" class=\"node\"><title>bn1</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"121\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- bz0->bn1 -->\n<g id=\"edge13\" class=\"edge\"><title>bz0->bn1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M121,-204.338C121,-199.124 121,-193.049 121,-187.293\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"123.625,-187.252 121,-179.752 118.375,-187.252 123.625,-187.252\"/>\n</g>\n<!-- bz2 -->\n<g id=\"node3\" class=\"node\"><title>bz2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"215\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- bz1->bz2 -->\n<!-- bz3 -->\n<g id=\"node4\" class=\"node\"><title>bz3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- bz2->bz3 -->\n<!-- bz -->\n<g id=\"node5\" class=\"node\"><title>bz</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- bz->bz0 -->\n<!-- bd -->\n<g id=\"node7\" class=\"node\"><title>bd</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d</text>\n</g>\n<!-- bz->bd -->\n<!-- bn2 -->\n<g id=\"node8\" class=\"node\"><title>bn2</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"121\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- bn1->bn2 -->\n<g id=\"edge14\" class=\"edge\"><title>bn1->bn2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M121,-150.338C121,-145.124 121,-139.049 121,-133.293\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"123.625,-133.252 121,-125.752 118.375,-133.252 123.625,-133.252\"/>\n</g>\n<!-- ba2 -->\n<g id=\"node12\" class=\"node\"><title>ba2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"215\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- bn1->ba2 -->\n<g id=\"edge15\" class=\"edge\"><title>bn1->ba2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M130.357,-153.449C146.826,-134.877 181.093,-96.2361 200.598,-74.2405\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"202.669,-75.8616 205.681,-68.5085 198.741,-72.3783 202.669,-75.8616\"/>\n</g>\n<!-- bd->bn1 -->\n<!-- bu -->\n<g id=\"node9\" class=\"node\"><title>bu</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u</text>\n</g>\n<!-- bd->bu -->\n<!-- ba0 -->\n<g id=\"node10\" class=\"node\"><title>ba0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- bn2->ba0 -->\n<g id=\"edge16\" class=\"edge\"><title>bn2->ba0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M121,-96.3376C121,-91.1243 121,-85.0495 121,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"123.625,-79.2516 121,-71.7517 118.375,-79.2517 123.625,-79.2516\"/>\n</g>\n<!-- ba1 -->\n<g id=\"node11\" class=\"node\"><title>ba1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"168\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- bn2->ba1 -->\n<g id=\"edge17\" class=\"edge\"><title>bn2->ba1</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M130.286,-99.7265C136.852,-92.4619 145.789,-82.5736 153.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"155.652,-75.5764 158.734,-68.2522 151.757,-72.0561 155.652,-75.5764\"/>\n</g>\n<!-- ba -->\n<g id=\"node14\" class=\"node\"><title>ba</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- bu->ba -->\n<!-- ba0->ba1 -->\n<!-- ba1->ba2 -->\n<!-- ba3 -->\n<g id=\"node13\" class=\"node\"><title>ba3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">a3</text>\n</g>\n<!-- ba2->ba3 -->\n<!-- ba->ba0 -->\n<!-- az0 -->\n<g id=\"node15\" class=\"node\"><title>az0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- az1 -->\n<g id=\"node16\" class=\"node\"><title>az1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"453\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- az0->az1 -->\n<!-- an1 -->\n<g id=\"node23\" class=\"node\"><title>an1</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"406\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- az0->an1 -->\n<g id=\"edge30\" class=\"edge\"><title>az0->an1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M406,-204.338C406,-199.124 406,-193.049 406,-187.293\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"408.625,-187.252 406,-179.752 403.375,-187.252 408.625,-187.252\"/>\n</g>\n<!-- az2 -->\n<g id=\"node17\" class=\"node\"><title>az2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"500\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- az1->az2 -->\n<!-- az3 -->\n<g id=\"node18\" class=\"node\"><title>az3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- az2->az3 -->\n<!-- az -->\n<g id=\"node19\" class=\"node\"><title>az</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- az->az0 -->\n<!-- au -->\n<g id=\"node24\" class=\"node\"><title>au</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u'</text>\n</g>\n<!-- az->au -->\n<!-- an2 -->\n<g id=\"node20\" class=\"node\"><title>an2</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"406\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- aa0 -->\n<g id=\"node25\" class=\"node\"><title>aa0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- an2->aa0 -->\n<g id=\"edge33\" class=\"edge\"><title>an2->aa0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M406,-96.3376C406,-91.1243 406,-85.0495 406,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"408.625,-79.2516 406,-71.7517 403.375,-79.2517 408.625,-79.2516\"/>\n</g>\n<!-- aa2 -->\n<g id=\"node27\" class=\"node\"><title>aa2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"500\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- an2->aa2 -->\n<g id=\"edge34\" class=\"edge\"><title>an2->aa2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M416.814,-101.045C420.53,-98.2349 424.811,-95.2754 429,-93 449.021,-82.124 456.979,-85.876 477,-75 478.963,-73.9334 480.947,-72.7165 482.884,-71.4351\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"484.594,-73.4398 489.186,-66.9546 481.552,-69.1609 484.594,-73.4398\"/>\n</g>\n<!-- an3 -->\n<g id=\"node21\" class=\"node\"><title>an3</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"453\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#3</text>\n</g>\n<!-- aa1 -->\n<g id=\"node26\" class=\"node\"><title>aa1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"453\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- an3->aa1 -->\n<g id=\"edge35\" class=\"edge\"><title>an3->aa1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M453,-96.3376C453,-91.1243 453,-85.0495 453,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"455.625,-79.2516 453,-71.7517 450.375,-79.2517 455.625,-79.2516\"/>\n</g>\n<!-- an3->aa2 -->\n<g id=\"edge36\" class=\"edge\"><title>an3->aa2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M462.286,-99.7265C468.852,-92.4619 477.789,-82.5736 485.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"487.652,-75.5764 490.734,-68.2522 483.757,-72.0561 487.652,-75.5764\"/>\n</g>\n<!-- ad -->\n<g id=\"node22\" class=\"node\"><title>ad</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d'</text>\n</g>\n<!-- aa -->\n<g id=\"node29\" class=\"node\"><title>aa</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- ad->aa -->\n<!-- an1->an2 -->\n<g id=\"edge31\" class=\"edge\"><title>an1->an2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M406,-150.338C406,-145.124 406,-139.049 406,-133.293\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"408.625,-133.252 406,-125.752 403.375,-133.252 408.625,-133.252\"/>\n</g>\n<!-- an1->an3 -->\n<g id=\"edge32\" class=\"edge\"><title>an1->an3</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M415.286,-153.726C421.852,-146.462 430.789,-136.574 438.316,-128.246\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"440.652,-129.576 443.734,-122.252 436.757,-126.056 440.652,-129.576\"/>\n</g>\n<!-- au->ad -->\n<!-- au->an1 -->\n<!-- aa0->aa1 -->\n<!-- aa1->aa2 -->\n<!-- aa3 -->\n<g id=\"node28\" class=\"node\"><title>aa3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">a3</text>\n</g>\n<!-- aa2->aa3 -->\n<!-- aa->aa0 -->\n</g>\n</svg>\n",
"text/plain": [
"[Digraph]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ite_scaffold(\"dependent on one side\",\n",
" before = {\n",
" 'rd': [1], 'ru': [2],\n",
" 'ites': [[z0, 1, un], [1, 2, a2], [2, a0, a1]]},\n",
" after = {\n",
" 'ru': [1], 'rd': [-2, 3],\n",
" 'ites': [[z0, 1, un], [1, 2, 3], [2, a0, a2], [3, a1, a2]]})"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Note that node `#1` has changed its color (branch variable), moving from row `d` to row `u'`, even as the rows swap.\n",
"This way, the graph can be changed without disturbing incoming edges from nodes higher in the graph (`z0`, for example).\n",
"\n",
"It appears as if node `#2` has also switched colors, but the reason is completely different.\n",
"The only reference to this node was coming from `#1`. Once the rows swapped, that reference had to be removed (since\n",
"edges can only point downward), and replaced with a new reference to a node on row `d'`. Removing this edge dropped node `#1`'s\n",
"reference count 0, so it was immediately garbage collected and its slot was reused for a completely new node.\n",
"\n",
"\n",
"Suppose instead that there had been an extra link to `#2`:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"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.38.0 (20140413.2041)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"586pt\" height=\"284pt\"\n viewBox=\"0.00 0.00 586.00 284.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 280)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-280 582,-280 582,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"289\" y=\"-7.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">diagram 3. extra link to #2</text>\n<g id=\"clust1\" class=\"cluster\"><title>cluster_before</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"8,-31 8,-268 285,-268 285,-31 8,-31\"/>\n<text text-anchor=\"middle\" x=\"34.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">before</text>\n</g>\n<g id=\"clust6\" class=\"cluster\"><title>cluster_after</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"293,-31 293,-268 570,-268 570,-31 293,-31\"/>\n<text text-anchor=\"middle\" x=\"313.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">after</text>\n</g>\n<!-- bz0 -->\n<g id=\"node1\" class=\"node\"><title>bz0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- bz1 -->\n<g id=\"node2\" class=\"node\"><title>bz1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"168\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z1</text>\n</g>\n<!-- bz0->bz1 -->\n<!-- bn1 -->\n<g id=\"node6\" class=\"node\"><title>bn1</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"124\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"124\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- bz0->bn1 -->\n<g id=\"edge13\" class=\"edge\"><title>bz0->bn1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M121.788,-204.338C122.089,-199.124 122.439,-193.049 122.772,-187.293\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"125.395,-187.39 123.207,-179.752 120.154,-187.088 125.395,-187.39\"/>\n</g>\n<!-- bz2 -->\n<g id=\"node3\" class=\"node\"><title>bz2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"215\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- bz1->bz2 -->\n<!-- bn2 -->\n<g id=\"node8\" class=\"node\"><title>bn2</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"144\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"144\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- bz1->bn2 -->\n<g id=\"edge14\" class=\"edge\"><title>bz1->bn2</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M164.96,-204.575C160.867,-186.495 153.541,-154.14 148.726,-132.872\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"151.231,-132.051 147.015,-125.316 146.111,-133.211 151.231,-132.051\"/>\n</g>\n<!-- bz3 -->\n<g id=\"node4\" class=\"node\"><title>bz3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- bz2->bz3 -->\n<!-- bz -->\n<g id=\"node5\" class=\"node\"><title>bz</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- bz->bz0 -->\n<!-- bd -->\n<g id=\"node7\" class=\"node\"><title>bd</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d</text>\n</g>\n<!-- bz->bd -->\n<!-- bn1->bn2 -->\n<g id=\"edge15\" class=\"edge\"><title>bn1->bn2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M128.944,-151.146C131.172,-145.353 133.855,-138.378 136.335,-131.93\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"138.871,-132.649 139.113,-124.706 133.971,-130.764 138.871,-132.649\"/>\n</g>\n<!-- ba2 -->\n<g id=\"node12\" class=\"node\"><title>ba2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"215\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- bn1->ba2 -->\n<g id=\"edge16\" class=\"edge\"><title>bn1->ba2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M135.74,-155.91C144.861,-149.294 157.513,-139.368 167,-129 181.76,-112.869 195.391,-91.8615 204.326,-76.8919\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"206.793,-77.8742 208.319,-70.076 202.263,-75.2203 206.793,-77.8742\"/>\n</g>\n<!-- bd->bn1 -->\n<!-- bu -->\n<g id=\"node9\" class=\"node\"><title>bu</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u</text>\n</g>\n<!-- bd->bu -->\n<!-- ba0 -->\n<g id=\"node10\" class=\"node\"><title>ba0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- bn2->ba0 -->\n<g id=\"edge17\" class=\"edge\"><title>bn2->ba0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M138.432,-97.4123C135.777,-91.4082 132.54,-84.0902 129.58,-77.3972\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"131.951,-76.269 126.516,-70.4718 127.15,-78.3927 131.951,-76.269\"/>\n</g>\n<!-- ba1 -->\n<g id=\"node11\" class=\"node\"><title>ba1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"168\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- bn2->ba1 -->\n<g id=\"edge18\" class=\"edge\"><title>bn2->ba1</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M149.81,-97.4123C152.581,-91.4082 155.958,-84.0902 159.047,-77.3972\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"161.484,-78.3816 162.244,-70.4718 156.717,-76.1815 161.484,-78.3816\"/>\n</g>\n<!-- ba -->\n<g id=\"node14\" class=\"node\"><title>ba</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- bu->ba -->\n<!-- ba0->ba1 -->\n<!-- ba1->ba2 -->\n<!-- ba3 -->\n<g id=\"node13\" class=\"node\"><title>ba3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">a3</text>\n</g>\n<!-- ba2->ba3 -->\n<!-- ba->ba0 -->\n<!-- az0 -->\n<g id=\"node15\" class=\"node\"><title>az0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- az1 -->\n<g id=\"node16\" class=\"node\"><title>az1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"453\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z1</text>\n</g>\n<!-- az0->az1 -->\n<!-- an1 -->\n<g id=\"node24\" class=\"node\"><title>an1</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"453\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- az0->an1 -->\n<g id=\"edge33\" class=\"edge\"><title>az0->an1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M415.286,-207.726C421.852,-200.462 430.789,-190.574 438.316,-182.246\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"440.652,-183.576 443.734,-176.252 436.757,-180.056 440.652,-183.576\"/>\n</g>\n<!-- az2 -->\n<g id=\"node17\" class=\"node\"><title>az2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"500\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- az1->az2 -->\n<!-- an2 -->\n<g id=\"node23\" class=\"node\"><title>an2</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"406\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- az1->an2 -->\n<g id=\"edge32\" class=\"edge\"><title>az1->an2</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M443.714,-207.726C437.148,-200.462 428.211,-190.574 420.684,-182.246\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"422.243,-180.056 415.266,-176.252 418.348,-183.576 422.243,-180.056\"/>\n</g>\n<!-- az3 -->\n<g id=\"node18\" class=\"node\"><title>az3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- az2->az3 -->\n<!-- az -->\n<g id=\"node19\" class=\"node\"><title>az</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- az->az0 -->\n<!-- au -->\n<g id=\"node25\" class=\"node\"><title>au</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u'</text>\n</g>\n<!-- az->au -->\n<!-- an3 -->\n<g id=\"node20\" class=\"node\"><title>an3</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"453\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#3</text>\n</g>\n<!-- aa0 -->\n<g id=\"node26\" class=\"node\"><title>aa0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- an3->aa0 -->\n<g id=\"edge38\" class=\"edge\"><title>an3->aa0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M443.714,-99.7265C437.148,-92.4619 428.211,-82.5736 420.684,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"422.243,-72.0561 415.266,-68.2522 418.348,-75.5764 422.243,-72.0561\"/>\n</g>\n<!-- aa2 -->\n<g id=\"node28\" class=\"node\"><title>aa2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"500\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- an3->aa2 -->\n<g id=\"edge39\" class=\"edge\"><title>an3->aa2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M462.286,-99.7265C468.852,-92.4619 477.789,-82.5736 485.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"487.652,-75.5764 490.734,-68.2522 483.757,-72.0561 487.652,-75.5764\"/>\n</g>\n<!-- an4 -->\n<g id=\"node21\" class=\"node\"><title>an4</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"500\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#4</text>\n</g>\n<!-- aa1 -->\n<g id=\"node27\" class=\"node\"><title>aa1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"453\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- an4->aa1 -->\n<g id=\"edge40\" class=\"edge\"><title>an4->aa1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M490.714,-99.7265C484.148,-92.4619 475.211,-82.5736 467.684,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"469.243,-72.0561 462.266,-68.2522 465.348,-75.5764 469.243,-72.0561\"/>\n</g>\n<!-- an4->aa2 -->\n<g id=\"edge41\" class=\"edge\"><title>an4->aa2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M500,-96.3376C500,-91.1243 500,-85.0495 500,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"502.625,-79.2516 500,-71.7517 497.375,-79.2517 502.625,-79.2516\"/>\n</g>\n<!-- ad -->\n<g id=\"node22\" class=\"node\"><title>ad</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d'</text>\n</g>\n<!-- aa -->\n<g id=\"node30\" class=\"node\"><title>aa</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- ad->aa -->\n<!-- an2->an1 -->\n<!-- an2->aa0 -->\n<g id=\"edge34\" class=\"edge\"><title>an2->aa0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M406,-150.142C406,-132.029 406,-100.135 406,-79.0337\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"408.625,-79.0259 406,-71.5259 403.375,-79.0259 408.625,-79.0259\"/>\n</g>\n<!-- an2->aa1 -->\n<g id=\"edge35\" class=\"edge\"><title>an2->aa1</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M409.075,-150.736C412.736,-136.133 419.563,-112.184 429,-93 432.039,-86.8228 436.057,-80.4922 439.934,-74.9431\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"442.078,-76.4573 444.354,-68.8439 437.827,-73.3765 442.078,-76.4573\"/>\n</g>\n<!-- an1->an3 -->\n<g id=\"edge36\" class=\"edge\"><title>an1->an3</title>\n<path fill=\"none\" stroke=\"black\" d=\"M453,-150.338C453,-145.124 453,-139.049 453,-133.293\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"455.625,-133.252 453,-125.752 450.375,-133.252 455.625,-133.252\"/>\n</g>\n<!-- an1->an4 -->\n<g id=\"edge37\" class=\"edge\"><title>an1->an4</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M462.286,-153.726C468.852,-146.462 477.789,-136.574 485.316,-128.246\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"487.652,-129.576 490.734,-122.252 483.757,-126.056 487.652,-129.576\"/>\n</g>\n<!-- au->ad -->\n<!-- au->an2 -->\n<!-- aa0->aa1 -->\n<!-- aa1->aa2 -->\n<!-- aa3 -->\n<g id=\"node29\" class=\"node\"><title>aa3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">a3</text>\n</g>\n<!-- aa2->aa3 -->\n<!-- aa->aa0 -->\n</g>\n</svg>\n",
"text/plain": [
"[Digraph]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ite_scaffold(\"extra link to #2\",\n",
" before = {\n",
" 'rd': [1], 'ru': [2],\n",
" 'ites': [[z0, 1, un], [z1, 2, un], [1, 2, a2], [2, a0, a1]]},\n",
" after = {\n",
" 'ru': [2, 1], 'rd': [3, 4],\n",
" 'ites': [[z1, 2, un], [z0, 1, un], [2, a0, a1], [1, 3, 4], [3, a0, a2], [4, a1, a2]]})"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"As before, node `#1` moved from row `d` to row `u'`, and two new nodes were created on row `d'`, but this time, `#2`\n",
"is left unchanged. Internally, its refcount still dropped by 1, but in terms of the graph itself, it is still\n",
"branching on variable `u`, with its `hi` and `lo` edges pointing at `a0` and `a1`, respectively.\n",
"\n",
"\n",
"### Dependent nodes on both sides"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"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.38.0 (20140413.2041)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"586pt\" height=\"284pt\"\n viewBox=\"0.00 0.00 586.00 284.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 280)\">\n<title>%3</title>\n<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-280 582,-280 582,4 -4,4\"/>\n<text text-anchor=\"middle\" x=\"289\" y=\"-7.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">diagram 4. both branches dependent on u</text>\n<g id=\"clust1\" class=\"cluster\"><title>cluster_before</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"8,-31 8,-268 285,-268 285,-31 8,-31\"/>\n<text text-anchor=\"middle\" x=\"34.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">before</text>\n</g>\n<g id=\"clust6\" class=\"cluster\"><title>cluster_after</title>\n<polygon fill=\"none\" stroke=\"#666666\" points=\"293,-31 293,-268 570,-268 570,-31 293,-31\"/>\n<text text-anchor=\"middle\" x=\"313.5\" y=\"-252.8\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">after</text>\n</g>\n<!-- bz0 -->\n<g id=\"node1\" class=\"node\"><title>bz0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- bz1 -->\n<g id=\"node2\" class=\"node\"><title>bz1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"168\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- bz0->bz1 -->\n<!-- bn1 -->\n<g id=\"node6\" class=\"node\"><title>bn1</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"121\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- bz0->bn1 -->\n<g id=\"edge13\" class=\"edge\"><title>bz0->bn1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M121,-204.338C121,-199.124 121,-193.049 121,-187.293\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"123.625,-187.252 121,-179.752 118.375,-187.252 123.625,-187.252\"/>\n</g>\n<!-- bz2 -->\n<g id=\"node3\" class=\"node\"><title>bz2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"215\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- bz1->bz2 -->\n<!-- bz3 -->\n<g id=\"node4\" class=\"node\"><title>bz3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"262\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- bz2->bz3 -->\n<!-- bz -->\n<g id=\"node5\" class=\"node\"><title>bz</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- bz->bz0 -->\n<!-- bd -->\n<g id=\"node7\" class=\"node\"><title>bd</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d</text>\n</g>\n<!-- bz->bd -->\n<!-- bn2 -->\n<g id=\"node8\" class=\"node\"><title>bn2</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"121\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- bn1->bn2 -->\n<g id=\"edge14\" class=\"edge\"><title>bn1->bn2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M121,-150.338C121,-145.124 121,-139.049 121,-133.293\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"123.625,-133.252 121,-125.752 118.375,-133.252 123.625,-133.252\"/>\n</g>\n<!-- bn3 -->\n<g id=\"node9\" class=\"node\"><title>bn3</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"215\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#3</text>\n</g>\n<!-- bn1->bn3 -->\n<g id=\"edge15\" class=\"edge\"><title>bn1->bn3</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M133.289,-157.202C149.193,-148.404 177.077,-132.979 195.79,-122.627\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"197.416,-124.727 202.708,-118.8 194.875,-120.133 197.416,-124.727\"/>\n</g>\n<!-- bd->bn1 -->\n<!-- bu -->\n<g id=\"node10\" class=\"node\"><title>bu</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u</text>\n</g>\n<!-- bd->bu -->\n<!-- ba0 -->\n<g id=\"node11\" class=\"node\"><title>ba0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"121\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"121\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- bn2->ba0 -->\n<g id=\"edge16\" class=\"edge\"><title>bn2->ba0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M121,-96.3376C121,-91.1243 121,-85.0495 121,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"123.625,-79.2516 121,-71.7517 118.375,-79.2517 123.625,-79.2516\"/>\n</g>\n<!-- ba1 -->\n<g id=\"node12\" class=\"node\"><title>ba1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"168\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"168\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- bn2->ba1 -->\n<g id=\"edge17\" class=\"edge\"><title>bn2->ba1</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M130.286,-99.7265C136.852,-92.4619 145.789,-82.5736 153.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"155.652,-75.5764 158.734,-68.2522 151.757,-72.0561 155.652,-75.5764\"/>\n</g>\n<!-- ba2 -->\n<g id=\"node13\" class=\"node\"><title>ba2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"215\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"215\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- bn3->ba2 -->\n<g id=\"edge18\" class=\"edge\"><title>bn3->ba2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M215,-96.3376C215,-91.1243 215,-85.0495 215,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"217.625,-79.2516 215,-71.7517 212.375,-79.2517 217.625,-79.2516\"/>\n</g>\n<!-- ba3 -->\n<g id=\"node14\" class=\"node\"><title>ba3</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"262\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"262\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a3</text>\n</g>\n<!-- bn3->ba3 -->\n<g id=\"edge19\" class=\"edge\"><title>bn3->ba3</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M224.286,-99.7265C230.852,-92.4619 239.789,-82.5736 247.316,-74.2464\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"249.652,-75.5764 252.734,-68.2522 245.757,-72.0561 249.652,-75.5764\"/>\n</g>\n<!-- ba -->\n<g id=\"node15\" class=\"node\"><title>ba</title>\n<text text-anchor=\"middle\" x=\"52\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- bu->ba -->\n<!-- ba0->ba1 -->\n<!-- ba1->ba2 -->\n<!-- ba2->ba3 -->\n<!-- ba->ba0 -->\n<!-- az0 -->\n<g id=\"node16\" class=\"node\"><title>az0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z0</text>\n</g>\n<!-- az1 -->\n<g id=\"node17\" class=\"node\"><title>az1</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"453\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z1</text>\n</g>\n<!-- az0->az1 -->\n<!-- an1 -->\n<g id=\"node24\" class=\"node\"><title>an1</title>\n<ellipse fill=\"orange\" stroke=\"black\" cx=\"406\" cy=\"-165\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#1</text>\n</g>\n<!-- az0->an1 -->\n<g id=\"edge32\" class=\"edge\"><title>az0->an1</title>\n<path fill=\"none\" stroke=\"#cccccc\" d=\"M406,-204.338C406,-199.124 406,-193.049 406,-187.293\"/>\n<polygon fill=\"#cccccc\" stroke=\"#cccccc\" points=\"408.625,-187.252 406,-179.752 403.375,-187.252 408.625,-187.252\"/>\n</g>\n<!-- az2 -->\n<g id=\"node18\" class=\"node\"><title>az2</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"500\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z2</text>\n</g>\n<!-- az1->az2 -->\n<!-- az3 -->\n<g id=\"node19\" class=\"node\"><title>az3</title>\n<ellipse fill=\"white\" stroke=\"white\" cx=\"547\" cy=\"-219\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"white\">z3</text>\n</g>\n<!-- az2->az3 -->\n<!-- az -->\n<g id=\"node20\" class=\"node\"><title>az</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-215.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">z</text>\n</g>\n<!-- az->az0 -->\n<!-- au -->\n<g id=\"node25\" class=\"node\"><title>au</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-161.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">u'</text>\n</g>\n<!-- az->au -->\n<!-- an2 -->\n<g id=\"node21\" class=\"node\"><title>an2</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"406\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#2</text>\n</g>\n<!-- aa0 -->\n<g id=\"node26\" class=\"node\"><title>aa0</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"406\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"406\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a0</text>\n</g>\n<!-- an2->aa0 -->\n<g id=\"edge35\" class=\"edge\"><title>an2->aa0</title>\n<path fill=\"none\" stroke=\"black\" d=\"M406,-96.3376C406,-91.1243 406,-85.0495 406,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"408.625,-79.2516 406,-71.7517 403.375,-79.2517 408.625,-79.2516\"/>\n</g>\n<!-- aa2 -->\n<g id=\"node28\" class=\"node\"><title>aa2</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"500\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"500\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a2</text>\n</g>\n<!-- an2->aa2 -->\n<g id=\"edge36\" class=\"edge\"><title>an2->aa2</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M416.814,-101.045C420.53,-98.2349 424.811,-95.2754 429,-93 449.021,-82.124 456.979,-85.876 477,-75 478.963,-73.9334 480.947,-72.7165 482.884,-71.4351\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"484.594,-73.4398 489.186,-66.9546 481.552,-69.1609 484.594,-73.4398\"/>\n</g>\n<!-- an3 -->\n<g id=\"node22\" class=\"node\"><title>an3</title>\n<ellipse fill=\"dodgerblue\" stroke=\"black\" cx=\"453\" cy=\"-111\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">#3</text>\n</g>\n<!-- aa1 -->\n<g id=\"node27\" class=\"node\"><title>aa1</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"453\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"453\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a1</text>\n</g>\n<!-- an3->aa1 -->\n<g id=\"edge37\" class=\"edge\"><title>an3->aa1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M453,-96.3376C453,-91.1243 453,-85.0495 453,-79.2931\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"455.625,-79.2516 453,-71.7517 450.375,-79.2517 455.625,-79.2516\"/>\n</g>\n<!-- aa3 -->\n<g id=\"node29\" class=\"node\"><title>aa3</title>\n<ellipse fill=\"white\" stroke=\"#cccccc\" cx=\"547\" cy=\"-57\" rx=\"14.5\" ry=\"14.5\"/>\n<text text-anchor=\"middle\" x=\"547\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a3</text>\n</g>\n<!-- an3->aa3 -->\n<g id=\"edge38\" class=\"edge\"><title>an3->aa3</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M466.196,-104.349C480.739,-97.9281 504.636,-86.799 524,-75 525.908,-73.8373 527.856,-72.5581 529.771,-71.2393\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"531.499,-73.2297 536.048,-66.7144 528.429,-68.971 531.499,-73.2297\"/>\n</g>\n<!-- ad -->\n<g id=\"node23\" class=\"node\"><title>ad</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-107.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\">d'</text>\n</g>\n<!-- aa -->\n<g id=\"node30\" class=\"node\"><title>aa</title>\n<text text-anchor=\"middle\" x=\"337\" y=\"-53.3\" font-family=\"Times New Roman,serif\" font-size=\"14.00\" fill=\"#cccccc\">a</text>\n</g>\n<!-- ad->aa -->\n<!-- an1->an2 -->\n<g id=\"edge33\" class=\"edge\"><title>an1->an2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M406,-150.338C406,-145.124 406,-139.049 406,-133.293\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"408.625,-133.252 406,-125.752 403.375,-133.252 408.625,-133.252\"/>\n</g>\n<!-- an1->an3 -->\n<g id=\"edge34\" class=\"edge\"><title>an1->an3</title>\n<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M415.286,-153.726C421.852,-146.462 430.789,-136.574 438.316,-128.246\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"440.652,-129.576 443.734,-122.252 436.757,-126.056 440.652,-129.576\"/>\n</g>\n<!-- au->ad -->\n<!-- au->an1 -->\n<!-- aa0->aa1 -->\n<!-- aa1->aa2 -->\n<!-- aa2->aa3 -->\n<!-- aa->aa0 -->\n</g>\n</svg>\n",
"text/plain": [
"[Digraph]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ite_scaffold(\"both branches dependent on u\",\n",
" before = {\n",
" 'rd': [1], 'ru': [2, 3],\n",
" 'ites': [[z0, 1, un], [1, 2, 3], [2, a0, a1], [3, a2, a3]]},\n",
" after = {\n",
" 'ru': [1], 'rd': [-2, -3],\n",
" 'ites': [[z0, 1, un], [1, 2, 3], [2, a0, a2], [3, a1, a3]]})\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"TODO: dependent on both sides, with extra reference(s)\n",
"\n",
"TODO: special case when one side collapses\n",
"\n",
"TODO: show when a v-node would be deleted but there are references from outside row v\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"write_tests()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.1 64-bit",
"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.10.1"
},
"metadata": {
"interpreter": {
"hash": "02dd80c4b7287f3e16ced86c43aa4adbd2bf8523c6ec7913418dfb2bc69fcf95"
}
},
"vscode": {
"interpreter": {
"hash": "0a772f36d6f012e6a612662d86668ecc0866106f9098f9c3a4257ac075db434c"
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}