### layout-tutte

#### layout-tutte turtle-set link-set radius

The turtles that are connected by links in link-set but not included in turtle-set are placed in a circle layout with the given radius. There should be at least 3 agents in this agentset.

The turtles in turtle-set are then laid out in the following manner: Each turtle is placed at centroid (or barycenter) of the polygon formed by its linked neighbors. (The centroid is like a 2-dimensional average of the coordinates of the neighbors.)

(The purpose of the circle of "anchor agents" is to prevent all the turtles from collapsing down to one point.)

After a few iterations of this, the layout will stabilize.

This layout is named after the mathematician William Thomas Tutte, who proposed it as a method for graph layout.

    to make-a-tree
      set-default-shape turtles "circle"
      crt 6
      ask turtle 0 [
        create-link-with turtle 1
        create-link-with turtle 2
        create-link-with turtle 3
      ]
      ask turtle 1 [
        create-link-with turtle 4
        create-link-with turtle 5
      ]
      ; place all the turtles with just one
      ; neighbor on the perimeter of a circle
      ; and then place the remaining turtles inside
      ; this circle, spread between their neighbors.
      repeat 10 [ layout-tutte (turtles with [link-neighbors = 1]) links 12 ]
    end

Take me to the full NetLogo Dictionary