Week 8

Dad Joke

What is brown and sticky?

A stick.

Housekeeping

  • Social Search assignment
    • Try to find someone with driver’s license from HI
    • No group texts
    • Diagram search network
    • Instructions on wiki

Also upcoming

  • Visualization Challenge
    • Start from existing dataset (Dutch school student behavior or Harry Potter)
    • Come up with a question
    • Create a network visualization that helps to answer that question
    • Working in pairs is great

Anatomy of ggraph

G |> 
activate(nodes) |> 
mutate(centrality = centrality_eigen()) |> 
ggraph(layout = 'kk') + 
geom_edge_fan(aes(width=weight), color = 'gray') + 
geom_node_point(aes(size=centrality), color = 'gold')

Loads the graph, which is stored as the variable G (the |> sends the output to the next line)

Selects the nodes “spreadsheet” to edit. To activate the edges, run activate(edges)

Calculates the eigenvector centrality and saves it as a new column in the nodes spreadsheet. Note that we keep using |> until we get to ggraph()

Tells R we want to take the network and make a plot from it. This is where we set the layout

Remember to add edges first.

The first argument is the “aesthetic mapping” - this maps aspects of the plot to variables in your data. In this case, we change the width of the edges based on the variable “weight”, which must be in our edges “spreadsheet”

We can also change the look of the plot universally. These options go outside of aes()

This code does similar operations to the nodes. It changes the size based on the centrality (which we calculated and defined in line 3) and changes the color of all nodes to gold

Review Questions

  • What is a “path”? What is the “path length” of a path?
  • What is the “geodesic distance” or “diameter” of a network?
  • What is triadic closure?
  • Why would we expect networks with high triadic closure to have high geodesic distance?
  • What was the Travers and Milgram experiment?
  • How can we have such high triadic closure but still have short path lengths? What was the key insight from Watts and Strogatz?

Thursday plan

  • Troubled Lands game or R?

R Co-working time

# A tbl_graph: 58 nodes and 967 edges
#
# An undirected simple graph with 1 component
#
# Node Data: 58 × 1 (active)
   friendship_prop
             <dbl>
 1             NaN
 2             NaN
 3             NaN
 4             NaN
 5             NaN
 6             NaN
 7             NaN
 8             NaN
 9             NaN
10             NaN
# ℹ 48 more rows
#
# Edge Data: 967 × 3
   from    to weight
  <int> <int>  <dbl>
1     1     3      2
2     1     4      1
3     1     7      2
# ℹ 964 more rows