public boolean remove_if_cycle(BrdTracep p_trace){
  if (!p_trace.is_on_the_board())   return false;
  if (!p_trace.has_cycle())   return false;
  int curr_layer=p_trace.get_layer();
  PlaPoint[] end_corners=new PlaPoint[2];
  end_corners[0]=p_trace.corner_first();
  end_corners[1]=p_trace.corner_last();
  boolean[] tail_at_endpoint_before=new boolean[2];
  for (int index=0; index < 2; ++index) {
    BrdTracep tail=get_trace_tail(end_corners[index],curr_layer,p_trace.net_nos);
    tail_at_endpoint_before[index]=(tail != null);
  }
  Set<BrdItem> connection_items=p_trace.get_connection_items();
  remove_items_unfixed(connection_items);
  for (int index=0; index < 2; ++index) {
    if (tail_at_endpoint_before[index])     continue;
    BrdTracep tail=get_trace_tail(end_corners[index],curr_layer,p_trace.net_nos);
    if (tail == null)     continue;
    remove_items_unfixed(tail.get_connection_items());
  }
  return true;
}

public boolean remove_if_cycle ( BrdTracep p_trace ) { if ( ! p_trace . is_on_the_board ( ) ) return false ; if ( ! p_trace . has_cycle ( ) ) return false ; int curr_layer = p_trace . get_layer ( ) ; PlaPoint [ ] end_corners = new PlaPoint [ 2 ] ; end_corners [ 0 ] = p_trace . corner_first ( ) ; end_corners [ 1 ] = p_trace . corner_last ( ) ; boolean [ ] tail_at_endpoint_before = new boolean [ 2 ] ; for ( int index = 0 ; index < 2 ; ++ index ) { BrdTracep tail = get_trace_tail ( end_corners [ index ] , curr_layer , p_trace . net_nos ) ; tail_at_endpoint_before [ index ] = ( tail != null ) ; } Set < BrdItem > connection_items = p_trace . get_connection_items ( ) ; remove_items_unfixed ( connection_items ) ; for ( int index = 0 ; index < 2 ; ++ index ) { if ( tail_at_endpoint_before [ index ] ) continue ; BrdTracep tail = get_trace_tail ( end_corners [ index ] , curr_layer , p_trace . net_nos ) ; if ( tail == null ) continue ; remove_items_unfixed ( tail . get_connection_items ( ) ) ; } return true ; }
checks , if p_trace is part of a cycle and remove it together with its connection in this case .
