Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #1 from mquinson/master
[simgrid.git] / contrib / psg / src / peersim / dynamics / WireRingLattice.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.graph.*;
22 import peersim.config.Configuration;
23
24 /**
25  * Takes a {@link peersim.core.Linkable} protocol and adds edges that
26  * define a ring lattice.
27  * Note that no connections are removed, they are only added. So it can be used
28  * in combination with other initializers.
29  * @see  GraphFactory#wireRingLattice
30  */
31 public class WireRingLattice extends WireGraph {
32
33 // --------------------------------------------------------------------------
34 // Parameters
35 // --------------------------------------------------------------------------
36
37 /**
38  * The "lattice parameter" of the graph. The out-degree of the graph is equal to
39  * 2k. See {@link GraphFactory#wireRingLattice} (to which this parameter is
40  * passed) for further details.
41  * @config
42  */
43 private static final String PAR_K = "k";
44
45 // --------------------------------------------------------------------------
46 // Fields
47 // --------------------------------------------------------------------------
48
49 /**
50  */
51 private final int k;
52
53 // --------------------------------------------------------------------------
54 // Initialization
55 // --------------------------------------------------------------------------
56
57 /**
58  * Standard constructor that reads the configuration parameters.
59  * Invoked by the simulation engine.
60  * @param prefix the configuration prefix for this class
61  */
62 public WireRingLattice(String prefix)
63 {
64         super(prefix);
65         k = Configuration.getInt(prefix + "." + PAR_K);
66 }
67
68 //--------------------------------------------------------------------------
69 //Public methods
70 //--------------------------------------------------------------------------
71
72 /** calls {@link GraphFactory#wireRingLattice}. */
73 public void wire(Graph g)
74 {
75         GraphFactory.wireRingLattice(g, k);
76 }
77
78 //--------------------------------------------------------------------------
79
80 }