📜  图形表示 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:57.758000             🧑  作者: Mango

代码示例1
GRAPH REPRESENTATION:
    - adjacency matrix (linear representation) 
            Pro: esay implement, removing edge=O(1), queries of vertex or edge is O(1), 
            Cons: Consume space O(V^2), adding a vertex is O(V^2) ;
    - adjacency list 
        -ArrayList (or Array of LinkedList) 
            Pro: save space: O(|V|+|E|), worst case O(V^2)
            Cons: queries are not efficient O(V);
        -LinkedList - a pointer from one vertex to second
        -HashMap collection. K,V . (adjancency list in HashMap)
            private HashMap nodeLookup = new HashMap();
    - Incidence Matrix
    - Incidence List