Comments (2)
Adjusting the recursion limit is not a fail-proof solution, because a hard limit does exist. The general solution is to remove recursion. Nonetheless, another suggestion may allow to avoid this.
Though I am not familiar with the internals of the algorithm, a similar issue arises in flattening a syntax tree with more nested operators than the default recursion limit. Increasing the recursion limit is not a solution there, because an expression can have arbitrarily many operators. Clearly, an unbounded number of operators can't be handled (unless processing in a streaming fashion). Nonetheless, the bound can be increased significantly, compared to that imposed by the recursion limit.
The solution is to arrange the (associative) operators in a binary tree. The total number of operators is the same, but the recursion depth is their logarithm. So a the required recursion depth becomes logarithmic in the number of operators, as opposed to linear (which it was initially).
Sidenote: humans do not manually write expressions with more associative operators (e.g., conjunctions) than the recursion depth, but machines do. The expressions mentioned above are generated by a machine, so the number of conjunctions is unavoidable. At the same time, this also allows automatically generating them in a binary tree (using parentheses to prevent the parser from blindly applying the associativity of that operator, which would yield a linear tree).
As already noted, I am not familiar with the details of the layout algorithm, and whether its recursive calls can be arranged as a binary call tree, but it is a possibility that can avoid rewriting the whole algorithm in a non-recursive paradigm.
from grandalf.
I see what you mean (actually amoco/cas/expressions.py and associated parser.py illustrate this as well) but unfortunately the final phase of the layout algorithm does not involve binary operators.
It is really recursive "by nature" (like a factorial function is) and thus is very easy to implement this way.
Removing recursion is a pain but I don't see any other option here...
from grandalf.
Related Issues (19)
- SugiyamaLayout is sensitive to initial Vertex ordering HOT 1
- ImportError: No module named linalg HOT 2
- add `grandalf` to PyPI HOT 2
- Format code to obey pep8
- Drawing to a file? HOT 3
- Please add a simple copy and past sample on the front page
- Release a new version HOT 4
- Point interpolation by splines is badly parametrized
- Please push tests into your source distribution
- Render graph from draw HOT 2
- Deprecation warning due to invalid escape sequences
- Orthogonal Layout
- No source tarball for 0.7 on the PyPI.org site HOT 10
- Drawing graph left to right (horizontally) rather vertically (top to bottom) HOT 3
- Videos in Wiki are Private HOT 1
- AttributeError in Tarjan algorithm HOT 1
- grandalf layout seems to give horizontal layouts instead of more vertically-aligned layouts HOT 6
- Sugiyama layout fails with custom ranking HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grandalf.