ClusteredQuantumGraph

class lsst.ctrl.bps.ClusteredQuantumGraph(incoming_graph_data=None, **attr)

Bases: networkx.classes.digraph.DiGraph

Graph where node in the graph is a QuantumGraph

Methods Summary

add_cluster(name, qgraph[, label]) Add a cluster of quanta as a node in the graph.
add_node(node_for_adding, **attr) Override add_node function to ensure that nodes are limited to QuantumGraphs
add_nodes_from(nodes_for_adding, **attr) Add multiple nodes.

Methods Documentation

add_cluster(name, qgraph, label=None)

Add a cluster of quanta as a node in the graph.

Parameters:
name : str

Node name which must be unique in the graph.

qgraph : QuantumGraph

QuantumGraph containing the quanta in the cluster.

label : str, optional

Label for the cluster. Can be used in grouping clusters.

add_node(node_for_adding, **attr)

Override add_node function to ensure that nodes are limited to QuantumGraphs

Parameters:
node_for_adding : str or QuantumGraph

Name of cluster or QuantumGraph to add where name will be a padded node counter.

attr :

Attributes to be saved with node in graph

add_nodes_from(nodes_for_adding, **attr)

Add multiple nodes.

Parameters:
nodes_for_adding : iterable container

A container of nodes (list, dict, set, etc.). OR A container of (node, attribute dict) tuples. Node attributes are updated using the attribute dict.

attr : keyword arguments, optional (default= no attributes)

Update attributes for all nodes in nodes. Node attributes specified in nodes as a tuple take precedence over attributes specified via keyword arguments.

See also

add_node

Examples

>>> G = nx.Graph()  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_nodes_from("Hello")
>>> K3 = nx.Graph([(0, 1), (1, 2), (2, 0)])
>>> G.add_nodes_from(K3)
>>> sorted(G.nodes(), key=str)
[0, 1, 2, 'H', 'e', 'l', 'o']

Use keywords to update specific node attributes for every node.

>>> G.add_nodes_from([1, 2], size=10)
>>> G.add_nodes_from([3, 4], weight=0.4)

Use (node, attrdict) tuples to update attributes for specific nodes.

>>> G.add_nodes_from([(1, dict(size=11)), (2, {"color": "blue"})])
>>> G.nodes[1]["size"]
11
>>> H = nx.Graph()
>>> H.add_nodes_from(G.nodes(data=True))
>>> H.nodes[1]["size"]
11