How to Connect multiple runtime generated graphs

Hi there, Completely new here, just started using A*. It seems like a great toolset. However, i have searched far and wide for exact instructions on how to accomplish connecting runtime generated graphs, and had no success.

I noted that there is an article here about this topic, but in both threads i could locate, there seems to be key code missing that left me in the dark. For eg: in the following snippet… GetGraphAtChunk()… Im assuming this is a custom method, as i could not locate the method myself.

Im really struggling to make this work, as its one of the last things i need to complete. But alas, no success at all.

 void AddGridGraph(int chunkX, int chunkZ) {
     // z = 0
     for (int x = 0; x < graph.width; x++) {
          var node = graph.GetNode(x, 0);
          var adjacentGraph = GetGraphAtChunk(chunkX, chunkZ-1);
          var adjacentNode = adjacentGraph.GetNode(x, adjacentGraph.depth - 1);
          var cost = (adjacentNode.position - node.position).CostMagnitude;
          node.AddConnection(adjacentNode, cost);
          adjacentNode.AddConnection(node, cost);
     // Similar code for the 4 other edges of the graph

On topic, I have several very small graphs (5 x 5 nodes each), that i need to connect after they have been generated at runtime. But yes, i have no clue what to do at this point. Any help would be so great, so so great. ty.


I would strongly recommend using a single large grid graph and just updating that. It will be much more efficient and more convenient than having many small 5x5 graphs.

There’s no method called GetGraphAtChunk in the package, I’m not sure where you got that method from.

That method is from a code snippet you posted… i just quoted it… right here in these forums. Ofc it doesnt exist, i mentioned that above, hence why i am so lost trying to figure out how to do this.

In fact, is from your post in the other thread you replied to me in.

Ah, sorry. Yeah that was some pseudocode I wrote there.
Essentially, assume you have an NxN grid of grids. Call each grid graph a chunk. That method is a stand-in for a method that would return the grid graph at the given (x,y) chunk coordinate. So the first graph would have chunk coordinates (0,0) and the last one would be (N,N).