Reputation: 153
I need a graph data structure implementation that stores a graph with vertices and edges, but my edges need to be objects that can store their own data, unlike just the normal adjacency list implementations.
I remember seeing such a representation for this once, but can not find it now.
It kept a list or map of vertexes and a list or map of edges objects. Can anyone point me to a good reference for this?
Upvotes: 0
Views: 974
Reputation:
You could define an Edge
class with all the data you need and then have an adjency list whose values aren't vertices but Edge
object (which store from, to vertices).
If you don't want the Edge
class to have vertices properties, you could put tuples of (Edge
, vertice) in your adjency list instead.
Upvotes: 1