in Generator/Sources/NeedleFramework/Utilities/DependencyGraphPrinter.swift [26:46]
func printDIStructure(withRootComponentName rootComponentName: String) {
var childrenDictionary = [String: [Component]]()
let parentChildTuples: [(Component, Component)] = components.flatMap { component in
return component.parents.map { ($0, component) }
}
parentChildTuples.forEach { (parent, child) in
var children = childrenDictionary[parent.name] ?? [Component]()
children.append(child)
childrenDictionary[parent.name] = children
}
var sortedChildren = [String: [Component]]()
childrenDictionary.forEach { (parentName, children) in
sortedChildren[parentName] = children.sorted { $0.name < $1.name}
}
printChildren(ofParent: rootComponentName,
withChildrenDictionary: sortedChildren,
atLevel: 0)
}