2 * Copyright (c) 2003-2005 The BISON Project
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 package peersim.dynamics;
21 import peersim.config.*;
22 import peersim.core.*;
23 import peersim.graph.*;
26 * This class contains the implementation of the Barabasi-Albert model
27 * of growing scale free networks. The original model is described in
28 * <a href="http://arxiv.org/abs/cond-mat/0106096">http://arxiv.org/abs/cond-mat/0106096</a>. It also contains the option of building
29 * a directed network, in which case the model is a variation of the BA model
30 * described in <a href="http://arxiv.org/pdf/cond-mat/0408391">
31 http://arxiv.org/pdf/cond-mat/0408391</a>. In both cases, the number of the
32 * initial set of nodes is the same as the degree parameter, and no links are
33 * added. The first added node is connected to all of the initial nodes,
34 * and after that the BA model is used normally.
35 * @see GraphFactory#wireScaleFreeBA
37 public class WireScaleFreeBA extends WireGraph {
40 // ================ constants ============================================
41 // =======================================================================
44 * The number of edges added to each new node (apart from those forming the
46 * Passed to {@link GraphFactory#wireScaleFreeBA}.
49 private static final String PAR_DEGREE = "k";
52 // =================== fields ============================================
53 // =======================================================================
55 /** Parameter of the BA model. */
58 // ===================== initialization ==================================
59 // =======================================================================
62 * Standard constructor that reads the configuration parameters.
63 * Invoked by the simulation engine.
64 * @param prefix the configuration prefix for this class
66 public WireScaleFreeBA(String prefix)
69 k = Configuration.getInt(prefix + "." + PAR_DEGREE);
73 // ======================== methods =======================================
74 // ========================================================================
77 /** calls {@link GraphFactory#wireScaleFreeBA}.*/
78 public void wire(Graph g) {
80 GraphFactory.wireScaleFreeBA(g,k,CommonState.r );