Search code examples
pythonnetworkx

Remove a node from graph using NetworkX without copying


I was wondering if it's possible to remove a node from the graph without modifying the original graph to check if removing that node increase the connected components.


Solution

  • Create a subgraph view without that node. https://networkx.org/documentation/stable/reference/classes/generated/networkx.Graph.subgraph.html