graph TD subgraph "Generic (Hash-map)" A1["node u"] -->|"hash lookup πΈ"| B1["neighbors map"] B1 -->|"hash lookup πΈ"| C1["edge w_uv"] end subgraph "CSR" A2["offsets[u]"] -->|"direct index β "| B2["targets[e]"] B2 -->|"direct index β "| C2["weights[e]"] end style A1 fill:#fce4ec,stroke:#f44336 style B1 fill:#fce4ec,stroke:#f44336 style C1 fill:#fce4ec,stroke:#f44336 style A2 fill:#e3f2fd,stroke:#2196f3 style B2 fill:#e3f2fd,stroke:#2196f3 style C2 fill:#e3f2fd,stroke:#2196f3
graph TD subgraph "Node 0" O0["offsets[0]=0"] end subgraph "Node 1" O1["offsets[1]=2"] end subgraph "Node 2" O2["offsets[2]=4"] end subgraph "Targets" T["[1, 2, 0, 2, 0, 1]"] end subgraph "Weights" W["[10, 20, 30, 40, 50, 60]"] end O0 -.->|"edges 0-1"| T O1 -.->|"edges 2-3"| T O2 -.->|"edges 4-5"| T style O0 fill:#e3f2fd style O1 fill:#e3f2fd style O2 fill:#e3f2fd style T fill:#f3e5f5 style W fill:#f3e5f5
graph LR reset["Reset\npredecessor map"] --> relax["Relax all edges\nO(E)"] relax --> changed{"Changed?"} changed -->|"Yes"| cycle["Find cycle in\npredecessor graph\nO(V)"] changed -->|"No"| done["Return\nfound > 0"] cycle --> neg{"Negative?"} neg -->|"Yes"| yield["Yield cycle\nvia callback"] neg -->|"No"| relax yield --> relax style reset fill:#fce4ec style relax fill:#e3f2fd style changed fill:#f9e79f style cycle fill:#e3f2fd style neg fill:#f9e79f style yield fill:#d5f5e3 style done fill:#a9cce3
graph LR 0 -->|"-5"| 1 1 -->|"-5"| 2 2 -->|"-5"| 0 0 -->|"w_01"| 1 0 -->|"w_02"| 2 0 -->|"w_03"| 3 1 -->|"w_12"| 2 1 -->|"w_13"| 3 1 -->|"w_14"| 4 2 -->|"w_23"| 3 2 -->|"w_24"| 4 2 -->|"w_25"| 5 style 0 fill:#f44336 style 1 fill:#f44336 style 2 fill:#f44336
graph TD subgraph "CSR Memory Layout" M1["[wβ wβ wβ ... wβ] βββΆ sequential scan"] end subgraph "Hash-map Memory Layout" M2["[wβ ββββ wβ ββ wβ ...] βββΆ random access"] end style M1 fill:#e3f2fd,stroke:#2196f3 style M2 fill:#fce4ec,stroke:#f44336
graph TD subgraph "Future Architecture" A["CSR Graph\n(fast paths)"] --> B["Howard's\nAlgorithm"] C["Hash Index\n(mutation)"] -.->|"rebuild"| A end style A fill:#e3f2fd,stroke:#2196f3 style B fill:#d5f5e3,stroke:#27ae60 style C fill:#fce4ec,stroke:#f44336