Skip to article frontmatterSkip to article content

Phase 1: Link Fundamentals

Learning Objectives

By the end of this phase, you will be able to:

Conceptual Frame

Before we model polarization, let’s learn how to represent relationships in NetLogo. Links are how we show that two people are connected—they have a relationship. Think of your own social network: you have friends, and your friends have friends. Links represent those friendships.

Links are the innovation that makes this module different from previous modules. In earlier modules (segregation, contagion), agents interacted based on proximity—who was nearby. Now, agents interact through choice. People link to whom they want to connect with. This opens up entirely new possibilities for modeling social phenomena where relationships matter.

Key Concepts in Phase 1

Undirected links represent symmetric relationships (friendship, collaboration, mutual following):

Directed links represent asymmetric relationships (following, parent-child, authority):

In the polarization model, we use undirected links because friendship and social influence are symmetric.

Just like turtles can have properties, links can too:

undirected-link-breed [social-bonds social-bond]
social-bonds-own [strength]

This creates a link type called social-bonds with a property called strength. This allows us to track characteristics of relationships, not just their existence.

Accessing Neighbors

Once links exist, accessing connected turtles is easy:

ask turtle 0 [
  ask link-neighbors [set color green]  ; Highlight all neighbors
]

link-neighbors is incredibly useful—it returns an agentset of all turtles connected to the asking turtle.

Starter Code for Phase 1

breed [people person]
undirected-link-breed [social-bonds social-bond]

people-own [opinion]
social-bonds-own [strength]

to setup
  clear-all
  
  ; Create 20 people with random opinions
  create-people 20 [
    set opinion random 100
    setxy random-xcor random-ycor
    set size 1.5
    set color blue
  ]
  
  ; Each person creates links to 3 random others
  ask people [
    create-social-bonds-with n-of 3 other people [
      set strength random-float 1.0  ; Random strength 0-1
      set color grey
    ]
  ]
  
  reset-ticks
end

to go
  tick
end

After creating this code, add a Setup and Go button to run the model. When you click Setup, you should see 20 blue turtles connected by grey links.

Classroom Activities - Phase 1

Activity 1.1: Explore the Network

Students run the setup and explore:

Learning point: Links are agents too; they can be modified just like turtles.

Add a command button called highlight-neighbors with this code:

to highlight-neighbors
  ask people [set color blue]  ; Reset all to blue
  ask one-of people [
    ask link-neighbors [set color green]
  ]
end

Answer:

Learning point: link-neighbors gives us access to interaction partners.

Add this code to your Code tab and create a button show-link-info to call it:

to show-link-info
  let example-link one-of links
  ask example-link [
    show (word "Link between turtle " end1 " and turtle " end2)
    show (word "Strength: " strength)
  ]
end

Answer:

Learning point: Links connect turtles, and we can reference those turtles through end1 and end2.

Add this code to your Code tab and create a button create-links-by-color to call it:

to create-links-by-color
  ask people with [color = blue] [
    create-social-bonds-with other people with [color = blue] [
      set strength 0.8
      set color blue
    ]
  ]
end

Answer:

Learning point: We can use conditions to control link formation.


Assessment - Phase 1

Students should be able to:


Final Code

The final code for Phase 1 can be found here.