1import{r as m,j as e}from"./react-core-SaLnwSRd.js";import{R as E}from"./rotate-ccw-DXvLKzyc.js";import{N as D}from"./network-C0UO2SNo.js";import{k as _}from"./index-CRJ-gAjQ.js";const o=["A","B","C","D","E","F"],W=({theme:$})=>{const[n,j]=m.useState(4),[x,u]=m.useState(!1),[i,N]=m.useState(2),[c,f]=m.useState([[0,1,1,0,0,0],[1,0,1,1,0,0],[1,1,0,1,0,0],[0,1,1,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]]),w=(a,t)=>{const s=c.map(d=>[...d]),r=s[a][t]===1?0:1;s[a][t]=r,x||(s[t][a]=r),f(s)},y=(a,t,s)=>{const l=Array(s).fill(0).map(()=>Array(s).fill(0));for(let r=0;r<s;r++)for(let d=0;d<s;d++){let g=0;for(let h=0;h<s;h++)g+=a[r][h]*t[h][d];l[r][d]=g}return l},k=()=>{const a=Array(n).fill(0).map(()=>Array(n).fill(0));for(let t=0;t<n;t++){let s=0;for(let l=0;l<n;l++)s+=c[t][l];a[t][t]=s}return a},v=a=>{const t=Array(n).fill(0).map(()=>Array(n).fill(0));for(let s=0;s<n;s++)for(let l=0;l<n;l++)t[s][l]=a[s][l]-c[s][l];return t},A=a=>{const t=Math.max(1,Math.min(6,a));let s=c.slice(0,n).map(r=>r.slice(0,n)),l=c.slice(0,n).map(r=>r.slice(0,n));for(let r=2;r<=t;r++)s=y(s,l,n);return s},M=(()=>{const a=[];let t=1;for(let s=0;s<n;s++){const l=x?0:s+1;for(let r=l;r<n;r++)c[s][r]===1&&a.push({from:s,to:r,id:`e${t++} (${o[s]}-${o[r]})`})}return a})(),b=k(),C=v(b),L=A(i),p=a=>{const t=a/n*2*Math.PI-Math.PI/2,s=100,l=100,r=70;return{x:s+r*Math.cos(t),y:l+r*Math.sin(t)}};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"p-4 rounded-2xl bg-slate-100 dark:bg-slate-800/80 border border-slate-200 dark:border-slate-700 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-slate-700 dark:text-slate-300",children:"Vertices (Nodes):"}),e.jsx("div",{className:"flex gap-1",children:[3,4,5,6].map(a=>e.jsx("button",{onClick:()=>j(a),className:`w-7 h-7 rounded-lg text-xs font-bold transition-all ${n===a?"bg-blue-600 text-white":"bg-white dark:bg-slate-900 text-slate-700 dark:text-slate-300 border border-slate-200 dark:border-slate-700"}`,children:a},a))})]}),e.jsx("div",{className:"flex items-center gap-2 pl-3 border-l border-slate-300 dark:border-slate-700",children:e.jsxs("label",{className:"text-xs font-semibold text-slate-700 dark:text-slate-300 flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:a=>u(a.target.checked),className:"w-4 h-4 text-blue-600 rounded"}),e.jsx("span",{children:"Directed Graph (Digraph)"})]})})]}),e.jsxs("button",{onClick:()=>{const a=Array(6).fill(0).map(()=>Array(6).fill(0));f(a)},className:"text-xs text-slate-500 hover:text-red-500 flex items-center gap-1",children:[e.jsx(E,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Clear All Edges"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8 items-start",children:[e.jsxs("div",{className:"lg:col-span-5 space-y-6",children:[e.jsxs("div",{className:"p-6 bg-white dark:bg-slate-900 rounded-2xl border border-slate-200 dark:border-slate-800 flex flex-col items-center justify-center space-y-4",children:[e.jsxs("div",{className:"w-full flex items-center justify-between",children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wider text-slate-500 flex items-center gap-1.5",children:[e.jsx(D,{className:"w-3.5 h-3.5 text-blue-600"}),e.jsx("span",{children:"Interactive Graph Topology"})]}),e.jsxs("span",{className:"text-xs font-mono text-slate-400",children:[M.length," Edges / ",n," Vertices"]})]}),e.jsx("div",{className:"w-64 h-64 relative bg-slate-50 dark:bg-slate-800/40 rounded-2xl border border-slate-100 dark:border-slate-800 p-2",children:e.jsxs("svg",{viewBox:"0 0 200 200",className:"w-full h-full",children:[Array.from({length:n}).map((a,t)=>Array.from({length:n}).map((s,l)=>{if(c[t][l]===1&&(x||t<=l)){const r=p(t),d=p(l);return e.jsx("line",{x1:r.x,y1:r.y,x2:d.x,y2:d.y,stroke:"#3b82f6",strokeWidth:"2.5",strokeOpacity:"0.8"},`edge-${t}-${l}`)}return null})),Array.from({length:n}).map((a,t)=>{const s=p(t);return e.jsxs("g",{children:[e.jsx("circle",{cx:s.x,cy:s.y,r:"15",fill:"#1e293b",stroke:"#3b82f6",strokeWidth:"2"}),e.jsx("text",{x:s.x,y:s.y+4,textAnchor:"middle",fill:"white",fontSize:"12",fontWeight:"bold",fontFamily:"monospace",children:o[t]})]},`node-${t}`)})]})}),e.jsx("div",{className:"text-[11px] text-slate-500 text-center",children:"Click cells in the Adjacency Matr
1ix below to connect or disconnect edges."})]}),e.jsxs("div",{className:"p-5 bg-white dark:bg-slate-900 rounded-2xl border border-slate-200 dark:border-slate-800 space-y-3",children:[e.jsx("h4",{className:"font-bold text-xs uppercase tracking-wider text-slate-700 dark:text-slate-300",children:"Adjacency Matrix (A) Editor"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-center text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-1.5 text-slate-400"}),Array.from({length:n}).map((a,t)=>e.jsx("th",{className:"p-1.5 font-bold text-blue-600",children:o[t]},t))]})}),e.jsx("tbody",{children:Array.from({length:n}).map((a,t)=>e.jsxs("tr",{children:[e.jsx("td",{className:"p-1.5 font-bold text-blue-600",children:o[t]}),Array.from({length:n}).map((s,l)=>e.jsx("td",{className:"p-1",children:e.jsx("button",{onClick:()=>w(t,l),className:`w-7 h-7 rounded-md font-bold transition-colors ${c[t][l]===1?"bg-blue-600 text-white shadow-sm":"bg-slate-100 dark:bg-slate-800 text-slate-400 hover:bg-slate-200"}`,children:c[t][l]})},l))]},t))})]})})]})]}),e.jsxs("div",{className:"lg:col-span-7 space-y-6",children:[e.jsxs("div",{className:"p-6 rounded-2xl bg-gradient-to-br from-slate-900 to-indigo-950 text-white shadow-xl space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-bold uppercase tracking-widest text-indigo-300 flex items-center gap-1.5",children:[e.jsx(_,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Matrix Power A^",i," (Walk Counts)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-slate-300 font-mono",children:"Power k ="}),e.jsxs("select",{value:i,onChange:a=>
1N(parseInt(a.target.value)||2),className:"px-2 py-0.5 rounded-lg bg-white/10 text-white border border-white/20 text-xs font-mono",children:[e.jsx("option",{value:2,className:"text-slate-900",children:"A² (Length 2)"}),e.jsx("option",{value:3,className:"text-slate-900",children:"A³ (Length 3)"}),e.jsx("option",{value:4,className:"text-slate-900",children:"Aⴠ(Length 4)"}),e.jsx("option",{value:5,className:"text-slate-900",children:"Aⵠ(Length 5)"})]})]})]}),e.jsxs("p",{className:"text-xs text-slate-300 leading-relaxed font-light",children:["Each entry ",e.jsxs("code",{className:"font-mono text-amber-300",children:["(A^",i,")[i, j]"]})," indicates the exact number of distinct paths/walks of length ",i," between vertex ",e.jsx("em",{children:"v_i"})," and vertex ",e.jsx("em",{children:"v_j"}),"."]}),e.jsx("div",{className:"overflow-x-auto p-3 bg-slate-950/70 rounded-xl border border-white/10",children:e.jsxs("table",{className:"w-full text-center text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-1 text-slate-500"}),Array.from({length:n}).map((a,t)=>e.jsx("th",{className:"p-1 text-indigo-300 font-bold",children:o[t]},t))]})}),e.jsx("tbody",{children:L.map((a,t)=>e.jsxs("tr",{children:[e.jsx("td",{className:"p-1 text-indigo-300 font-bold",children:o[t]}),a.map((s,l)=>e.jsx("td",{className:"p-1 font-bold text-white",children:s},l))]},t))})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-5 bg-white dark:bg-slate-900 rounded-2xl border border-slate-200 dark:border-slate-800 space-y-3",children:[e.jsxs("h4",{className:"font-bold text-xs uppercase tracking-wider text-slate-700 dark:text-slate-300 flex items-center justify-between",children:[e.jsx("span",{children:"Degree Matrix (D)"}),e.jsx("span",{className:"text-[10px] text-slate-400 font-normal",children:"D[i,i] = deg(v_i)"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"w-full text-center text-xs font-mono",children:e.jsx("tbody",{children:b.map((a,t)=>e.jsxs("tr",{children:[e.jsx("td",{className:"p-1 text-slate-400 font-bold",children:o[t]}),a.map((s,l)=>e.jsx("td",{className:`p-1 ${t===l?"font-bold text-blue-600 dark:text-blue-400":"text-slate-300 dark:text-slate-600"}`,children:s},l))]},t))})})})]}),e.jsxs("div",{className:"p-5 bg-white dark:bg-slate-900 rounded-2xl border border-slate-200 dark:border-slate-800 space-y-3",children:[e.jsxs("h4",{className:"font-bold text-xs uppercase tracking-wider text-slate-700 dark:text-slate-300 flex items-center justify-between",children:[e.jsx("span",{children:"Laplacian Matrix (L)"}),e.jsx("span",{className:"text-[10px] text-slate-400 font-normal",children:"L = D - A"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx("table",{className:"w-full text-center text-xs font-mono",children:e.jsx("tbody",{children:C.map((a,t)=>e.jsxs("tr",{children:[e.jsx("td",{className:"p-1 text-slate-400 font-bold",children:o[t]}),a.map((s,l)=>e.jsx("td",{className:`p-1 font-bold ${s>0?"text-blue-600 dark:text-blue-400":s<0?"text-red-500":"text-slate-400"}`,children:s},l))]},t))})})})]})]})]})]})]})};export{W as GraphMatrixCalculator};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.