Core Function Analysis
1. Directional Check Function
def is_direct_connection(start, end, tolerance=1):
dx = abs(end[0] - start[0])
dy = abs(end[1] - start[1])
- Calculates absolute differences in X and Y coordinates
- Uses 1-unit tolerance for minor deviations
- Returns direction (‘X’, ‘Y’, or None)
2. Selection Logic
if dx > tolerance and dy <= tolerance:
return 'X'
elif dy > tolerance and dx <= tolerance:
return 'Y'
else:
return None
- X-direction: Significant X difference, minimal Y difference
- Y-direction: Significant Y difference, minimal X difference
- Diagonal/Other: Neither cond