Comparison of 2 graphs created by the Boost Graph library

It may be more of a beginner or even a wrong question, so please goodbye. Is there a way to compare 2 graphs created using the Boost Graph => library with 1 graph created in memory and the 2nd graph loaded from the archive (i.e., the second one was serialized earlier)?

I don't see the == operator presented in the BGL documentation, but I'm not sure if this means that I have to write a workaround and comparison. Any pointers to study guides, man pages or samples would be most helpful.

Thanks in advance Ganesh

+5
source share
2 answers

, , , ; , (, , NP -). , , , , .

. (, ) , O (V lg V + E lg E ) , :

If |G1| != |G2|, the graphs are non-equal. Abort.

i = 0
For each vertex V in G1:
  G1_M[Label(V)] = V
  G1_I[V] = i
  i = i + 1

For each vertex V in G1:
  G1_E[V] = sort(map(λDestination -> G1_I[Destination]) Edges[V])

For each vertex V in G2:
  If G1_M[Label(V)] does not exist, the graphs are non-equal. Abort.
  G2_corresp[V] = G1_M[Label(V)]
  G2_I[V] = G1_I[G2_corresp[V]]

For each vertex V in G2:
  G1_E[V] = sort(map(λDestination -> G2_I[Destination]) Edges[V])
  Compare G1_E[G2_corresp[V]] and G2_E[V]. If non-equal, the graphs are non-equal. Abort.

If we get here, the graphs are equal.
+5

All Articles