graph/hierarchy_utils library
Hierarchy flattener and builder from flat list with parent ids — roadmap #556, #557.
Classes
- HierarchyUtils
- Node with id and optional parentId for tree building.
Functions
-
flattenHierarchy(
List< HierarchyUtils> nodes) → List<(String, int)> -
Flattens tree:
nodeshas (id, parentId). Returns list of (id, level). Root level = 0. -
hierarchyFromParentIds(
List< HierarchyUtils> nodes) → Map<String, String?> - Builds parent map from flat list: id -> parentId (roots have null).