Java: how to represent graphs?

前端 未结 12 1482
感动是毒
感动是毒 2020-12-02 12:17

I\'m implementing some algorithms to teach myself about graphs and how to work with them. What would you recommend is the best way to do that in Java? I was thinking somethi

12条回答
  •  感动是毒
    2020-12-02 12:54

    class Graph {
        private List> vertices;
    
        private static class Vertex {
            E elem;
            List> neighbors;
        }
    }
    

提交回复
热议问题