Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有邻接矩阵优于邻接列表的算法?反过来呢?
在运行时间方面,邻接矩阵几乎总是优于列表。List 实现将使用更少的内存(与边数成正比)来存储 Graph。
因此,如果内存确实很重要(对于具有大量节点的稀疏图肯定会如此),请使用列表。如果运行时间很重要,并且图形可能很密集,请使用邻接矩阵。