genplanner.ZoneRelationMatrix¶
- class genplanner.ZoneRelationMatrix(zones, _m)[source]¶
Symmetric matrix of relations between zones. Access is O(1). Default relation is NEUTRAL.
- Symmetry invariant:
_m[a][b] == _m[b][a] for all a,b
- classmethod from_pairs(zones, *, neighbors=(), forbidden=(), default=Relation.NEUTRAL)[source]¶
Build from explicit pairs. Input pairs may be non-symmetric — matrix will be symmetric internally anyway.
- classmethod from_dataframe(df, *, value_map=None, default=Relation.NEUTRAL, require_symmetric=True)[source]¶
df must be square.
Requirements: - df.index contains Zone objects - df.columns contains Zone objects - set(index) == set(columns) - (optional) matrix must be symmetric (after mapping values)
- with_pairs(pairs, rel)[source]¶
Applies pairs and enforces symmetry: (a,b) and (b,a) both set to rel.