Message from JavaScript discussions

May 2017

— If true, skip but still include in teration, if false, add to stack and traverse. If it was seen before the existing property of the state object will be set to the tuple of the map entry for that node

Message permanent page


So that is great for clone algorithms since they can add the cloned object to the tuple, then have it again when it meets a cycle so you can assign it again

— I see

— That way you dont clone a node multiple times

— Otherwise you may get infinite loops

— It can detect a cycle, hard circulars, anything

— What's a hard circular?

— The stack is basically just a list of nodes to be traversed. When its empty and no more nodes are added, the algorithm stops

Message permanent page


var obj = {};
obj.a = obj;

— Right, I thought that's what you meant by cycle

— A graph's evasiveness erases canonical relation information, in js you cannot point a property to another property, so you have to store every node

Message permanent page

— Since js objects are converted from directed (literals) to undirected (hashmap)