Skip to content

Partition Graph Integer Allocator

The visual partition graph represents disk slices whose capacities range from single megabytes to multiple terabytes. Standard floating-point flex layouts suffer from sub-pixel rounding errors and layout overflows. fparted implements a pure integer largest-remainder apportionment allocator.


🧮 Allocator Invariants

  1. Exact Width Sum Invariant: $$\sum_{i=1}^{N} \text{width}_i + \text{gaps} + \text{padding} = \text{boundaryWidth}$$ The sum of all segment widths and gaps matches the bounding box down to the exact pixel.
  2. Zero Layout Overflow: Under no constraint or device width does the graph exceed its parent boundary.
  3. Pure Function: allocatePartitionGraphWidths() is a pure, side-effect-free function tested against extreme pathological cases (1-byte partition on 100TB disk, 1000 tiny partitions on a 320px screen).
  4. Feasible Minimums: Enforces a minimum visual width (default 8px) so tiny partitions remain clickable, gracefully scaling down if total segments exceed available pixels.

📐 Largest-Remainder Apportionment (Hare-Niemeyer)

flowchart TD
    A[Compute Drawable Width: boundary - padding - gaps] --> B[Calculate Normalized Quotas: weight / totalWeight * drawableWidth]
    B --> C[Assign Integer Floors: floor quota]
    C --> D[Compute Remainder Fractional Parts: quota - floor]
    D --> E[Sort Indices by Descending Remainder]
    E --> F[Distribute Remaining Pixels +1 to Highest Remainders]
    F --> G[Final Exact-Width Allocation]

Visual Free Space Clamping

Filesystem used/free ratios inside each partition segment are clamped to $[0.0, 1.0]$. Text labels are measured before rendering and automatically hidden if the allocated segment width is insufficient, preventing nested negative layout constraints.