upxo.netops.kmake module
Grain-network construction helpers for UPXO.
Builds NetworkX graphs from neighbour dictionaries (gid → neighbour gids) used by KREPR, gsan2d, and mode-modifier seed selection.
Import:
from upxo.netops.kmake import make_gid_net_from_neighlist
- upxo.netops.kmake.make_gid_net_from_neighlist(neighbor_dict)[source]
Create an undirected NetworkX graph from a neighbour map.
- Parameters:
neighbor_dict (dict) – Mapping
gid → iterable of neighbour gids. Self-loops and direction are not special-cased; each (gid, neighbour) pair becomes an undirected edge.- Returns:
Graph with grain IDs as nodes and neighbour relations as edges.
- Return type:
networkx.Graph
Example
>>> from upxo.netops.kmake import make_gid_net_from_neighlist >>> G = make_gid_net_from_neighlist({1: [2, 3], 2: [1], 3: [1]})