Java - Which is the best implementation structure for Graph?

前端 未结 8 2082
我在风中等你
我在风中等你 2021-02-02 16:47

The graph is very large but undirected. Edges are unweighted.

In my implementation, I have to find the vertex with max degree and do deletion on both vertexes and edges.

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-02 16:58

    Graph implementation depends on what you going to do with it. But for most cases Adjacency list based implementation helps.

    In Java you can do it using a Map<>. Here is generic Adjacency List based Graph.Java implementation on my blog.

提交回复
热议问题