Looking for Architecture help.

This topic is 2650 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm trying to make a program that have entities traverse a node graph (I believe that's the term) in C++. Here's a simplified mock-up of the graph:

[img]http://img824.imageshack.us/img824/1585/ipatest.png[/img]

The problem I'm having is figuring out how to represent the graph in code, or atleast, the connections. I can pseudo-code it as:

A.connected(B,C,G);B.connected(A,D,G);...H.connected(C,D,G);...K.connected(E,I);

I can't see how to make this work with a 2D array, as making the connections from G and H seem impossible.
But does that mean to have the entities move around the graph, would I have the NODE class hold or reference itself? i.e.

class NODE{// other things std :: vector<NODE> connected;};

For an example of what I want to happen with this program, let's say an entity starts out at node E. It then is told to move, so it moves to node C. It is told to move again, and it moves to node H.

To restate my question: How would I represent a node graph with odd connections in C++?

Please note that this program is not looking for some goal, it is merely moving the entities around. Please trust me that it has a purpose in the final version of the program.