public void generateBAModel() {
        for (int iNode1 = nInitialNodes; iNode1 < nNodes; iNode1++) {
            /* Creates a node. */
            final Node aNewNode = new Node(iNode1);
            networkStructurer.getNodeList().add(aNewNode);
            
            /* Generates and stores the node's location. */
            networkStructurer.getNodeLocationMap().put(iNode1,
                    new double[] {Math.random(), Math.random()});
            
            /*
             * Attaches the new node to a predefined number of other nodes
             * following a distribution proportional to the vertex degree. If
             * the number of nodes in the network is less than the predefined
             * number of links to add at each step, then lower the latter to
             * match the number of nodes until this number increases to the point
             * where the full number of links at each step can be used.
             *
             * The "size - 1" in the test condition and allocation of number of
             * links to add at each step is to account for the fact that we
             * created and added a node to the network earlier in this method.
             */
            int nLinksToAddAtEachStepCounter;
            
            if ((networkStructurer.getNodeList().size() - 1) < nLinksToAddAtEachStep) {
                nLinksToAddAtEachStepCounter =
                        networkStructurer.getNodeList().size() - 1;
            }
            else {
                nLinksToAddAtEachStepCounter = nLinksToAddAtEachStep;
            }
            
            int aRandomNodeID;
            Node aRandomNode;
            Link aNewLink;
            
            while (nLinksToAddAtEachStepCounter > 0) {
                /* Chooses a random node in the network. */
                aRandomNodeID =
                        (int) Math.floor(Math.random() *
                                networkStructurer.getNodeList().size());
                aRandomNode =
                        networkStructurer.getNodeList().get(aRandomNodeID);
                
                /*
                 * Checks that the total number of links in the network is greater
                 * than zero to avoid a division by zero error. This could arise
                 * if only one node is present.
                 */
                if (nTotalLinks > 0) {
                    linkProbability =
                            (double) aRandomNode.degree() / nTotalLinks;
                }
                else {
                    linkProbability = 1;
                }
                
                /*
                 * Generates link.
                 *
                 * First, it makes sure that the link is not a self-link
                 * (i.e. a link that links the node that was just created back
                 * to itself) and that the link does not already exist.
                 */
                if ((Math.random() < linkProbability) &&
                        (aNewNode.getNodeID() != aRandomNode.getNodeID()) &&
                        (!aNewNode.isConnectedTo(aRandomNode))) {
                    aNewLink =
                            new Link(aNewNode.getNodeID(), aRandomNode
                                    .getNodeID(), networkStructurer);
                    
                    aNewNode.addLinkToLinkSet(aNewLink);
                    aRandomNode.addLinkToLinkSet(aNewLink);
                    
                    nTotalLinks++;
                    nLinksToAddAtEachStepCounter--;
                }
            }
        }
    }