schrodinger.thirdparty.networkx_algos module¶
- schrodinger.thirdparty.networkx_algos.get_subgraphs(g: MultiGraph, root, *, node_weight_map=None, max_weight: float = inf) Iterable[MultiGraph]¶
Return a generator over all subgraphs of
gweighing at mostmax_weightand with rootrootFor every iteration of this generator, a
nx.MultiGraphwill be yielded that is a subgraph ofg. The samenx.MultiGraphis used for every iteration so if you need to save the state of the subgraph, make a copy of it (subgraph.copy()).All nodes are given a default weight of 1. If
node_weight_mapis supplied, weights of nodes are determined by looking them up in the map. If they are not found in the map, the default of 1 is used.
- schrodinger.thirdparty.networkx_algos.get_subtrees(g: MultiGraph, root, *, node_weight_map=None, max_weight: float = inf) Iterable[MultiGraph]¶
Return a generator over all subtrees of
gweighing at mostmax_weightand with rootrootFor every iteration of this generator, a
nx.MultiGraphwill be yielded that is a subtree ofg. The samenx.MultiGraphis used for every iteration so if you need to save the state of the subtree, make a copy of it (subtree.copy()).All nodes are given a default weight of 1. If
node_weight_mapis supplied, weights of nodes are determined by looking them up in the map. If they are not found in the map, the default of 1 is used.
- schrodinger.thirdparty.networkx_algos.leaf_first_topo_sort(g: DiGraph, key=None) list¶
Topologically sort a directed graph with a bias towards visiting leaf nodes as early as possible.
If provided, the
keyfunction should accept a node and return a comparable value. This will be used to determine the order in which nodes are visited if they’re the same distance from a leaf.