function dep_tree(graph,node,prev_deps){    return uniq(flatten(graph[node].map(function(child_node){         if (contains(prev_deps,child_node))            throw Circular reference between +child_node+ and +node;        return dep_tree(graph,child_node,prev_deps ? prev_deps.concat(node) : [node])     })).concat(node));};graph is an object such as {a:[],b:[a],c:[],d:[b,c]}, that links a file, ex: d to it's dependencies b c. file is the the node to search.prev_deps is internal, to keep track of visited nodesThe function returns the full dependency tree of that node. For example, dep_tree(that_obj_above,d) = [b,c,a]. Is this code correct, overall? Is it correctly checking for circular dependencies? Is there a name for what I'm doing?
Is this code for getting the dependency tree of a file correct?
javascript;algorithm;functional programming;graph