What is better, adjacency lists or adjacency matrices for graph problems in C++?

后端 未结 11 1092
小鲜肉
小鲜肉 2020-11-28 00:41

What is better, adjacency lists or adjacency matrix, for graph problems in C++? What are the advantages and disadvantages of each?

11条回答
  •  隐瞒了意图╮
    2020-11-28 01:22

    If you are looking at graph analysis in C++ probably the first place to start would be the boost graph library, which implements a number of algorithms including BFS.

    • Boost Graph Library Docs

    EDIT

    This previous question on SO will probably help:

    how-to-create-a-c-boost-undirected-graph-and-traverse-it-in-depth-first-search

提交回复
热议问题