-
Notifications
You must be signed in to change notification settings - Fork 2
mutable_graph
The MutableGraph is an abstract base class, that allows modifications and additions to the graph. It is used to build graphs. SizeBoundedGraph is a subclass.
Bases: SearchGraph, ABC
Add a new vertex. The neighbor indices will be prefilled with a self-loop, the weights will be 0.
-
Parameters:
- external_label – The label for the new vertex
- feature_vector – The feature vector to add. This numpy array should be c-contiguous, otherwise it has to be reallocated.
- Returns: the internal index of the new vertex
Remove an existing vertex.
- Parameters: external_label – The external label of the vertex that should be removed.
abstractmethod change_edge(internal_index: int, from_neighbor_index: int, to_neighbor_index: int, to_neighbor_weight: float) → bool
Swap a neighbor with another neighbor and its weight.
-
Parameters:
- internal_index – vertex index which neighbors should be changed
- from_neighbor_index – neighbor index to remove
- to_neighbor_index – neighbor index to add
- to_neighbor_weight – weight of the neighbor to add
- Returns: True if the from_neighbor_index was found and changed
abstractmethod change_edges(internal_index: int, neighbor_indices: ndarray, neighbor_weights: ndarray)
Change all edges of a vertex. The neighbor indices/weights and feature vectors will be copied. The neighbor array need to have enough neighbors to match the edge-per-vertex count of the graph. The indices in the neighbor_indices array must be sorted.
-
Parameters:
- internal_index – The index of the vertex for which edges should change
- neighbor_indices – These neighbors will be set as the new neighbors of the specified vertex
- neighbor_weights – These weights will be set as the new weights for the neighbors.
Get weights for each neighbor of the vertex defined by the given index.
-
Parameters:
- internal_index – The index that specifies the vertex
- copy – If True the returned neighbor weights are copied, otherwise they reference internal graph data.
- Returns: The weights of the neighbors
Get the weight from vertex to another vertex. If start vertex is not a neighbor of end vertex, -1.0 is returned.
-
Parameters:
- from_neighbor_index – Internal index of the start vertex
- to_neighbor_index – Internal index of the target vertex
- Returns: If present the weight between start and target vertex, -1.0 otherwise
Save graph to specified file. Creates necessary directories.
- Parameters: path – The path where to save the file.
Remove all edges which are not MRNG conform.