public PogNode chooseNeighborWeighted(TreeQualifier qualifier, Random generator, double beta) {
        Node editedNode = null;
        boolean isAdded = false;
        if (addableList.isEmpty() && removableList.isEmpty()) { // this is a null node; choose a node to add from the whole dataset
            isAdded = true;
            Set<Node> entireNodeList = qualifier.entireNodeList();
            int chosenIndex = generator.nextInt(entireNodeList.size());
            int i = 0;
            for (Node n : entireNodeList) {
                if (i++ == chosenIndex) {
                    editedNode = n;
                    break;
                }
            }
        } else { // pick from the candidate set
            // decide whether add or remove
            if (generator.nextDouble() > beta && !addableList.isEmpty()) {  // add a vertex to the subgraph   
                int chosenIndex = randomIndex(generator, addWeight);
                isAdded = true;
                editedNode = candidateArrayAdd[chosenIndex];
            } else {    // remove a vertex from the subgraph
                int chosenIndex = randomIndex(generator, removeWeight);
                editedNode = candidateArrayRemove[chosenIndex];
            }
        }

        // create a node with the new infomation
        PogNode q = null;
        if (isAdded) {
            q = recalcInfoAdded(editedNode, qualifier);
        } else {
            q = recalcInfoRemoved(editedNode, qualifier);
        }

        if (q != null) {
            candidateEditedNode = editedNode;
        }
        return q;
    }