-
-
Save N-Coder/bf5c27408d2f872a8a0b6e83a0cf5b4d to your computer and use it in GitHub Desktop.
TreeLayout only handles TreeLayout::RootSelectionType::Source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"True" | |
] | |
}, | |
"execution_count": 1, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from ogdf_python import cppinclude, ogdf\n", | |
"\n", | |
"cppinclude(\"ogdf/fileformats/GraphIO.h\")\n", | |
"cppinclude(\"ogdf/tree/TreeLayout.h\")\n", | |
"cppinclude(\"ogdf/basic/simple_graph_alg.h\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0 5 True\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<?xml version=\"1.0\"?>\n", | |
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:ev=\"http://www.w3.org/2001/xml-events\" version=\"1.1\" baseProfile=\"full\" viewBox=\"-91 -11 182 92\">\n", | |
"\t<g>\n", | |
"\t\t<g>\n", | |
"\t\t\t<polygon points=\"-70,61.25,-67.0602,57.0168,-65.414,58.8982,\" stroke=\"#000000\" />\n", | |
"\t\t\t<path fill=\"none\" d=\" M0,0 L-70,61.25\" stroke=\"#000000\" />\n", | |
"\t\t</g>\n", | |
"\t\t<g>\n", | |
"\t\t\t<polygon points=\"-34.2857,60,-32.8903,55.0386,-30.7197,56.279,\" stroke=\"#000000\" />\n", | |
"\t\t\t<path fill=\"none\" d=\" M0,0 L-34.2857,60\" stroke=\"#000000\" />\n", | |
"\t\t</g>\n", | |
"\t\t<g>\n", | |
"\t\t\t<polygon points=\"0,60,-1.25,55,1.25,55,\" stroke=\"#000000\" />\n", | |
"\t\t\t<path fill=\"none\" d=\" M0,0 L0,55\" stroke=\"#000000\" />\n", | |
"\t\t</g>\n", | |
"\t\t<g>\n", | |
"\t\t\t<polygon points=\"34.2857,60,30.7197,56.279,32.8903,55.0386,\" stroke=\"#000000\" />\n", | |
"\t\t\t<path fill=\"none\" d=\" M0,0 L34.2857,60\" stroke=\"#000000\" />\n", | |
"\t\t</g>\n", | |
"\t\t<g>\n", | |
"\t\t\t<polygon points=\"70,61.25,65.414,58.8982,67.0602,57.0168,\" stroke=\"#000000\" />\n", | |
"\t\t\t<path fill=\"none\" d=\" M0,0 L70,61.25\" stroke=\"#000000\" />\n", | |
"\t\t</g>\n", | |
"\t</g>\n", | |
"\t<g>\n", | |
"\t\t<rect x=\"-10\" y=\"-10\" width=\"20\" height=\"20\" />\n", | |
"\t</g>\n", | |
"\t<g>\n", | |
"\t\t<rect x=\"-90\" y=\"60\" width=\"20\" height=\"20\" />\n", | |
"\t</g>\n", | |
"\t<g>\n", | |
"\t\t<rect x=\"-50\" y=\"60\" width=\"20\" height=\"20\" />\n", | |
"\t</g>\n", | |
"\t<g>\n", | |
"\t\t<rect x=\"-10\" y=\"60\" width=\"20\" height=\"20\" />\n", | |
"\t</g>\n", | |
"\t<g>\n", | |
"\t\t<rect x=\"30\" y=\"60\" width=\"20\" height=\"20\" />\n", | |
"\t</g>\n", | |
"\t<g>\n", | |
"\t\t<rect x=\"70\" y=\"60\" width=\"20\" height=\"20\" />\n", | |
"\t</g>\n", | |
"</svg>\n" | |
], | |
"text/plain": [ | |
"<cppyy.gbl.ogdf.GraphAttributes object at 0x5587934ce470>" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"G = ogdf.Graph()\n", | |
"root = G.newNode()\n", | |
"leaves = [G.newNode() for i in range(5)]\n", | |
"for leaf in leaves:\n", | |
" G.newEdge(root,leaf)\n", | |
"print(root.indeg(), root.outdeg(), ogdf.isArborescenceForest(G))\n", | |
"GA = ogdf.GraphAttributes(G)\n", | |
"tl = ogdf.TreeLayout()\n", | |
"tl.rootSelection(ogdf.TreeLayout.RootSelectionType.Source)\n", | |
"tl.call(GA)\n", | |
"GA" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"5 0 False\n" | |
] | |
}, | |
{ | |
"ename": "AssertionFailed", | |
"evalue": "void ogdf::TreeLayout::call(ogdf::GraphAttributes& GA) =>\n AssertionFailed: OGDF assertion `isArborescenceForest(tree)' failed at /home/finksim/GitLab/ogdf/ogdf/src/ogdf/tree/TreeLayout.cpp:387(virtual void ogdf::TreeLayout::call(ogdf::GraphAttributes&))\nStack trace (most recent call last):\n#20 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d39904, in _PyEval_EvalFrameDefault\n#19 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d50e95, in gen_send_ex\n#18 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d39904, in _PyEval_EvalFrameDefault\n#17 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d50e95, in gen_send_ex\n#16 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d34427, in _PyEval_EvalFrameDefault\n#15 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d41c4b, in cfunction_vectorcall_FASTCALL\n#14 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db795f, in builtin_exec\n#13 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db1cde, in PyEval_EvalCode\n#12 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db1d2c, in PyEval_EvalCodeEx\n#11 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db1d94, in _PyEval_EvalCodeWithName\n#10 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d33090, in _PyEval_EvalCode\n#9 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d3996d, in _PyEval_EvalFrameDefault\n#8 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d3cd22, in _PyObject_MakeTpCall\n#7 Source \"src/CPPOverload.cxx\", line 565, in mp_call\n#6 Source \"src/CPPMethod.cxx\", line 810, in Call\n#5 Source \"src/CPPMethod.cxx\", line 755, in Execute\n#4 Source \"src/CPPMethod.cxx\", line 144, in ExecuteProtected\n#3 Source \"src/CPPMethod.cxx\", line 69, in ExecuteFast\n#2 | Source \"src/Executors.cxx\", line 414, in GILCallV\n Source \"src/Executors.cxx\", line 68, in Execute\n#1 Source \"src/clingwrapper.cxx\", line 802, in WrapperCall\n#0 Source \"/home/finksim/GitLab/ogdf/ogdf/src/ogdf/tree/TreeLayout.cpp\", line 387, in call\n > 387: \tOGDF_ASSERT(isArborescenceForest(tree));\n 388: \tOGDF_ASSERT(m_siblingDistance > 0);\n", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mAssertionFailed\u001b[0m Traceback (most recent call last)", | |
"\u001b[0;32m<ipython-input-3-0f96ea1c6666>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mtl\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mogdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTreeLayout\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0mtl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrootSelection\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mogdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTreeLayout\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRootSelectionType\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSource\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m \u001b[0mtl\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcall\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mGA\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 12\u001b[0m \u001b[0mGA\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0;31mAssertionFailed\u001b[0m: void ogdf::TreeLayout::call(ogdf::GraphAttributes& GA) =>\n AssertionFailed: OGDF assertion `isArborescenceForest(tree)' failed at /home/finksim/GitLab/ogdf/ogdf/src/ogdf/tree/TreeLayout.cpp:387(virtual void ogdf::TreeLayout::call(ogdf::GraphAttributes&))\nStack trace (most recent call last):\n#20 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d39904, in _PyEval_EvalFrameDefault\n#19 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d50e95, in gen_send_ex\n#18 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d39904, in _PyEval_EvalFrameDefault\n#17 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d50e95, in gen_send_ex\n#16 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d34427, in _PyEval_EvalFrameDefault\n#15 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d41c4b, in cfunction_vectorcall_FASTCALL\n#14 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db795f, in builtin_exec\n#13 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db1cde, in PyEval_EvalCode\n#12 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db1d2c, in PyEval_EvalCodeEx\n#11 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541db1d94, in _PyEval_EvalCodeWithName\n#10 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d33090, in _PyEval_EvalCode\n#9 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d3996d, in _PyEval_EvalFrameDefault\n#8 Object \"/usr/lib64/libpython3.9.so.1.0, at 0x7f2541d3cd22, in _PyObject_MakeTpCall\n#7 Source \"src/CPPOverload.cxx\", line 565, in mp_call\n#6 Source \"src/CPPMethod.cxx\", line 810, in Call\n#5 Source \"src/CPPMethod.cxx\", line 755, in Execute\n#4 Source \"src/CPPMethod.cxx\", line 144, in ExecuteProtected\n#3 Source \"src/CPPMethod.cxx\", line 69, in ExecuteFast\n#2 | Source \"src/Executors.cxx\", line 414, in GILCallV\n Source \"src/Executors.cxx\", line 68, in Execute\n#1 Source \"src/clingwrapper.cxx\", line 802, in WrapperCall\n#0 Source \"/home/finksim/GitLab/ogdf/ogdf/src/ogdf/tree/TreeLayout.cpp\", line 387, in call\n > 387: \tOGDF_ASSERT(isArborescenceForest(tree));\n 388: \tOGDF_ASSERT(m_siblingDistance > 0);\n" | |
] | |
} | |
], | |
"source": [ | |
"del GA\n", | |
"G = ogdf.Graph()\n", | |
"root = G.newNode()\n", | |
"leaves = [G.newNode() for i in range(5)]\n", | |
"for leaf in leaves:\n", | |
" G.newEdge(leaf,root)\n", | |
"print(root.indeg(), root.outdeg(), ogdf.isArborescenceForest(G))\n", | |
"GA = ogdf.GraphAttributes(G)\n", | |
"tl = ogdf.TreeLayout()\n", | |
"tl.rootSelection(ogdf.TreeLayout.RootSelectionType.Source)\n", | |
"tl.call(GA)\n", | |
"GA" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "ogdf-python", | |
"language": "python", | |
"name": "ogdf-python" | |
}, | |
"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.9.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment