我应该如何在 Java 中表示依赖图?
我正在编写一些 JavaScript 依赖管理代码,并且我认为有人已经解决了 Java 中的依赖图问题。
我的第一次尝试是在 JSResource 对象上实现比较,但是当存在多个没有依赖性的叶节点时,它会失败,因此没有合理的顺序,除非受到其依赖项的影响。
所以我想我需要一个图表,然后需要一种迭代该图表的方法。这不是一个不可能的问题,但我想在重新发明轮子之前我应该在这里发帖。
干杯, 皮特
I'm working on some code for JavaScript dependency management and I'm figuring someone has tackled the dependency graph problem in Java already.
My first attempt was to just implement comparable on my JSResource object, but it falls over when there are multiple leaf nodes with no dependency and hence no sensible order unless influenced by their dependents.
So I figure I need a graph and then a way to iterate through the graph. Not an impossible problem but I thought I'd post here before reinventing the wheel.
Cheers,
Pete
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发布了一些内容可能可以回答您的问题。这是链接:
http://nicolaecaralicea.blogspot.com/2010/11 /dependency-graphs-generic-approach-in.html
这是代码:
I posted something that might answer to your question. Here is the link:
http://nicolaecaralicea.blogspot.com/2010/11/dependency-graphs-generic-approach-in.html
Here is the code:
很多时候,将任务表示为依赖图是不够的,您可能希望并行执行满足依赖条件的任务(表示为节点),再加上做一些内务工作,例如检查周期等。为此,您可以借助这个框架,这是一个非常轻量级的框架,可以在可靠的方式。这是一个测试用例,可以让您有一个简单的了解:
这是控制台输出,可以让您了解幕后情况
Many a times representing tasks as dependency graph is not sufficient, you would want to execute the tasks (represented as nodes) in parallel meeting the dependency conditions, plus do some house keeping works such as check for cycle etc.. For that purpose you can take help of this framework, which is a very light weight framework to run dependent tasks in a reliable way. Here is a test case to give you a brief idea:
Here is the console output to give you an idea of what is going under the hood