Document behavior whan adding Node to a Graph with already used identifier #13

Open
opened 2026-06-08 01:19:29 +00:00 by linarphy · 1 comment
Owner

Right now, a node will fail to connect if it has an identifier that is already defined in the graph. I think this could be better if we re-use the node in this case. But I’m not sure about user expectation in this case. Would that surprise user to use a different object in the connection than the one they used in the connect method ?

Current behavior is NodeAlreadyInGraphError, which may be fine already.

Right now, a node will fail to connect if it has an identifier that is already defined in the graph. I think this could be better if we re-use the node in this case. But I’m not sure about user expectation in this case. Would that surprise user to use a different object in the connection than the one they used in the connect method ? Current behavior is `NodeAlreadyInGraphError`, which may be fine already.
Author
Owner

After some though, I think current behavior is good. May be good to add documentation about this just in case. If this is applied, user could do

test_1 = Node(identifier="test", data="A")
test_2 = Node(identifier="test", data="B")
graph = Graph()
graph.add(test_1)
connection = graph.connect(test_2, Connection(), Node()) # will fail with current implementation
print(connection.state.setup.source.data) # user will expect "B" but this would return "A"
After some though, I think current behavior is good. May be good to add documentation about this just in case. If this is applied, user could do ```py test_1 = Node(identifier="test", data="A") test_2 = Node(identifier="test", data="B") graph = Graph() graph.add(test_1) connection = graph.connect(test_2, Connection(), Node()) # will fail with current implementation print(connection.state.setup.source.data) # user will expect "B" but this would return "A" ```
linarphy changed title from Re-use Node with existing identifier in graph.connect to Document behavior whan adding Node to a Graph with already used identifier 2026-06-09 16:33:16 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
linarphy/galaxy-graph#13
No description provided.