{"slug": "your-ai-agent-is-guessing-what-a-failure-cuts-off", "title": "Your AI Agent Is Guessing What a Failure Cuts Off", "summary": "GridMend, an LLM agent built by Anish Tejwani for FalkorDB's Graph Hacks hackathon, produced 0 unsafe switching plans across 23 simulated power-grid faults, while a language model planning alone produced unsafe plans for 20 of the 23 faults. GridMend uses FalkorDB's built-in Cypher procedures algo.WCC and algo.MSF to compute which grid sections a fault cuts off and whether a reconfiguration would close a loop. The hackathon, held October 15 to 18, 2026, with $20K in prizes, drew 7,899 developers and 1,213 projects, 320 of which named a FalkorDB algo.* procedure.", "body_md": "Graph Hacks, FalkorDB's online hackathon (October 15 to 18, 2026, $20K in prizes), drew 7,899 developers and 1,213 projects, and 320 of those projects named a FalkorDB `algo.*` procedure in their write-up. The strongest result came from a power grid. A language model planning alone made unsafe switching plans for 20 of 23 faults. GridMend, an agent that works through graph algorithms and forked copies of one FalkorDB graph, made 0. This tutorial shows the exact `CALL algo.*` queries three teams used, the question each answers for an agent, and what it returned.\n\n**Key takeaways.** An LLM guesses what a failure cuts off or how much a network can carry. Graph algorithms for AI agents compute it. FalkorDB runs algorithms as Cypher procedures, so each agent tool is one query. GridMend uses\n\n`algo.WCC` and `algo.MSF` to reach 0 unsafe grid plans. Detour uses `algo.maxFlow` to show that 17,167 of 18,432 riders an hour can still move toward Manhattan when the L train shuts. Seismo uses `algo.pageRank` to find breaking news on Wikipedia with no LLM in detection.\n**Want to run these queries yourself?** [Start free on FalkorDB Cloud](https://app.falkordb.cloud/signup?cta=cta-top), load a small network, and call your first `algo.*` procedure from the browser.\n\n## What are graph algorithms for AI agents?\n\nGraph algorithms for AI agents are procedures that compute an exact answer over a whole network, like the best route, the most it can carry, what is connected or what matters most, and return that answer to an agent as a tool result.\n\nIn FalkorDB they are built in. You write `CALL algo.<name>(...)` in Cypher, `YIELD` the results and keep filtering them in the same query. The model picks the question, and the database does the math. It's the same idea as giving [enterprise AI agents a context layer they can query](https://www.falkordb.com/reference/enterprise-ai-agents-context-layer/).\n\n## Which graph algorithm answers which agent question?\n\n| FalkorDB procedure | Question it answers for an agent | Graph Hacks example | \n|---|---|---|\n| `algo.WCC` | What does a failure cut off? | GridMend grid zones, Seismo stories | \n| `algo.MSF` | Would this change close a loop? | GridMend loop check on a fork | \n| `algo.maxFlow` | How much can the network still carry? | Detour riders an hour after a closure | \n| `algo.SPpaths` | What is the best way around the problem? | Detour reroutes stranded trips | \n| `algo.pageRank` | What is at the center of this cluster? | Seismo finds a story's epicenter | \n| `algo.betweenness` | What does everything else depend on? | IROPS Brain load-bearing flights | \n\nAnd these are the procedures named most often across all 1,213 submissions.\n\n| FalkorDB procedure | Projects that named it | \n|---|---|\n| `algo.pageRank` | 194 | \n| `algo.SPpaths` | 117 | \n| `algo.betweenness` | 111 | \n| `algo.WCC` | 81 | \n| `algo.maxFlow` | 47 | \n| Any `algo.*` procedure | 320 | \n\n## How did Graph Hacks teams use graph algorithms for AI agents in FalkorDB?\n\n### 1. algo.WCC and algo.MSF: what does a grid fault cut off?\n\n**GridMend** · Anish Tejwani · [See the code](https://github.com/anish891/gridmend) · [Use the app](https://gridmend.onrender.com) · [Blog](https://anish891.hashnode.dev/building-a-self-healing-power-grid-agent-with-falkordb)\n\nWhen a power line faults, the substation breaker trips and everyone downstream goes dark. Operators must cut out the faulted section with switches and re-feed the rest through backup ties, without closing a loop or overloading a line. Utilities call this FLISR.\n\nGridMend is an LLM agent that does FLISR on a digital twin of the feeder in one FalkorDB graph. Buses are nodes, unswitched lines are `SEG` edges and switches are `SW` edges. The agent never writes Cypher. It calls 13 tools. Its first question is \"what is the smallest section I can cut out?\" `algo.WCC` answers it over `SEG` edges only. Switches are left out, so they act as walls, and every component is a zone the switches can isolate.\n\n```\nCALL algo.WCC({nodeLabels: ['Bus'], relationshipTypes: ['SEG']})\nYIELD node, componentId\nWITH componentId, collect(node) AS nodes\nWHERE none(n IN nodes WHERE n.is_source)\nRETURN [n IN nodes | n.id] AS buses\n```\n\nBefore any switch moves, every plan runs on its own GRAPH.COPY of the live FalkorDB graph. There, `algo.MSF` builds a spanning forest over the conducting edges. Any edge the forest can't use closes a loop, and the query names it.\n\n```\nCALL algo.MSF({nodeLabels: ['Bus'], relationshipTypes: ['SEG', 'SW'],\n               weightAttribute: 'tree_weight'})\nYIELD nodes, edges\nWITH nodes, [e IN edges | e.id] AS tree\nOPTIONAL MATCH (a:Bus)-[r:SEG|SW]->(:Bus)\nWHERE a IN nodes AND NOT r.id IN tree\nRETURN size(nodes) AS energized_buses, collect(r.id) AS loop_edges\n```\n\nThe result: across all 23 single faults on the IEEE 33-bus test feeder, the agent made 0 unsafe plans and restored 85.5% of the best possible load. A language model with a text description of the feeder and no tools made unsafe plans for 20 of 23 faults.\n\n**In the builder's words.**\"Algorithms inside Cypher: WCC, MSF and maxFlow are callable directly, which replaced most of the custom graph code I expected to write.\" Anish Tejwani, GridMend\n\n**Try it.** Model the thing that can fail as one relationship type, and run `algo.WCC` without it to see what gets cut off. [Start free on FalkorDB Cloud](https://app.falkordb.cloud/signup?cta=algo-wcc).\n\n### 2. algo.maxFlow and algo.SPpaths: can the subway absorb a shutdown?\n\n**Detour** · Harsh Mishra, Saud Satopay and Parva Panchal · [See the code](https://github.com/SaudSatopay/detour) · [Use the app](https://detour-orpin.vercel.app) · [Blog](https://dev.to/saudsatopay/i-shut-down-the-l-train-in-a-graph-max-flow-min-cut-and-ai-agents-on-the-new-york-subway-40g7)\n\nWhen a subway line breaks at rush hour, a control center must answer fast. Who is stuck, where will they go, and can the rest of the network carry them? A trip planner routes one rider. This is a flow problem.\n\nDetour loads the New York City subway from MTA open data into FalkorDB, with 1,459 segments that carry capacity and 30,205 origin-destination flows. A dispatcher describes a closure in plain words, and agents pick from 13 fixed tools. For \"can the network carry them?\", the agent runs `algo.maxFlow` over spare capacity on a forked FalkorDB graph without the closed segments. The returned edge flows show which corridors are full.\n\n```\nMATCH (src:Hub {id: $src}), (snk:Hub {id: $snk})\nCALL algo.maxFlow({sourceNodes: [src], targetNodes: [snk],\n                   relationshipTypes: ['FLOW'], capacityProperty: 'spare'})\nYIELD maxFlow, edges, edgeFlows\nRETURN maxFlow,\n       [e IN edges | [e.kind, startNode(e).id, endNode(e).id]] AS es,\n       edgeFlows AS flows\n```\n\nFor \"where will they go?\", one query sends every displaced trip through `algo.SPpaths`, weighted by minutes, so waits and transfers have a price.\n\n```\nUNWIND $pairs AS p\nMATCH (a:Station {id: p.o}), (b:Station {id: p.d})\nCALL algo.SPpaths({sourceNode: a, targetNode: b,\n                   relTypes: ['BOARD', 'RIDE', 'ALIGHT', 'WALK', 'BUS'], weightProp: 'minutes'})\nYIELD path, pathWeight\nRETURN p.o AS o, p.d AS d, pathWeight AS minutes,\n       [r IN relationships(path) WHERE type(r) = 'RIDE' | r.eid] AS eids\n```\n\nThe result for closing the L between Bedford Av and 8 Av at 8 a.m.: 23,445 riders an hour are hit. On their fastest paths, the G runs at up to 244% of capacity and 4,689 riders have no path. Max flow says 17,167 of 18,432 riders an hour toward Manhattan can still get through, and the min cut points to 1 Av. A shuttle tested on a fork cuts riders with no path to 623. An independent NetworkX program matches FalkorDB's max flow for all three closures the team tested.\n\n**In the builder's words.**\"Graph algorithms are Cypher procedures, so each agent tool is a query and nothing leaves the database.\" The Detour team\n\n**Try it.** Put a capacity on every edge of a network you care about, and run `algo.maxFlow` between two points. [Start free on FalkorDB Cloud](https://app.falkordb.cloud/signup?cta=algo-maxflow).\n\n### 3. algo.WCC and algo.pageRank: is this a breaking story?\n\n**Seismo** · Divyansh Khurana · [See the code](https://github.com/divyanshkhurana06/seismo) · [Use the app](https://seismo.onrender.com) · [Blog](https://dev.to/divyanshkhurana06/i-built-a-newsroom-that-is-not-allowed-to-read-the-news-41f6)\n\nNews doesn't get written on Wikipedia. It gets edited. When something happens, strangers converge on the same few articles within minutes, and that shape shows up before any headline.\n\nSeismo streams every human edit on every Wikipedia, about two a second, into one FalkorDB graph of pages, editors and edits. Every 45 seconds, Cypher gives a temporary `:Hot` label to pages that three or more people edited in the last 20 minutes, then links hot pages that share an editor. Look at the second line of the query below. Editors who touch more than four hot pages are skipped, because on the first run one vandalism patroller glued unrelated pages into a fake story.\n\n``` php\nMATCH (u:Editor)-[:MADE]->(e:Edit)-[:ON]->(h:Hot) WHERE e.ts > $since\nWITH u, count(DISTINCT h) AS deg WHERE deg >= 2 AND deg <= $max_deg\nMATCH (a:Hot)<-[:ON]-(ea:Edit)<-[:MADE]-(u)-[:MADE]->(eb:Edit)-[:ON]->(b:Hot)\nWHERE ea.ts > $since AND eb.ts > $since AND id(a) < id(b)\nWITH a, b, count(DISTINCT u) AS shared\nCREATE (a)-[:CO_EDITED {shared: shared}]->(b)\n```\n\nNow \"which pages are one story, and where did it start?\" is two calls. `algo.WCC` groups hot pages into stories, with `SAME_AS` edges joining languages, and `algo.pageRank` picks each epicenter.\n\n```\nCALL algo.WCC({nodeLabels: ['Hot'], relationshipTypes: ['CO_EDITED', 'SAME_AS']})\nYIELD node, componentId\nRETURN node.key, componentId\n\nCALL algo.pageRank('Hot', 'CO_EDITED') YIELD node, score\nRETURN node.key, score\n```\n\nNo LLM is involved in detection. Only after FalkorDB finds a story do Claude agents claim it and write a brief, with a `CITES` edge to every revision they read. In the first live run, the crew filed a brief on an explosion at a military base in Alberta.\n\n**Try it.** Give the nodes you care about a temporary label, then run `algo.WCC` and `algo.pageRank` on just that label. [Start free on FalkorDB Cloud](https://app.falkordb.cloud/signup?cta=algo-pagerank).\n\n## Two more projects using graph algorithms for AI agents\n\n**Six algorithms in one airline recovery agent.** IROPS Brain, by Pugar Huda Mantoro, replays the December 2022 Southwest meltdown from US DOT data in FalkorDB. `algo.betweenness` finds load-bearing flights, A* finds the nearest reserve crew, and `algo.maxFlow` over free seats says how many stranded passengers the network can still carry. [Watch the demo](https://youtu.be/Ta5wwLPcX7Y).\n\n**One FalkorDB graph per football match.** GraphScout, by Parv Mittal, Aniket Chawardol and Avnish Jaltare, stores each of 51 Euro 2024 matches as its own FalkorDB graph. `algo.pageRank` and `algo.betweenness` show which players a team depends on, and each marking plan is tested on a GRAPH.COPY of the match. [Watch the demo](https://youtu.be/7s1hNXD6r6g).\n\nBuilding agents that also need to remember what they learn? Read [5 agent memory patterns from 647 Graph Hacks projects](https://www.falkordb.com/blog/ai-agent-memory-graph-patterns/).\n\nMore algorithms at work: `algo.maxFlow` picks the cheapest way to cut off a poisoned agent in [how Graph Hacks teams secured AI agents](https://www.falkordb.com/blog/ai-agent-security-graph/), and five FalkorDB algorithms run a live conference graph in [what 647 developers built at Patch the Conference](https://www.falkordb.com/blog/conference-knowledge-graph-hackathon/).\n\n## Frequently asked questions\n\n### What graph algorithms for AI agents does FalkorDB support?\n\nFalkorDB has built-in procedures for BFS, shortest paths (`algo.SPpaths` and `algo.SSpaths`), A*, minimum spanning forest (` algo.MSF`), PageRank, betweenness and harmonic centrality, weakly connected components (`algo.WCC`), community detection with label propagation, and max flow (`algo.maxFlow`). [Start free on FalkorDB Cloud](https://app.falkordb.cloud/signup?cta=cta-bottom) to try every option.\n\n### How do you call a graph algorithm from Cypher in FalkorDB?\n\nUse `CALL algo.<name>` with a config map, then `YIELD` the fields you need. For example, `CALL algo.WCC({nodeLabels: ['Bus'], relationshipTypes: ['SEG']}) YIELD node, componentId` returns every node with its component. PageRank takes a label and a relationship type as two arguments instead: `CALL algo.pageRank('Hot', 'CO_EDITED') YIELD node, score`.\n\n### Why should an AI agent call a graph algorithm instead of reasoning on its own?\n\nA language model can only estimate what a failure cuts off or how much a network can carry. A graph algorithm computes the exact answer. In the GridMend test on 23 power-grid faults, a language model planning alone made 20 unsafe plans, while the agent working through FalkorDB graph algorithms made 0.\n\n### How do you run a graph algorithm on only part of a graph?\n\nPass `nodeLabels` and `relationshipTypes` in the config map. Graph Hacks teams used two more patterns on FalkorDB. Seismo adds a temporary label, runs the algorithm on it, then removes it. GridMend and Detour run algorithms on a GRAPH.COPY of the graph, so the live data never changes.\n\n## Let the database do the math\n\nEvery algorithm in this post runs on the same FalkorDB you can start with one Docker command, `docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:latest`, or a free cloud instance. Load a network your agent already reasons about, and replace one guess with one `CALL algo.*` query.\n\n[Start free on FalkorDB Cloud](https://app.falkordb.cloud/signup?cta=cta-bottom)\n\nNot ready to build yet? [Join the FalkorDB Discord](https://discord.gg/Y2mMT9VdMy) to get help from our engineers, share what you build, and hear about the next Graph Hacks first.", "url": "https://wpnews.pro/news/your-ai-agent-is-guessing-what-a-failure-cuts-off", "canonical_source": "https://www.falkordb.com/blog/graph-algorithms-for-ai-agents/", "published_at": "2026-11-16 17:00:00+00:00", "updated_at": "2026-11-16 17:20:48.743294+00:00", "lang": "en", "topics": ["ai-agents", "artificial-intelligence", "large-language-models", "ai-tools"], "entities": ["FalkorDB", "Graph Hacks", "GridMend", "Anish Tejwani", "Detour", "Seismo", "IROPS Brain"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/your-ai-agent-is-guessing-what-a-failure-cuts-off", "markdown": "https://wpnews.pro/news/your-ai-agent-is-guessing-what-a-failure-cuts-off.md", "text": "https://wpnews.pro/news/your-ai-agent-is-guessing-what-a-failure-cuts-off.txt", "jsonld": "https://wpnews.pro/news/your-ai-agent-is-guessing-what-a-failure-cuts-off.jsonld"}}