public Net clone () {
        Net newNet = new Net();

        //clone all the nodes...
        for (Node node : this._nodes) {
            Node newNode = node.clone();
            newNet.addNode(newNode);
            // if it's an input or an output, put it in the right place
            if (newNode instanceof InputNode) newNet.addInput((InputNode) newNode);
            if (newNode instanceof OutputNode) newNet.addOutput((OutputNode) newNode);
        }
        
        // Clone the links, matching source and destination with corresponding IDs
        for (Link link : this._links) {
            if (link.getWeight() != 0) { //Dont' clone links with values of 0, I guess...
                Node source = newNet.getNodeForId(link.getSource().getId());
                Node dest = newNet.getNodeForId(link.getDestination().getId());
                Link newLink = link.clone(source, dest);
                newNet.addLink(newLink);
            }
        }

        newNet.setTopId(this._topId);

        newNet.sortNodes(); //Sort the nodes for more optimal access

        return newNet;
    }