cyclic flows

127 views
Skip to first unread message

Clifford Federspiel

unread,
Jun 12, 2017, 2:42:43 PM6/12/17
to Node-RED
Has anyone created a way to detect whether or not a flow is cyclic? A trivial example such as this:



is easy to identify. But link nodes, especially if they link flows together can create cyclic flows that are not so easy to identify. If a cyclic flow is deployed, it uses nearly the entire CPU and is difficult to terminate. It would helpful if a check could be run in advance of deploying so that the user could be notified if the flow is cyclic.

Colin Law

unread,
Jun 12, 2017, 4:53:04 PM6/12/17
to node...@googlegroups.com
Note that a flow containing a closed loop is not necessarily an error.. See [1] for example. So if a warning were to be displayed then it would need a Don't Tell Me Again button.

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/c0cf3cf8-baa6-4a74-99fe-2bca047fa7ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan Van den Audenaerde

unread,
Jun 12, 2017, 4:58:02 PM6/12/17
to Node-RED
Hi clifford,

Cyclic flows are not necessary erroneously.
There might be nodes in the cycle that will not always send a message or that will send a message with a delay.

Kr
Jan

Julian Knight

unread,
Jun 12, 2017, 7:10:48 PM6/12/17
to Node-RED
As this comes down to your own logic, I think you need to implement your own checks. Perhaps using a counter or some kind of ID code that you could check.

Clifford Federspiel

unread,
Jun 12, 2017, 7:24:49 PM6/12/17
to Node-RED
I understand that someone may intentionally create a cyclic flow. But I'm asking if anyone has devised a way to determine if a flow (or set of flows) is cyclic, because I would like to detect the unintentional creation of cyclic flows.

Julian Knight

unread,
Jun 13, 2017, 3:37:43 AM6/13/17
to Node-RED
One way would be to add some counters with a check to see if the counter exceeds a set number. In the simple example you give, if you added a function node before the divide by two node & wired the multiply by 2 node into it as well, you could check a counter (added to the msg) and +1 each execution.

Nick O'Leary

unread,
Jun 13, 2017, 3:54:04 AM6/13/17
to Node-RED Mailing List
There are two different things here. One is how you can create your flows such that they detect any such loops for themselves. The other is whether the editor can automatically detect loops and provide some sort of warning/indication.

Whilst the first option is certainly possible, it only helps if a user knows they should do it.

Having the editor spot the loops is much more useful. The challenge is how to do so without getting in the way. The editor cannot check your logic, it can only see where the wires lead, and there are many legitimate reasons for having loops in a flow.

Nick


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Clifford Federspiel

unread,
Jun 13, 2017, 9:20:57 AM6/13/17
to Node-RED
Nick, how is the adjacency matrix of a flow encoded in the JSON file for a flow?

-Cliff


On Tuesday, June 13, 2017 at 12:54:04 AM UTC-7, Nick O'Leary wrote:
There are two different things here. One is how you can create your flows such that they detect any such loops for themselves. The other is whether the editor can automatically detect loops and provide some sort of warning/indication.

Whilst the first option is certainly possible, it only helps if a user knows they should do it.

Having the editor spot the loops is much more useful. The challenge is how to do so without getting in the way. The editor cannot check your logic, it can only see where the wires lead, and there are many legitimate reasons for having loops in a flow.

Nick

On 13 June 2017 at 08:37, Julian Knight <j.kni...@gmail.com> wrote:
One way would be to add some counters with a check to see if the counter exceeds a set number. In the simple example you give, if you added a function node before the divide by two node & wired the multiply by 2 node into it as well, you could check a counter (added to the msg) and +1 each execution.

On Tuesday, 13 June 2017 00:24:49 UTC+1, Clifford Federspiel wrote:
I understand that someone may intentionally create a cyclic flow. But I'm asking if anyone has devised a way to determine if a flow (or set of flows) is cyclic, because I would like to detect the unintentional creation of cyclic flows.

On Monday, June 12, 2017 at 11:42:43 AM UTC-7, Clifford Federspiel wrote:
Has anyone created a way to detect whether or not a flow is cyclic? A trivial example such as this:



is easy to identify. But link nodes, especially if they link flows together can create cyclic flows that are not so easy to identify. If a cyclic flow is deployed, it uses nearly the entire CPU and is difficult to terminate. It would helpful if a check could be run in advance of deploying so that the user could be notified if the flow is cyclic.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Nick O'Leary

unread,
Jun 13, 2017, 9:28:51 AM6/13/17
to Node-RED Mailing List
Clifford,

the flow file format is described here https://github.com/node-red/node-red/wiki/Flow-Format 

In short, it is an array of 'node' objects. Each node object has a 'wires' property that is an array. Each element of that array represents an output of the node, and will be an array of the node ids it is wired to.

So the format describes directly what downstream nodes a node is connected to.


We already have code in the editor that finds all nodes that are connected to a particular node - used when you Shift-Click a node. That code protects itself against loops - so would be trivial to do something extra when a loop is detected. That code does not, however, take into account Link nodes or Catch/Status nodes that can create 'virtual' links - but certainly a starting point.


Nick


To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Reply all
Reply to author
Forward
0 new messages