cayleypy.BfsResult
- class cayleypy.BfsResult[source]
Result of running breadth-first search on a Schreier coset graph.
Can be used to obtain the graph explicitly. In this case, vertices are numbered sequentially in the order in which they are visited by BFS.
- __init__(bfs_completed: bool, layer_sizes: list[int], layers: dict[int, Tensor], layers_hashes: list[Tensor], edges_list_hashes: Tensor | None, graph: CayleyGraphDef) None
Methods
__init__
(bfs_completed, layer_sizes, layers, ...)Returns adjacency matrix as a dense NumPy array.
Returns adjacency matrix as a sparse SciPy array.
check_has_layer_hashes
()diameter
()Maximal distance from any start vertex to any other vertex.
get_edge_name
(i1, i2)Returns name for generator used to go from vertex i1 to vertex i2.
get_layer
(layer_id)Returns all states in the layer with given index.
has_edges_list_hashes
()Returns last layer, formatted as set of strings.
load
(path)Names for vertices (representing coset elements in readable format).
save
(path)to_device
(device)to_networkx_graph
([directed, with_labels])Returns explicit graph as networkx.Graph or networkx.DiGraph.
vertex_name
(state)Attributes
Explicit states, ordered by index.
Returns list of edges, with vertices renumbered.
Dictionary used to remap vertex hashes to indexes.
Number of vertices in the graph.
Returns names for vertices in the graph.
Whether full graph was explored.
i-th element is number of states at distance i from start.
Explicitly stored states for each layer.
layers_hashes
edges_list_hashes
Definition of the CayleyGraph on which BFS was run.
- property all_states: Tensor
Explicit states, ordered by index.
- bfs_completed: bool
Whether full graph was explored.
- property edges_list: ndarray
Returns list of edges, with vertices renumbered.
- get_edge_name(i1: int, i2: int) str [source]
Returns name for generator used to go from vertex i1 to vertex i2.
- graph: CayleyGraphDef
Definition of the CayleyGraph on which BFS was run. Needed if we want to restore edge names.
- property hashes_to_indices_dict: dict[int, int]
Dictionary used to remap vertex hashes to indexes.
- layer_sizes: list[int]
i-th element is number of states at distance i from start.
- layers: dict[int, Tensor]
Explicitly stored states for each layer.
- named_undirected_edges() set[tuple[str, str]] [source]
Names for vertices (representing coset elements in readable format).
- property num_vertices: int
Number of vertices in the graph.
- to_networkx_graph(directed=False, with_labels=True)[source]
Returns explicit graph as networkx.Graph or networkx.DiGraph.
- property vertex_names: list[str]
Returns names for vertices in the graph.