Graph¶
- plot3d.graph.build_weighted_graph_from_face_matches(face_matches: List[dict], n_blocks: int, aggregate: str = 'sum', ignore_self_matches: bool = True) Tuple[Dict[int, List[int]], Dict[int, Dict[int, int]]][source]¶
 Convert connectivity_fast face_matches into adjacency + weights.
Note
Aggregate controls how we combine weights when the same two blocks are connected by multiple faces.
- Why this matters:
 connectivity_fast can return more than one face between the same pair of blocks (e.g. a block is split and has two non-contiguous interfaces with its neighbor). Each face gives a weight = dI * dJ * dK (number of shared nodes). METIS expects one edge per block-pair, with a single weight. So if there are multiple faces, we must decide how to merge them. That’s what aggregate does.
- Parameters:
 face_matches (List[dict]) – Output from connectivity_fast
n_blocks (int) – number of blocks in a mesh
aggregate (str, optional) – ‘sum’|’max’|’min’. Controls how weights are combined. Defaults to “sum”.
ignore_self_matches (bool, optional) – ignores self matching (i==j). Defaults to True.
- Raises:
 ValueError – if aggregate is not one of ‘sum’,’max’,’min’
- Returns:
 adj_list (Dict[int, List[int]]): Neighbors for each block.
edge_w (Dict[int, Dict[int, int]]): Edge weights (u->v).
- Return type:
 Tuple[Dict[int, List[int]], Dict[int, Dict[int, int]]]
- plot3d.graph.csr_from_adj_and_weights(adj_list: Dict[int, List[int]], edge_w: Dict[int, Dict[int, int]]) Tuple[List[int], List[int], List[int]][source]¶
 Build CSR arrays (xadj, adjncy, eweights) from adjacency + weights.
- Returns:
 prefix sum of neighbors adjncy (List[int]): flattened neighbor list eweights (List[int]): edge weights aligned with adjncy
- Return type:
 xadj (List[int])
- plot3d.graph.partition_from_face_matches(face_matches: List[dict], blocks: Sequence[Block], nparts: int, favor_blocksize: bool = True, aggregate: str = 'sum', ignore_self_matches: bool = True) Tuple[List[int], Dict[int, List[int]], Dict[int, Dict[int, int]]][source]¶
 Partition a graph derived from face_matches using pymetis.
Note
Aggregate controls how we combine weights when the same two blocks are connected by multiple faces.
- Why this matters:
 connectivity_fast can return more than one face between the same pair of blocks (e.g. a block is split and has two non-contiguous interfaces with its neighbor). Each face gives a weight = dI * dJ * dK (number of shared nodes). METIS expects one edge per block-pair, with a single weight. So if there are multiple faces, we must decide how to merge them. That’s what aggregate does.
- Returns:
 parts (List[int]) – Partition id (0-based) for each block.
adj_list (Dict[int, List[int]]) – Adjacency list used for the partitioning.
edge_w (Dict[int, Dict[int, int]]) – Edge weights.
- plot3d.graph.write_ddcmp(parts: Sequence[int], blocks: Sequence[Block], adj_list: Dict[int, List[int]], edge_weights: Dict[int, Dict[int, int]] | None = None, filename: str = 'ddcmp.dat') None[source]¶
 Writes ddcmp.dat and ddcmp_info.txt.
Notes
parts are 0-based in memory, but written 1-based in the file (to match your C#).
edge_weights affects the per-partition ‘edge_work’ if provided.