0

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?

4

1 回答 1

1

您可以使用所需的所有数据定义一个Edge类,然后拥有一个邻接列表,其值不是顶点而是Edge对象(从顶点存储到顶点)。

如果您不希望Edge该类具有顶点属性,则可以将 ( Edge, vertice) 的元组放在您的邻接列表中。

于 2018-05-14T21:10:47.190 回答