hasConnectionsForNode method

bool hasConnectionsForNode(
  1. String nodeId
)

Checks if a node has any connections (as source or target).

This is an O(1) operation using the internal connection index. Use this instead of getConnectionsForNode(nodeId).isNotEmpty for better performance.

Example:

if (controller.hasConnectionsForNode('node1')) {
  print('Node has connections');
}

Implementation

bool hasConnectionsForNode(String nodeId) {
  final connectionIds = _connectionsByNodeId[nodeId];
  return connectionIds != null && connectionIds.isNotEmpty;
}