Diff for Directed Acyclic Graphs

前端 未结 2 1905
故里飘歌
故里飘歌 2021-01-31 09:47

I\'m looking for an algorithm which can diff two Directed Acyclic Graphs(DAGs). That is, I\'d like an algorithm which produces a sequence of deletions and insertion

2条回答
  •  礼貌的吻别
    2021-01-31 10:47

    This might be a bit too late but just for fun: Both of your DAGs can be expressed as matrices, with row index indicating the "from" vertex, and the column index indicating the "to" vertex, and the corresponding cell labeled with edge id. You can give vertex unique and random ids.

    The next part is a bit tricky, because only your edges have meaningful label that maps from DAG1 to DAG2. Suppose you have a set of edges E* that are the intersect of labeled edges from DAG1 and DAG2, you will need to perform a series of row shift (move up or down) or column shift (move left or right) so position of all edges in E* in DAG1 and DAG2 maps to each other. Note that for a DAG represented in Matrix, shifting position of entire row or entire column still makes the representation equivalent.

    The remaining operation would be to rename the vertex according to the mapped matrices, compare the two matrices, and identify the new edges and new vertex required (and edges and vertices that can be removed.

提交回复
热议问题