Lattice#
- class Lattice(graph)[ソース]#
ベースクラス:
object
General lattice.
- パラメータ:
graph (Union[PyGraph, 'nx.Graph']) – Input graph for Lattice. Can be provided as
rustworkx.PyGraph
, which is used internally, or, for convenience, asrustworkx.Graph
. The graph cannot be a multigraph.- 例外:
ValueError – If the input graph is a multigraph.
ValueError – If the graph edges are non-numeric.
Attributes
- graph#
Return a copy of the input graph.
- node_indexes#
Return the node indexes.
- num_nodes#
Return the number of nodes.
- weighted_edge_list#
Return a list of weighted edges.
Methods
- draw(*, self_loop=False, style=None)[ソース]#
Draw the lattice.
- パラメータ:
self_loop (bool) – Draw self-loops in the lattice. Defaults to False.
style (LatticeDrawStyle | None) – Styles for rustworkx.visualization.mpl_draw. Please see https://qiskit.org/documentation/rustworkx/stubs/rustworkx.visualization.mpl_draw.html#rustworkx.visualization.mpl_draw for details.
- classmethod from_adjacency_matrix(interaction_matrix)[ソース]#
Constructs a new lattice from a 2-dimensional adjacency matrix.
This method is equivalent to
PyGraph.from_adjacency_matrix()
or its complex counterpart when given a complex-valued matrix.- パラメータ:
interaction_matrix (ndarray) – the adjacency matrix from which to build out the lattice.
- 例外:
ValueError – if the provided adjacency matrix is not a 2-D square matrix.
- 戻り値:
A new lattice based on the provided adjacency matrix.
- 戻り値の型:
- classmethod from_nodes_and_edges(num_nodes, weighted_edges)[ソース]#
Return an instance of Lattice from the number of nodes and the list of edges.
- to_adjacency_matrix(weighted=False)[ソース]#
Return its adjacency matrix from weighted edges. The weighted edge list is interpreted as the upper triangular matrix. Defaults to False.