portHyperedgeIndex property

Map<int, List<LayoutHyperedge>> get portHyperedgeIndex

Returns the port→hyperedge index for this node, building it on first access.

Implementation

Map<int, List<LayoutHyperedge>> get portHyperedgeIndex {
  if (_portHyperedgeIndex != null) {
    return _portHyperedgeIndex!;
  }
  final idx = <int, List<LayoutHyperedge>>{};
  final hes = hyperedges;
  if (hes != null) {
    for (final h in hes) {
      for (final (nId, pIdx) in h.sources) {
        if (nId == id) {
          (idx[pIdx] ??= []).add(h);
        }
      }
      for (final (nId, pIdx) in h.targets) {
        if (nId == id) {
          (idx[pIdx] ??= []).add(h);
        }
      }
    }
  }
  _portHyperedgeIndex = idx;
  return idx;
}