Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
peersimgrid release 1.0
[simgrid.git] / contrib / psg / src / peersim / dynamics / WireScaleFreeBA.java
1 /*
2  * Copyright (c) 2003-2005 The BISON Project
3  *
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.
7  *
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.
12  *
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.
16  *
17  */
18
19 package peersim.dynamics;
20
21 import peersim.config.*;
22 import peersim.core.*;
23 import peersim.graph.*;
24
25 /**
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
36 */
37 public class WireScaleFreeBA extends WireGraph {
38
39
40 // ================ constants ============================================
41 // =======================================================================
42
43 /**
44  * The number of edges added to each new node (apart from those forming the 
45  * initial network).
46  * Passed to {@link GraphFactory#wireScaleFreeBA}.
47  * @config
48  */
49 private static final String PAR_DEGREE = "k";
50
51
52 // =================== fields ============================================
53 // =======================================================================
54
55 /** Parameter of the BA model. */
56 private int k;
57
58 // ===================== initialization ==================================
59 // =======================================================================
60
61 /**
62  * Standard constructor that reads the configuration parameters.
63  * Invoked by the simulation engine.
64  * @param prefix the configuration prefix for this class
65 */
66 public WireScaleFreeBA(String prefix)
67 {
68         super(prefix);
69         k = Configuration.getInt(prefix + "." + PAR_DEGREE);
70 }
71
72
73 // ======================== methods =======================================
74 // ========================================================================
75
76
77 /** calls {@link GraphFactory#wireScaleFreeBA}.*/
78 public void wire(Graph g) {
79         
80         GraphFactory.wireScaleFreeBA(g,k,CommonState.r );
81 }
82
83 }
84