# SubgraphLayoutManager

Import it from `@grafloria/engine`.

Subgraph layout computation utilities

```ts
class SubgraphLayoutManager
```

**Methods**

- `static buildGroupTree(groups: GroupInfo[]): GroupTreeNode[]` (static) — Build hierarchical tree of groups
- `static getGroupsAtDepth(roots: GroupTreeNode[], depth: number): GroupInfo[]` (static) — Get all groups at a specific depth level
- `static getMaxDepth(roots: GroupTreeNode[]): number` (static) — Get maximum depth of group tree
- `static getNodesInGroup( groupId: string, group: GroupInfo, allNodes: Array<{ id: string; [key: string]: any }>, options: SubgraphLayoutOptions ): Array<{ id: string; [key: string]: any }>` (static) — Filter nodes by group membership
- `static getLinksInGroup( group: GroupInfo, allLinks: Array<{ sourceNodeId: string; targetNodeId: string; [key: string]: any }>, options: SubgraphLayoutOptions ): Array<{ sourceNodeId: string; targetNodeId: string; [key: string]: any }>` (static) — Filter links within a group
- `static calculateGroupSize( group: GroupInfo, nodePositions: Map<string, { x: number; y: number }>, nodeSizes: Map<string, { width: number; height: number }>, options: SubgraphLayoutOptions ): { width: number; height: number }` (static) — Calculate group size based on its content
- `static getGroupPadding( group: GroupInfo, options: SubgraphLayoutOptions ): { top: number; right: number; bottom: number; left: number }` (static) — Get effective padding for a group
- `static positionGroups( groups: GroupInfo[], groupSizes: Map<string, { width: number; height: number }>, options: SubgraphLayoutOptions ): Map<string, { x: number; y: number }>` (static) — Position groups relative to each other
- `static translateToGroupCoordinates( nodePositions: Map<string, { x: number; y: number }>, group: GroupInfo, groupPosition: { x: number; y: number }, options: SubgraphLayoutOptions ): Map<string, { x: number; y: number }>` (static) — Translate node positions to group-local coordinates
- `static async layoutGroup( group: GroupInfo, allNodes: Array<{ id: string; [key: string]: any }>, allLinks: Array<{ sourceNodeId: string; targetNodeId: string; [key: string]: any }>, nodeSizes: Map<string, { width: number; height: number }>, layoutAdapter: any, options: SubgraphLayoutOptions ): Promise<{ nodePositions: Map<string, { x: number; y: number }>; bounds: { x: number; y: number; width: number; height: number }; }>` (static) — Apply layout to a single group
- `static async computeSubgraphLayout( groups: GroupInfo[], allNodes: Array<{ id: string; [key: string]: any }>, allLinks: Array<{ sourceNodeId: string; targetNodeId: string; [key: string]: any }>, nodeSizes: Map<string, { width: number; height: number }>, layoutAdapter: any, options: SubgraphLayoutOptions ): Promise<SubgraphLayoutResult>` (static) — Main subgraph layout computation
