dominikbraun / graph

A library for creating generic graph data structures and modifying, analyzing, and visualizing them.
https://graph.dominikbraun.io
Apache License 2.0
1.77k stars 95 forks source link

Fix potential panic on AdjacencyMap #157

Open davidovich opened 9 months ago

davidovich commented 9 months ago

Because the store could theoretically be updated without the use of the main AddVertex and AddEdge APIs (which does some input validation), calculating the AdjencyMap could provoke an "assignment to entry in nil map" panic if the store reported edges that were between unknown vertices.

Since the edges are always between known vertices, it is an error to try and match a missing source vertex from the vertex set. If that happens, it is a data desynchronization error that we report to the user.

In order to test this pathological case, we needed to modify the test to use the store directly because the "front-facing" API would not allow us to add Edges on missing vertex.

fixes #102

Signed-off-by: davidovich david.genest@gmail.com

davidovich commented 9 months ago

cc @BriannHu @suarez-agu