portIndexById method

int portIndexById(
  1. String portId
)

Lazily-built port→hyperedge cache. The port-ID-to-index map has been eliminated: port IDs are now "nodeId:portIndex" so the index can be parsed directly from the string. Return the index of the port whose ID equals portId, or -1 if not found.

Scans elkPorts by ID — works for any ID format (address-based, sequential integers, or opaque strings from external sources).

Implementation

/// Return the index of the port whose ID equals `portId`, or -1 if not found.
///
/// Scans `elkPorts` by ID — works for any ID format (address-based,
/// sequential integers, or opaque strings from external sources).
int portIndexById(String portId) =>
    elkPorts.indexWhere((p) => p.id == portId);