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.graph.*;
22 import peersim.config.Configuration;
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
31 public class WireRingLattice extends WireGraph {
33 // --------------------------------------------------------------------------
35 // --------------------------------------------------------------------------
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.
43 private static final String PAR_K = "k";
45 // --------------------------------------------------------------------------
47 // --------------------------------------------------------------------------
53 // --------------------------------------------------------------------------
55 // --------------------------------------------------------------------------
58 * Standard constructor that reads the configuration parameters.
59 * Invoked by the simulation engine.
60 * @param prefix the configuration prefix for this class
62 public WireRingLattice(String prefix)
65 k = Configuration.getInt(prefix + "." + PAR_K);
68 //--------------------------------------------------------------------------
70 //--------------------------------------------------------------------------
72 /** calls {@link GraphFactory#wireRingLattice}. */
73 public void wire(Graph g)
75 GraphFactory.wireRingLattice(g, k);
78 //--------------------------------------------------------------------------