// Extra visual panels for the CDE playground. // // Replaces the old DGAC LossBreakdown / HomophilyDial / ConfidenceBars / etc. // with CDE-specific result visualisations: // // • CDETrainingDynamics — ACC vs time t for both GRAND and CDE branches // • CDEBenchmarkTable — paper Table 2 highlights (real numbers) // • CDEFigure1 — interactive reproduction of Figure 1 // (ACC vs h_edge on synthetic graphs) // • LossBreakdown — composes the above; kept as window export // for app.jsx compatibility const { useState: useStateX, useEffect: useEffectX, useMemo: useMemoX } = React; // Inline KaTeX for HTML — light wrapper so we can mix LaTeX into prose. function InlineKatex({ tex, style, displayMode=false }) { const ref = React.useRef(null); React.useEffect(() => { if (!ref.current) return; if (!window.katex) { ref.current.textContent = tex; return; } try { window.katex.render(tex, ref.current, { throwOnError: false, displayMode, strict: "ignore", }); } catch (e) { if (ref.current) ref.current.textContent = tex; } }, [tex, displayMode]); return ; } // ============================================================ // CDE Dataset Table — paper Table 1 statistics for the 9 heterophilic // benchmarks. Sorted by h_adj (most heterophilic first); highlights the // 3 datasets where paper line 845-846 claims CDE-GRAND best. // All numbers from paper line 460-544 + Sec. 5.2. // ============================================================ function CDEDatasetTable({ active }) { const T1 = [ { name:"Roman-empire", N:22662, E:32927, C:18, r:300, hedge:0.05, hadj:-0.05, sota:true }, { name:"Wiki-cooc", N:10000, E:2243042, C:5, r:100, hedge:0.34, hadj:-0.03, sota:true }, { name:"Minesweeper", N:10000, E:39402, C:2, r:7, hedge:0.68, hadj: 0.01, sota:true }, { name:"Questions", N:48921, E:153540, C:2, r:301, hedge:0.84, hadj: 0.02, sota:false }, { name:"Texas", N:183, E:295, C:5, r:1703, hedge:0.11, hadj: 0.04, sota:false }, { name:"Cornell", N:183, E:280, C:5, r:1703, hedge:0.30, hadj: 0.04, sota:false }, { name:"Wisconsin", N:251, E:466, C:5, r:1703, hedge:0.21, hadj: 0.07, sota:false }, { name:"Workers", N:11758, E:519000, C:2, r:10, hedge:0.59, hadj: 0.09, sota:false }, { name:"Amazon-ratings", N:24492, E:93050, C:5, r:300, hedge:0.38, hadj: 0.14, sota:false }, ]; // h_adj color: -0.05 (most hetero) red → 0.14 (least) green const hadjColor = h => { const t = Math.max(0, Math.min(1, (h - (-0.05)) / (0.14 - (-0.05)))); const hue = 30 + t * 120; return `oklch(0.55 ${0.18 - t*0.05} ${hue})`; }; const fmt = n => n >= 10000 ? n.toLocaleString() : n.toString(); return (
论文 Table 1 · 9 个 HETEROPHILIC BENCHMARKS Sec. 5.2 · line 460-544
升序排(最异质 → 最同质)· = paper line 845-846 明确 CDE-GRAND best 的 3 个最异质数据集
{T1.map(d => ( ))}
Dataset
{d.sota && } {d.name} {d.hadj > 0 ? `+${d.hadj.toFixed(2)}` : d.hadj.toFixed(2)} {d.hedge.toFixed(2)} {fmt(d.N)} {fmt(d.E)} {d.C} {fmt(d.r)}
train/val/test = 50/25/25(Platonov et al. 2023 fixed splits, paper line 442)· Wiki-cooc 边数 2.24M 但 ,验证 CDE 抗高密度异质边 · Texas/Cornell/Wisconsin 仅 ~200 节点(WebKB), 高维特征 → 不同 regime · Minesweeper/Workers/Questions 是 binary class,paper 用 ROC-AUC 评估(line 443-445)。
); } // ============================================================ // CDE Training Dynamics — paper Table 3 (integration-time ablation) // + paper Table 2 (per-benchmark CDE-GRAND vs GRAND ACC). // All numbers are real paper data; replaces the previous toy ACC plot // (which decayed too steeply due to fixed centroids + no source term — // not paper behaviour, see AlphaBetaResidual chip). // ============================================================ function CDETrainingDynamics({ cde, tIdx, active }) { const C_ROMAN = "oklch(0.45 0.18 250)"; const C_MINE = "oklch(0.42 0.20 320)"; // Paper Table 3 — integration-time ablation on CDE-GRAND. // Sec. 5.6 (line 1107-1118) + raw numbers (paper line 870-947). // Each entry: [T, mean ACC%, std%]. τ=1 throughout. const T3 = [ { name:"Roman · Euler", color:C_ROMAN, dash:false, peakIdx:2, data:[[1.0,87.26,0.46],[2.0,91.55,0.42],[3.0,91.64,0.28],[4.0,91.62,0.34],[5.0,91.16,0.67]] }, { name:"Roman · RK4", color:C_ROMAN, dash:true, peakIdx:0, data:[[1.0,91.55,0.66],[2.0,91.10,1.16],[3.0,90.82,2.18],[4.0,91.00,1.31],[5.0,90.26,2.16]] }, { name:"Mine · Euler", color:C_MINE, dash:false, peakIdx:3, data:[[1.0,87.13,1.36],[2.0,90.46,0.66],[3.0,92.00,0.60],[4.0,93.21,0.43],[5.0,93.11,2.36]] }, { name:"Mine · RK4", color:C_MINE, dash:true, peakIdx:3, data:[[1.0,93.05,0.48],[2.0,94.64,2.32],[3.0,94.35,3.62],[4.0,97.67,0.22],[5.0,97.10,2.02]] }, ]; // Plot geometry — y axis 84% to 100% (covers 87.13 lowest .. 97.67 highest) const W = 400, H = 215, padL = 36, padR = 14, padT = 16, padB = 30; const innerW = W - padL - padR, innerH = H - padT - padB; const Y_MIN = 84, Y_MAX = 100; const xToPxT = T => padL + ((T-1)/4) * innerW; const yToPxA = a => padT + ((Y_MAX - a)/(Y_MAX - Y_MIN)) * innerH; // Paper Table 2 highlights — real CDE-GRAND vs GRAND ACC (%) per dataset const benchmark = [ { name:"Roman-empire", h:"-0.05", grand:71.60, cde:91.64, hl:true }, { name:"Wiki-cooc", h:"-0.03", grand:92.03, cde:97.99, hl:false }, { name:"Minesweeper", h:" 0.01", grand:76.67, cde:95.50, hl:true }, { name:"Texas", h:" 0.04", grand:80.27, cde:86.22, hl:false }, { name:"Wisconsin", h:" 0.07", grand:83.73, cde:87.45, hl:false }, ]; const C_GRAND = "oklch(0.55 0.13 250)"; const C_CDE = "oklch(0.45 0.20 320)"; return (
论文真实数据 · PAPER TABLE 3 + TABLE 2 Sec. 5.6 · Sec. 5.2
{/* LEFT — Paper Table 3 · ACC vs T (integration time ablation) */}
Table 3 · CDE-GRAND ACC vs 积分时间 ,10 random seed 平均 ± std)
{/* y-axis gridlines + ticks (every 4%) */} {[84, 88, 92, 96, 100].map(a => ( {a} ))} {/* x-axis ticks T = 1..5 */} {[1,2,3,4,5].map(T => ( {T.toFixed(1)} ))} T (积分时间) ACC % {/* 4 series — error bars + line + dots + peak markers */} {T3.map((s) => { const path = s.data.map(([T,m], i) => `${i===0?"M":"L"}${xToPxT(T).toFixed(1)},${yToPxA(m).toFixed(1)}` ).join(" "); return ( {/* error bars (mean ± std) */} {s.data.map(([T,m,std]) => ( ))} {/* line */} {/* dots; peak slightly larger with white halo */} {s.data.map(([T,m], i) => ( ))} {/* peak ★ above peak point */} {s.peakIdx >= 0 && ( )} ); })} {/* legend (top-right corner) */} Roman RK4 Mine RK4
★ peak · paper 文字仅描述「improves to saturation point」(line 1112-1118), 未描述过饱和后大幅下降,T=5 较峰值仅微降
{/* RIGHT — Paper Table 2 highlights */}
论文 Table 2 · CDE-GRAND vs GRAND 在异质 benchmark 上的真实数字
{benchmark.map(b => { const delta = b.cde - b.grand; return ( ); })}
数据集 GRAND CDE-GRAND Δ
{b.name} {b.h} {b.grand.toFixed(2)} {b.cde.toFixed(2)} 10 ? "oklch(0.40 0.20 30)" : "oklch(0.45 0.15 150)"}} className="mono"> {b.hl && "★ "}+{delta.toFixed(1)}
越低(异质性越强),CDE 改进越大。 Roman-empire 是最异质的(−0.05),CDE-GRAND +20pp
); } // ============================================================ // CDE Figure 1 reproduction — ACC vs edge-homophily curve. // Sweeps h ∈ [0.1, 0.9] on synthetic graphs, runs both GRAND and // CDE for each h. Crossover at h<0.5 in the paper. // ============================================================ function CDEFigure1({ tweaks, active }) { const hs = useMemoX(() => Array.from({length:9}, (_,i) => 0.1 + i*0.1), []); const result = useMemoX(() => { const N = 20, K = 4; const buildGraph = (h, seed) => { const rng = (() => { let s = seed>>>0||1; return () => { s = (Math.imul(s,1664525)+1013904223)>>>0; return s/4294967296; }; })(); const nodes = []; for (let c=0; c { if (a===b) return; const k = a ((sameClu === (n.cluster===nodes[i].cluster)) && id!==i) ? id : -1) .filter(x => x>=0); if (!pool.length) continue; const j = pool[Math.floor(rng()*pool.length)]; addE(i, j); } } return { nodes, edges }; }; const accG = [], accC = []; for (const h of hs) { let aG = 0, aC = 0, used = 0; for (let trial=0; trial<3; trial++) { const G = buildGraph(h, 0xC0FFEE + trial*7); if (!G.edges.length) continue; const r = window.CDE_MATH.runCDE(G, { rDim: 8, K: 4, T: 2.5, tau: 0.25, kappa: 0.5, w0: tweaks.beta * 0.15, seed: 33 + trial, }); aG += r.accGrand[r.accGrand.length-1]; aC += r.accCDE[r.accCDE.length-1]; used++; } accG.push(used ? aG/used : 0); accC.push(used ? aC/used : 0); } return { accG, accC }; }, [hs, tweaks.beta]); const W = 800, H = 200, padL = 42, padR = 16, padT = 14, padB = 30; const innerW = W - padL - padR, innerH = H - padT - padB; const xToPx = h => padL + ((h-0.1)/0.8) * innerW; const yToPx = a => padT + (1-a)*innerH; const pathOf = arr => arr.map((a,i) => `${i===0?"M":"L"}${xToPx(hs[i]).toFixed(1)},${yToPx(a).toFixed(1)}` ).join(" "); const C_GRAND = "oklch(0.55 0.13 250)"; const C_CDE = "oklch(0.45 0.20 320)"; return (
论文 Figure 1 复现 · ACC vs synth graphs · 3 seed avg
在合成图上调控边同质率 。 论文 Figure 1 显示 CDE 在 区段碾压 GRAND/GCN/ACM-GCN 以下是用 playground 的 toy ODE 在浏览器里实算的版本。 · 调 β 滑块改变 convection 强度看曲线变化。
{/* shaded heterophilic region */} ↓ 异质区(CDE 优势) {/* gridlines */} {[0, 0.25, 0.5, 0.75, 1.0].map(a => ( {(a*100).toFixed(0)} ))} {hs.map(h => ( {h.toFixed(1)} ))} h_edge (边同质率) ACC % {/* curves */} {/* points */} {hs.map((h,i) => ( ))} {/* legend */} GRAND only CDE ★
); } // ============================================================ // LossBreakdown — kept as the export name for app.jsx compatibility. // Now actually shows training dynamics + benchmark + Figure 1. // ============================================================ function LossBreakdown({ active, tick, cde, tIdx, tweaks }) { if (!cde) { return (
初始化中…
); } return (
); } window.LossBreakdown = LossBreakdown; window.CDEDatasetTable = CDEDatasetTable; window.CDETrainingDynamics = CDETrainingDynamics; window.CDEFigure1 = CDEFigure1; window.InlineKatex = InlineKatex;