Changes between Initial Version and Version 1 of Old/NodeHandler/Commands/defTopology


Ignore:
Timestamp:
Oct 7, 2006, 9:40:44 AM (18 years ago)
Author:
anonymous
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/NodeHandler/Commands/defTopology

    v1 v1  
     1[wiki:Documentation]
     2| [wiki:Documentation/NodeHandler NodeHandler]
     3| [wiki:Documentation/NodeHandler/Commands Commands]
     4| defTopology
     5
     6= defTopology: Define a Topology =
     7
     8This command defines a topology consisting of a set of nodes and noise injection settings to configure a specific topology. An experiment can normally only contain a single topology with noise settings, but may create additional topology declarations which are a sub set of the 'base' topology.
     9
     10== Syntax: defTopology(name, nodeArray = nil, &block = nil) ==
     11
     12  * '''name:''' Name of the defined topology.
     13  * '''nodeArray:''' Selects the nodes used in this topology.
     14  * '''block:''' Additional modifications on the create topology.
     15
     16The 'name' is a uri string identifying the topology. For instance, it can be used in 'defNodes' commands. The following naming convention is encouraged: ''projectName'':'''topo''':''topologyName''
     17
     18The 'nodeArray' defines which nodes are in the topology. The following array patterns are supported:
     19
     20  * [x,y]: Describes a single node at location x@y
     21  * [x1..x2, y]: Describes a set of nodes along a line starting at x1@y and ending at x2@y. For instance, [2..4, 5] defines the nodes [2,5], [3,5], [4,5].
     22  * [x, y1..y2]: Same as previous, but for the y coordinate.
     23  * [x1..x2, y1..y2]: This defines a rectangle area of nodes within the grid.
     24  * [[x1,y1], [x2,y2], [x3,y3]]: An arbitrary long list of single nodes. Obvioulsy, any entry in this list can also use any of the above defined syntaxes.
     25
     26The optional 'block' allows the experimenter to further configure the topology. The following commands are defined inside the block:
     27
     28#  * [wiki:Documentation/NodeHandler/Commands/NodeSet/image image=]
     29
     30== Usage ==
     31
     32{{{
     33# topology contains 1 node
     34defTopology('test:topo:origin', [1, 1])
     35
     36# nodes arranged in a circle
     37defTopology('test:topo:circle') { |t|
     38  # use simple 4-way algorithm
     39  radius = 8
     40  xCenter = 10
     41  yCenter = 10
     42
     43  r2 = radius * radius
     44  t.addNode(xCenter, yCenter + radius)
     45  t.addNode(xCenter, yCenter - radius)
     46  (1..radius).each { |x|
     47    y = (Math.sqrt(r2 - x*x) + 0.5).to_i
     48    t.addNode(xCenter + x, yCenter + y)
     49    t.addNode(xCenter + x, yCenter - y)
     50    t.addNode(xCenter - x, yCenter + y)
     51    t.addNode(xCenter - x, yCenter - y)
     52  }
     53}
     54}}}
     55
     56== See Also ==