-
Notifications
You must be signed in to change notification settings - Fork 2
read_only_graph
Bluemi edited this page Sep 5, 2025
·
1 revision
The ReadOnlyGraph can not be modified. It is usually created using a MutableGraph.
Bases: SearchGraph
classmethod from_graph(input_graph: SearchGraph, max_vertex_count: int = -1, feature_space: FloatSpace | None = None, edges_per_vertex: int = -1) → ReadOnlyGraph
Create a read only graph from the given graph by only keeping information that is useful for searching.
-
Parameters:
- input_graph – The graph to build from
- max_vertex_count – If given the new size of the returned graph, otherwise will be taken from input graph
- feature_space – If given the feature space for the graph, otherwise the same as the feature space of the input graph
- edges_per_vertex – The number of edges for the new graph. Should not be smaller than the edges of the input graph
- Returns: the number of vertices in the graph
- Returns: the feature space
Translates internal index to external label
- Parameters: external_label – The external label to translate
- Returns: The internal index
has_path(entry_vertex_indices: List[int], to_vertex: int, eps: float, k: int) → List[ObjectDistance]
Returns a path from one of the entry vertex indices to the given to_vertex.
-
Parameters:
- entry_vertex_indices – List of start vertices
- to_vertex – The vertex to find a path to
- eps – Controls how many nodes are checked during search. Lower eps values like 0.001 are faster but less accurate. Higher eps values like 0.1 are slower but more accurate. Should always be greater 0.
- k – TODO
Creates a list of internal indices that can be used as starting point for an anns search.
Translates external labels to internal index
- Parameters: internal_index – The internal index to translate
- Returns: The external label
explore(entry_vertex_index: int, k: int, include_entry: bool, max_distance_computation_count: int) → ResultSet
An exploration for similar element, limited by max_distance_computation_count
-
Parameters:
- entry_vertex_index – The start point for which similar feature vectors should be searched
- k – The number of similar feature vectors to return
- include_entry – If True, the entry vertex is included in the result set.
- max_distance_computation_count – Limit the number of distance calculations. If set to 0 this is ignored.
- Returns: the number of edges of each vertex
Get the neighbor indices (internal index) of the given vertex.
-
Parameters:
- internal_index – The internal index to get the neighbors of
- copy – If True the returned neighbor indices are a copy, otherwise they reference internal graph data.
- Returns: whether the given external label is present in the graph.
- Returns: whether the vertex at internal_index has an edge to the vertex at neighbor_index.
deglib.graph.load_readonly_graph(path: Path | str) → ReadOnlyGraph
Read a saved ReadOnlyGraph from given file. The file can be created by calling SizeBoundedGraph.save_graph().
- Parameters: path – The path where to look for the file
- Raises: FileNotFoundError – If the given file does not exist