src/core/dependency-graph.js
function createDependencyGraph(tasks) {
    var graph = {
      tasks: {},
      roots: [],
      leaves: [],
      resources: [],
      depth: 0,
      end : 0
    };

    for(var i = 0, len = tasks.length; i < len; i++) {
      var t = tasks[i];
      graph.tasks[t.id] = {
        id: t.id,
        duration: t.duration,
        priority: t.priority,
        schedule: t.schedule,
        minSchedule: t.minSchedule,
        dependsOn: t.dependsOn,
        resources: t.resources
      };
    }

    setResources(graph);
    setRequiredBy(graph.tasks);
    setRootsAndLeaves(graph);

    setDepth(graph, graph.leaves, 0);
    graph.depth += 1; // increment depth so it is 1 based

    forwardPass(graph, {}, graph.roots, 0);
    setEnd(graph, graph.leaves);
    backwardPass(graph, {}, graph.leaves, graph.end);

    return graph;
  }
function createDependencyGraph(tasks) {
    var graph = {
      tasks: {},
      roots: [],
      leaves: [],
      resources: [],
      depth: 0,
      end : 0
    };

    for(var i = 0, len = tasks.length; i < len; i++) {
      var t = tasks[i];
      graph.tasks[t.id] = {
        id: t.id,
        duration: t.duration,
        priority: t.priority,
        schedule: t.schedule,
        minSchedule: t.minSchedule,
        dependsOn: t.dependsOn,
        resources: t.resources
      };
    }

    setResources(graph);
    setRequiredBy(graph.tasks);
    setRootsAndLeaves(graph);

    setDepth(graph, graph.leaves, 0);
    graph.depth += 1; // increment depth so it is 1 based

    forwardPass(graph, {}, graph.roots, 0);
    setEnd(graph, graph.leaves);
    backwardPass(graph, {}, graph.leaves, graph.end);

    return graph;
  }
function createDependencyGraph ( tasks ) { var graph = { tasks : { } , roots : [ ] , leaves : [ ] , resources : [ ] , depth : 0 , end : 0 } ; for ( var i = 0 , len = tasks . length ; i < len ; i ++ ) { var t = tasks [ i ] ; graph . tasks [ t . id ] = { id : t . id , duration : t . duration , priority : t . priority , schedule : t . schedule , minSchedule : t . minSchedule , dependsOn : t . dependsOn , resources : t . resources } ; } setResources ( graph ) ; setRequiredBy ( graph . tasks ) ; setRootsAndLeaves ( graph ) ; setDepth ( graph , graph . leaves , 0 ) ; graph . depth += 1 ; // increment depth so it is 1 based forwardPass ( graph , { } , graph . roots , 0 ) ; setEnd ( graph , graph . leaves ) ; backwardPass ( graph , { } , graph . leaves , graph . end ) ; return graph ; }
Starting point for creating the dependency graph, clones the tasks and
then fills out the graph properties.
Starting point for creating the dependency graph clones the tasks and then fills out the graph properties .