mesh structure

I am trying to create a mesh topology. I feel like the code I wrote is not what I was hoping to create. It's more of a logical mesh, its too linear with linked list to hold the pointers to class objects. What I am hoping for is:

http://sing.stanford.edu/gnawali/ctp/vinelab/topolog/topo.gif

What I have is this, there is more coding in my cpp but nothing that needs to be shown.

Does anyone have a suggestion, I feel that I am implementing the connections incorrectly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <string>

using namespace std;

enum enumNodeType
{ 
	input
};

class Node
{	
	public:	
			Node();
			Node(string,int);
			bool nodeExist(string);
			int displayNodeType();
			~Node();
	private:
			string logicalName;
			int nodeType;
};

class Connection
{	
	public:	
			Connection();
			Connection(string,int);
			bool connectionExist(string);
			int displayconnectionWeight();
			~Connection();
	private:
			Node *from;
			Node *to;
};


class Mesh
{
	public:
			Mesh();
			void display();
			~Mesh();

			struct node
			{ 
				string logicalName;
				Node *ptr;
				node*nxt;
			}*nodeStartPtr;

			struct connection
			{ 
				Connection *ptr;
				connection *nxt;
			}*connectionStartPtr;

	protected:
			// create instance of node class 
			// and add it to linked list
			void createNode(string logicalName);

			bool connect(Node* from, Node* to);
			bool connect(Node* from, Node* to, double weight);

};
¿Do you want a graph class? ¿or do you actually care about the faces?

By instance you could represent a graph with an adjacency matrix or with a list of neighbours
Thank you for the response ne555 but, no I do not care about the faces or a graph :) I have been running into a lot of those while searching for a mesh structure. It doesn't have to be anything graphical! Though I was hoping for something that was less linear!

I basically want a structure that's data can be held in a mesh like this:

http://sing.stanford.edu/gnawali/ctp/vinelab/topolog/topo.gif

Basically if you can achieve a mesh structure like in the picture above you can connect the nodes any which way you want. Right now my code can do that, but my "connections" seem too linear! I was hoping for some suggestions :P!
http://en.wikipedia.org/wiki/Graph_%28data_structure%29
Though I was hoping for something that was less linear!
Sorry, ¿what do you mean?

I usually use the adjacency list, because it facilitates the node expansion (by instance when searching for spanning tree)
1
2
3
4
5
struct node{
  some_container< pair<int, int> > neighbour; //id, weight
};

std::vector<node> graph;
that link was useful! I appreciate your help!
Topic archived. No new replies allowed.