Skip to content
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

Make Graph.adjacentNodes more transparent when a node gets deleted. #6553

Commits on Jun 15, 2023

  1. Make Graph.adjacentNodes more transparent when a node gets deleted:

    When a node in the graph is deleted, it can sometimes cause confusion with the view provided by the `Graph.adjacentNodes` function. This happens because the view might have been created before the node was removed.
    
    The removeNode function in `StandardMutableGraph` (which calls `StandardMutableValueGraph.removeNode`) meant to eliminate the connections related to the node. However, the `{Directed,Undirected}GraphConnections.adjacentNodeValues` associated with the to-be-removed node might still be referred to by the view constructed by `Graph.adjacentNodes` (which calls `StandardValueGraph.adjacentNodes`).
    
    So, this can result in indirect references to the values of adjacent nodes (from the perspective of the node that was removed), even though they've been deleted. This makes the view less transparent, because it's showing information that isn't accurate anymore after the node has been removed.
    
    The solution is to cleanup the associated `GraphConnections` before finally removing the node from the graph. Also it is now better aligned to the implementation of `StandardMutableNetwork.removeNode` reusing the same mechanism of copying the view to an immutable collection to avoid modifying the underlying view while iterating over it.
    ineuwirth committed Jun 15, 2023
    Configuration menu
    Copy the full SHA
    5a622ab View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2023

  1. Make Graph.adjacentNodes more transparent when a node gets deleted:

    Fixed review finding: the approach was borrowed from `StandardMutableNetwork.removeNode` where elements are copied to `ImmutableList`. Making the immutable collection list here too, so it is safer as no deduplication or reordering might happen.
    ineuwirth committed Jun 20, 2023
    Configuration menu
    Copy the full SHA
    f05f3f9 View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2023

  1. Configuration menu
    Copy the full SHA
    81e554b View commit details
    Browse the repository at this point in the history