private void calculateNode(Node n, Set<Node> doneNodes, Set<Node> openNodes) throws Exception {
        try {
            if (!openNodes.contains(n)) {
                if (n.getType() != NodeType.INPUT) {
                    openNodes.add(n);
                }
                if (!doneNodes.contains(n)) {
                    for (int i = 0; i < n.getIncomingLinksNumber(); i++) {
                        calculateNode(n.getIncomingLink(i).getIn_node(), doneNodes, openNodes);
                    }
                }
                n.countOut();
                openNodes.remove(n);
                doneNodes.add(n);
            } else {
                throw new Exception("LOOP in calculateNode");
            }
        } catch (Exception exc) {
            System.out.println("==================================");
            System.out.println("ERROR : " + exc.getMessage());
            System.out.println(n.getNodeID());
            System.out.println(n.getType());
            System.out.println("IncomingLinks: ");
            /*for (int i = 0; i < n.getIncomingLinksNumber(); i++) {
             System.out.println("IN Node" + n.getIncomingLink(i).getIn_node().getNodeID() + n.getIncomingLink(i).getIn_node().getType());
             System.out.println("OUT Node" + n.getIncomingLink(i).getOut_node().getNodeID() + n.getIncomingLink(i).getOut_node().getType());
             System.out.println();
             }*/
            System.out.println("==================================");
        }
    }