Deleting a connected node does not clear the connections

Reproduction steps:

  • Add BranchA, BranchB, NodeC, NodeD
  • Connect BranchA → NodeC → BranchB
  • Delete NodeC
  • Attempt to connect BranchA → NodeD → BranchB

The final step will fail, as the branch internally didn’t clear the previous connection

Additionally, this may cause inadvertent connections to be created, if a new NodeInternal happens to be assigned with the old one’s name. This will happen if after the Reproduction steps, if a new “NodeInternal” is added.

Gas branch/nodes are also affected the same way.

Manually clearing the “node_i”, “node_j” seems to free up the branches for new connections, though a more robust solution, which internally undos every node’s connections before deletions has a better chance of avoiding similar issues in the future.

  "model": {
    "nodes": [
      {
        "name": "NodeInternal1",
        "category": 1,
        "type": "NodeInternal",
        "dimType": null,
        "dimA": null,
        "dimB": null,
        "length": null,
        "volume": null
      }
    ],
    "branches": [
      {
        "name": "Branch",
        "category": 2,
        "type": "Branch",
        "dimType": null,
        "dimA": null,
        "dimB": null,
        "length": null,
        "volume": null,
        "node_i": null,
        "node_j": "NodeInternal", #### This node does not exist
        "roughness": null,
        "fittings": [],
        "n": null
      },
      {
        "name": "Branch1",
        "category": 2,
        "type": "Branch",
        "dimType": null,
        "dimA": null,
        "dimB": null,
        "length": null,
        "volume": null,
        "node_i": "NodeInternal", #### This node does not exist
        "node_j": null,
        "roughness": null,
        "fittings": [],
        "n": null
      }
    ],
    "machineries": [],
    "transmissions": [],
    "solids": [],
    "control_parameters": []
  },

Thanks for this, working on a fix, should be out in version 0.4+ :slight_smile: