算法 - 用代码获取流程走向(Java)
天蓬老师
天蓬老师 2017-04-18 10:52:54
0
2
566

需求是这样的,有很多类似的流程如下:

有一个函数,我传入一个开始节点Node,能够获取所有的流程走向,包装List返回,比如上面这张图就有两种走向:通过和不通过。我开始用递归来做,类似这样:

测试了几个流程,确实能达到效果,但是一遇到复杂的流程(上百种走向)的时候,

递归就会有性能问题(栈溢出等)
请问各位大神,像这种情况除了递归还有什么解法吗?如果没有,这种递归有哪里可以优化的地方?小弟能力有限,想了几天没啥好办法....

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
阿神
  1. The problem is recursive, and recursion is not necessary for implementation. You can put "Node that has not yet been searched" into a List. Each time a new Node is found, it is placed at the end of the List. When the next round of search starts, it is taken from the end of the List.

  2. Dynamic programming should also be used to reduce repeated searches. This problem is NP in complete search.

迷茫

Is this a workflow? ? ? ?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template