-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to edit nodes, edges, etc., after adding them #141
Comments
I really need these functionalities too. |
Thanks Matt and ntala. Sorry for taking so long to reply. About dependencies: One of reason for creating this package was to provide a pure Python way to render graphs: A library that does not depend on non-pure Python dependencies. Such dependencies where non-trivial to get working on some of the target platforms. Back then, About architecture: In my view, this library works at the level of DOT source lines/statements ( Long story short: Better editable I think a minimal working version would boil down to recording calls to I have written a quick proof of concept for this: https://gist.github.com/xflr6/1883d79bbe27b3e75a47916d1ab6b8a7. Maybe you guys can take a look and let me know if something in this direction would work for you. Here is a short example: >>> dot = LazyDigraph(filename='round-table.gv', comment='The Round Table')
>>> dot.node('A', 'King Arthur')
>>> dot.node('B', 'Sir Bedevere the Wise')
>>> dot.node('L', 'Sir Lancelot the Brave')
>>> dot.edges(['AB', 'AL'])
>>> dot.edge('B', 'L', constraint='false')
>>> method_name, tail_head, edge_attrs = dot.mock_calls.pop()
>>> assert method_name == 'edge'
>>> assert tail_head == ('B', 'L')
>>> assert edge_attrs == {'constraint': 'false'}
>>> dot.edge(*reversed(tail_head), **edge_attrs) # reverse the last edge
>>> print(dot.source)
// The Round Table
digraph {
A [label="King Arthur"]
B [label="Sir Bedevere the Wise"]
L [label="Sir Lancelot the Brave"]
A -> B
A -> L
L -> B [constraint=false] |
Marking this as enhancement for now (assuming the prototype would satisfy the use case). Let me know if there is interest in this. |
Now it's my turn to apologize for the delay in response, and thanks for considering this! It's hard to tell from the prototype, but would this support reading from an existing file to great the digraph that could then be modified using your In any event, |
No worries :)
If the approach replacing |
- see #141 - #141 (comment) - from https://gist.github.com/xflr6/1883d79bbe27b3e75a47916d1ab6b8a7 - at 307bf63d835eadce204817824befd0262135853a
I can't speak for @ntala, but I think my answer is, "yes". (Although I'm not sure I understand correctly.) My use case involves programmatically reading a |
PyGraphviz allows for this, but I think leans pretty heavily on the underlying Graphviz native library, which is sometimes a pain to install as a dependency. It would be super neato keen if there was a pure Python version of this functionality.
Architecturally, this would likely be a substantial departure from the current approach. I'm assuming one would want to define and maintain an internal representation of the graph(s), and then translate them to the
dot
format at write-time (rather than at edit time, which is what appears to be done now). One would have to be careful to ensure that the same set of inputs still resulted in the samedot
source each time.Once such functionality existed, one could write a reader as well, which would support a fairly powerful workflow:
dot
file from an external source.dot
structure reflecting the edited structure, and optionally render it.The text was updated successfully, but these errors were encountered: