配置继承机制
我有以下结构:
config |-- groups |-- rootgroup |-- group1 (includes rootgroup) |-- group2 (includes group1) |-- group3 (includes rootgroup) |-- users |-- Fred (includes group3 and group2)
因此 Fred 的继承树将如下所示:
_Fred_ v v group2 group3 v v group1 v v / rootgroup
我需要一个算法来打印从树的左下角开始的线性配置读取顺序(对于给定的示例,它将是 rootgroup - group1 - group2 - group3; group1覆盖 rootgroup,group2 覆盖 group1 等...)并查找递归链接(例如,如果 rootgroup 包含组 2),而且它必须找到递归循环(... -> group2 -> group1 -> rootgroup - >组2->...)。
首选语言是 python,但任何语言都可以。
谢谢。
I have the following structure:
config |-- groups |-- rootgroup |-- group1 (includes rootgroup) |-- group2 (includes group1) |-- group3 (includes rootgroup) |-- users |-- Fred (includes group3 and group2)
So inheritance tree for Fred will look like:
_Fred_ v v group2 group3 v v group1 v v / rootgroup
I need an algorithm to print the linear config read order beginning at the bottom left of the tree (for given example it would be rootgroup - group1 - group2 - group3; group1 overwrites rootgroup, group2 overwrites group1, etc...) and find recursive links (for example if rootgroup includes group 2), moreover it must find the recursion loop (... -> group2 -> group1 -> rootgroup -> group2 -> ...).
Preferable language is python, but any will do.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在阅读了有向无环图(DAG)之后,我想出了以下解决方案:
Well after reading about directed acyclic graphs (DAG) I came up with following solution: