dwave.optimization.model.Symbol.topological_index#
- Symbol.topological_index()#
Topological index of the node.
Return
None
if the model is not topologically sorted.Examples
This example prints the indices of a two-symbol model.
>>> from dwave.optimization import Model >>> model = Model() >>> i = model.integer(100, lower_bound=20) >>> sum_i = i.sum() >>> with model.lock(): ... for symbol in model.iter_symbols(): ... print(f"Symbol {type(symbol)} is node {symbol.topological_index()}") Symbol <class 'dwave.optimization.symbols.IntegerVariable'> is node 0 Symbol <class 'dwave.optimization.symbols.Sum'> is node 1