__layout-magspring

__layout-magspring turtle-set link-set spring-constant spring-length repulsion-constant magnetic-field-strength magnetic-field-type bidirectional?

Very similar to layout-spring, but with an added layer of complexity. The turtles in turtle-set attract and repel each other depending on the links (that are in link-set) between them, but there is also a magnetic field which the links try to align with.

The link-set is the set of links that exert forces on the turtles they are connected to. Turtles that are connected to links in the link agentset but are not included in the turtle agentset are treated as anchors. If there are no turtles with fixed positions the entire network will probably collapse on itself.

spring-constant is a measure of the "tautness" of the spring. (See layout-spring)

spring-length is the "zero-force" length or the natural length of the springs. (See layout-spring)

repulsion-constant is a measure of repulsion between the nodes. (See layout-spring)

magnetic-field-strength is the force of the magnetic field. (Reasonable values range from 0 to 1, but 0.05 is a good default.)

magnetic-field-type is a number in the range from 0 to 10. Choices are listed in the table below.

magnetic-field-type Description
NONE = 0 If no field is used, then this command works just like layout-spring.
NORTH = 1 Magnetic field runs toward the North
NORTHEAST = 2 Magnetic field runs toward the Northeast
EAST = 3 ...
SOUTHEAST= 4 ...
SOUTH = 5 ...
SOUTHWEST= 6 ...
WEST = 7 ...
NORTHWEST = 8 ...
POLAR = 9 Magnetic field runs outward at all angles from the origin.
CONCENTRIC = 10
Magnetic field runs clockwise around the origin in concentric circles.

If bidirectional? is true then links try to align with the magnetic field by pushing attached turtles both in the direction of the field, and in the opposite direction. Otherwise, the links just push in a single direction.

to make-a-tree
  set-default-shape turtles "circle"
  crt 5
  ask turtle 0 [ 
    create-link-with turtle 1
    create-link-with turtle 2
  ]
  ask turtle 1 [
    create-link-with turtle 3
    create-link-with turtle 4
  ]
  ; layout with a fairly strong SOUTH magnetic field
  repeat 50 [ __layout-magspring 
              turtles with [who != 0] links 0.3 4 1 .50 5 false ] 
end

Take me to the full NetLogo Dictionary