dwave_networkx.generators.chimera_graph¶
-
chimera_graph(m, n=None, t=None, create_using=None, node_list=None, edge_list=None, data=True)[source]¶ Creates a Chimera lattice of size (m, n, t).
A Chimera lattice is an m-by-n grid of Chimera tiles. Each Chimera tile is itself a bipartite graph with shores of size t. The connection in a Chimera lattice can be expressed using a node-indexing notation (i,j,u,k) for each node. (i,j) indexes the (row, column) of the Chimera tile. i must be between 0 and m-1, inclusive, and j must be between 0 and n-1, inclusive. u=0 indicates the left-hand nodes in the tile, and u=1 indicates the right-hand nodes. k=0,1,…,t-1 indexes nodes within either the left- or right-hand shores of a tile.
In this notation, two nodes (i, j, u, k) and (i’, j’, u’, k’) are neighbors if and only if:
(i = i’ AND j = j’ AND u != u’) OR (i = i’ +/- 1 AND j = j’ AND u = 0 AND u’ = 0 AND k = k’) OR (i = i’ AND j = j’ +/- 1 AND u = 1 AND u’ = 1 AND k = k’)The first line gives the bipartite connections within the tile. The second and third give the vertical and horizontal connections between blocks respectively.
Node (i, j, u, k) is labeled by:
label = i * n * 2 * t + j * 2 * t + u * t + kParameters: - m (int) – The number of rows in the Chimera lattice.
- n (int, optional (default m)) – The number of columns in the Chimera lattice.
- t (int, optional (default 4)) – The size of the shore within each Chimera tile.
- create_using (Graph, optional (default None)) – If provided, this graph is cleared of nodes and edges and filled with the new graph. Usually used to set the type of the graph.
- node_list (iterable, optional (default None)) – Iterable of nodes in the graph. If None, calculated from (m, n, t). Note that this list is used to remove nodes, so any nodes specified not in range(m * n * 2 * t) will not be added.
- edge_list (iterable, optional (default None)) – Iterable of edges in the graph. If None, edges are generated as described above. The nodes in each edge must be integer-labeled in range(m * n * t * 2).
- data (bool, optional (default True)) – If True, each node has a chimera_index attribute. The attribute is a 4-tuple Chimera index as defined above.
Returns: G – An (m, n, t) Chimera lattice. Nodes are labeled by integers.
Return type: a NetworkX Graph
Examples
>>> G = dnx.chimera_graph(1, 1, 2) # a single Chimera tile >>> len(G) 4 >>> list(G.nodes()) [0, 1, 2, 3] >>> list(G.nodes(data=True)) [(0, {'chimera_index': (0, 0, 0, 0)}), (1, {'chimera_index': (0, 0, 0, 1)}), (2, {'chimera_index': (0, 0, 1, 0)}), (3, {'chimera_index': (0, 0, 1, 1)})] >>> list(G.edges()) [(0, 2), (0, 3), (1, 2), (1, 3)]