Sign in to follow this  
KnTenshi

Looking for Architecture help.

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this