Referenced cell within a function not reflecting latest reference

You can visualize the dataflow of your notebook using the notebook visualizer:

I’m not sure I understand what you are trying to achieve with the example code. Is the idea that you want to have a graph cell, but have the positions of the graph nodes be draggable by the user, and then have other cells that react to the new user-specified positions? In that case, you here are two options.

Option 1. Use a view to display the graph, allow dragging, and expose the value interactively to the rest of the notebook. The view (the graph cell) will be the only cell that mutates the graph object. Here are a couple examples of this technique:


Option 2. Use a mutable. The graph display will handle the interaction and re-assign to mutable graph when a node is dragged.

The basic idea with the mutable is that you assign to mutable graph instead of emitting an input event as with a view. But I would recommend using a view unless you can elaborate on why you need a mutable.

1 Like