If I topologically sort a DAG, can I drop half the adjacency matrix?

前端 未结 2 1447
醉梦人生
醉梦人生 2021-02-14 20:29

I think I have understood a particular situation as described below, but I lack the theoretical knowledge to conduct a proof and I couldn\'t find any source that mentions it. If

2条回答
  •  逝去的感伤
    2021-02-14 21:22

    This is only correct if your adjacency matrix is constructed with the graph labels in sorted order. For a counterexample construct the adjacency matrix for B->C->A.

    If you kept a hash of the true node to it's topological sort position and construct the adjacency matrix from that you could save some space on a large matrix, as you're saving O(n²) space in the matrix with an O(n) size hashtable.

提交回复
热议问题