iqm.qrisp_iqm.passes.routing.core.graph_processing_tools.reachability_counts_csr#
- iqm.qrisp_iqm.passes.routing.core.graph_processing_tools.reachability_counts_csr(indptr: ndarray, indices: ndarray, ignore_nodes: ndarray, predecessors: bool = False) ndarray#
Count how many nodes each node can reach in a CSR-encoded DAG.
By default (
predecessors=False) this counts descendants: for every node u it returns the number of nodes reachable by following edges forward. Whenpredecessors=Trueit counts predecessors (ancestors) instead, i.e. the number of nodes from which u is reachable — equivalent to computing descendant counts on the transposed graph.Nodes listed in
ignore_nodesare excluded from every count (useful for skipping single-qubit gates in a circuit DAG).- Parameters:
- Returns:
Per-node reachability count (self excluded).
- Return type: