I have some shortest path data for a graph. Can I reconstruct the graph itself from this data?
More precisely, I have a boolean (0/1) matrix for each vertex v in graph (V, E). Matrix element [s,d] is equal to 1 iff v is in the shortest path from source vertex s to destination vertex d. All edges in the graph have the same length.
For example, for the graph
(V1) -- (V2) -- (V3)
the three matrices would be:
V1:
1 1 1
1 0 0
1 0 0
V2:
0 1 1
1 1 1
1 1 0
V3:
0 0 1
0 0 1
1 1 1
My questions:
1) is there an algorithm to reconstruct the set of edges E from these matrices?
2) is solution always unique? (this is more of a personal curiosity than a real requirement)
3) can the algorithm be generalized to nonuniform edge lengths?
v1
andv2
, then exactly these two vertices are in the shortest path betweenv1
andv2
. So for any other vertexv
,[v1, v] == 0 == [v, v1]
in the matrix ofv2
, and[v2, v] == 0 == [v, v2]
in the matrix ofv1
.