HnswUtil
Utilities for use in tests involving HNSW graphs
Types
A component (also "connected component") of an undirected graph is a collection of nodes that are connected by neighbor links: every node in a connected component is reachable from every other node in the component. See https://en.wikipedia.org/wiki/Component_(graph_theory). Such a graph is said to be "fully connected" iff it has a single component, or it is empty.
Functions
Returns the sizes of the distinct graph components on level 0. If the graph is fully-rooted the list will have one entry. If it is empty, the returned list will be empty.
Returns the sizes of the distinct graph components on the given level. The forest starting at the entry points (nodes in the next highest level) is considered as a single component. If the entire graph is rooted in the entry points--that is, every node is reachable from at least one entry point--the returned list will have a single entry. If the graph is empty, the returned list will be empty.
In graph theory, "connected components" are really defined only for undirected (ie bidirectional) graphs. Our graphs are directed, because of pruning, but they are mostly undirected. In this case we compute components starting from a single node so what we are really measuring is whether the graph is a "rooted graph". TODO: measure whether the graph is "strongly connected" ie there is a path from every node to every other node.