Modify DAG to improve ergonomics and robustness #785
Closed
chubei
started this conversation in
Feature Requests
Replies: 1 comment 1 reply
-
@chubei it makes sense, I have just a few questions:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Modify
DAG
to improve ergonomics and robustnessMotivation
Currently
DAG
is in fact a directed graph. In no way it checks if there's a cycle in the graph.It also provides limited abstraction over the graph operations. Apart from the
add_node
,connect
andmerge
method, it doesn't provide common graph operations such as topological order traversal, parent/child look up and traversal, etc.Instead, it exposes its internal data structure to the user,
pub nodes
andpub edges
, and expect the user to maintain its invariant when implementing common operations upon it. This is a leaky abstraction and can lead to bugs.Ways to improve
nodes
andedges
private, and provide methods for needed operations.Other ergonomics improvements
PortHandle
. Instead, every node defines the number of its input/output ports and user connects using the port index.It's extra mental burden to remember the port handle, and it doesn't provide any extra functionality over the port index.
connect
is called with invalid node/port.If user tries to add an invalid edge, that's probably a bug instead of an error that the user wants to handle.
@snork-alt @v3g42 @mediuminvader what do you think?
Beta Was this translation helpful? Give feedback.
All reactions