/**
   * Groups nodes with their connected north/south segments to keep them at the correct position
   * relative to each other.
   */
  private void groupCNodes() {
    // resetting groups from previous compaction
    cGraph.cGroups.clear();
    // necessary because of the exception in CGroup.addCNode
    for (CNode cNode : cGraph.cNodes) {
      cNode.cGroup = null;
    }

    // creating groups for independent CNodes
    for (CNode cNode : cGraph.cNodes) {
      if (cNode.parentNode == null) {
        cGraph.cGroups.add(new CGroup(cNode));
      }
    }

    // adding CNodes of north/south segments to the same group as their parent nodes
    for (CNode cNode : cGraph.cNodes) {
      if (cNode.parentNode != null) {
        cNode.parentNode.cGroup.addCNode(cNode);
      }
    }
  }
 /**
  * Applies the compacted positions to the {@link LGraphElement}s represented by {@link CNode}s.
  */
 private void applyNodePositions() {
   for (CNode cNode : cGraph.cNodes) {
     cNode.applyElementPosition();
   }
 }