What is the distinction between sparse and dense graphs?

后端 未结 5 1629
独厮守ぢ
独厮守ぢ 2020-12-23 02:22

I read it is ideal to represent sparse graphs by adjacency lists and dense graphs by an adjacency matrix. But I would like to understand the main difference between sparse a

5条回答
  •  萌比男神i
    2020-12-23 02:31

    Main graph integral characteristics are number of vertices V and number of edges E. The relation of these two determines whether graph is sparse or dense (wiki page here).

    The whole theory behind choosing graph in-memory representation is about determining the optimal access time vs memory footprint tradeoff, considering subject domain and usage specifics.

    Generally you want to have O(1) access time (and thus store the graph as a dense adjacency matrix) unless you can't tolerate memory footprint, in which case you choose the most appropriate sparse matrix representation (wiki page here).

提交回复
热议问题