kwant.graph.induced_subgraph

kwant.graph.induced_subgraph()[source]

Return a subgraph of the CGraph gr by picking all nodes [0:gr.num_nodes] for which select is True. select can be either a NumPy array, or a function that takes the node number as input. This function returns a CGraph as well.

The nodes in the new graph are again numbered sequentially from 0 to num_nodes-1, where num_nodes is the number of nodes in the subgraph. The numbering is done such that the ordering of the node numbers in the original and the subgraph are preserved (i.e. if nodes n1 and n2 are both in the subgraph, and original node number of n1 < original node number of n2, then also subgraph node number n1 < subgraph node number n2).

If edge_weights is provided, the function also returns the edge weights for the subgraph which are simply a subset of the original weights.

This function returns a simple graph, regardless of whether the input was a two-way graph or not (NOTE: This restriction could be lifted, if necessary). Also, the resulting edge_ids are not related to the original ones in any way (NOTE: There certainly is a relation, but as long no-one needs it, we do not specify it). Also, negative nodes are discarded (NOTE: this restriction can also be lifted).

Previous topic

kwant.graph.remove_duplicates

Next topic

kwant.graph.print_graph

This Page