Python Graphlib Module add(node,*predecessors)

Python Graphlib Module add(node,*predecessors)



This method is used to add a new node and its   predecessors to the graph.(both the node and all elements  are hashable).
 add(5,2) - adds a new node of value 5 and its   predecessors 2 to the graph.

 add(10,2,1) - adds a new node of value 10 and its   predecessors 2,1 to the graph.

->If add method is called multiple times with same node argument ,the

 set of dependencies will be the union of dependencies passed in .




   the set of dependencies for a node 5 is {1,2,6,7}

->we can add a node with no dependencies(predecessors  are not     provided).

 example: add(10)-it simply adds a node of value 10 with no 


->If we mention a new node (which is not included before in the 

  graph)among the predecessors, the new node will be added to the

 graph with no predecessors of its own.

 example : add(3,4)-here 4 is new node mentioned among the 

  predecessors, then it will added to the graph.

Note:if you call add(node*predecessors) after prepare() ,it raises valueerror.