andrey_zh
April 19th, 2010, 02:30 PM
Hi, there!
I need to implement a general purpose graph and I've stuck with OOP design.
The graph is very general, just vertices and edges. Also I'll need to iterate through vertices and edges. Both must allow to store some info on them.
So what is the proper design of a class hierarchy in my case?
What is a better way to store information on vertices and edges: inheritance or a field?
Does it make any sense to use inner classes (hope this is a proper name) like this:
class Graph
{
public class Vertex { ... }
public class Edge { ... }
}
?
Thanks in advance!
I need to implement a general purpose graph and I've stuck with OOP design.
The graph is very general, just vertices and edges. Also I'll need to iterate through vertices and edges. Both must allow to store some info on them.
So what is the proper design of a class hierarchy in my case?
What is a better way to store information on vertices and edges: inheritance or a field?
Does it make any sense to use inner classes (hope this is a proper name) like this:
class Graph
{
public class Vertex { ... }
public class Edge { ... }
}
?
Thanks in advance!