# COM 411

## Today’s Dad Joke

• Why did the near-sighted man fall in the well?
• He couldn’t see that well

# Network Data and Network Types

## Homework

• Did you find someone with a Hawaiian driver’s license?
• How did it go?
• What were the challenges?
• Were there overlapping networks?

# Networks in R

• Powerful
• Reproducible
• Extensible

## Network Data

• What are the three main ways of representing networks?

## Matrices

sw = watts.strogatz.game(2, 4, 1, .2)
as_adjacency_matrix(sw)
## 16 x 16 sparse Matrix of class "dgCMatrix"
##
##  [1,] . . . 1 1 . . . 1 . . . . . . .
##  [2,] . . 1 . . 1 . . . . . . . 1 . .
##  [3,] . 1 . . . 1 . 1 . . . . . . . .
##  [4,] 1 . . . . . 1 1 . . . . . . . 1
##  [5,] 1 . . . . 1 . 1 . . . 1 . . . .
##  [6,] . 1 1 . 1 . . . . 1 . . . . . .
##  [7,] . . . 1 . . . 1 . . 1 . . . . .
##  [8,] . . 1 1 1 . 1 . . . . 1 . 1 . .
##  [9,] 1 . . . . . . . . 1 . 1 . . . .
## [10,] . . . . . 1 . . 1 . 1 . . 1 . .
## [11,] . . . . . . 1 . . 1 . 1 . . 1 .
## [12,] . . . . 1 . . 1 1 . 1 . 1 . . 1
## [13,] . . . . . . . . . . . 1 . 1 1 1
## [14,] . 1 . . . . . 1 . 1 . . 1 . 1 .
## [15,] . . . . . . . . . . 1 . 1 1 . 1
## [16,] . . . 1 . . . . . . . 1 1 . 1 .

## Edgelists

as_edgelist(sw)
##       [,1] [,2]
##  [1,]    1    9
##  [2,]    1    5
##  [3,]    2    3
##  [4,]    2    6
##  [5,]    8   14
##  [6,]    3    6
##  [7,]    1    4
##  [8,]    4    8
##  [9,]    5    6
## [10,]    5   12
## [11,]    4    7
## [12,]    6   10
## [13,]    7    8
## [14,]    7   11
## [15,]    5    8
## [16,]    8   12
## [17,]    9   10
## [18,]   13   15
## [19,]   10   11
## [20,]   10   14
## [21,]   11   12
## [22,]   11   15
## [23,]    9   12
## [24,]   12   16
## [25,]   13   14
## [26,]   12   13
## [27,]   14   15
## [28,]    2   14
## [29,]   15   16
## [30,]    3    8
## [31,]   13   16
## [32,]    4   16

## Graphs/plots/sociograms

plot(sw,
vertex.label.cex = .5
)

• Surveys
• Observation
• Trace data

# Network Types

## Ego networks

• Typically created from surveys
• Your family networks were ego networks
plot(make_ego_graph(sw, nodes = 1)[[1]])

## Extended ego networks

plot(
make_ego_graph(sw,
nodes = 1,
order = 2)[[1]])

## Bipartite Networks

• 20 random reddittors and their communities

## What does this data look like?

head(r)
## # A tibble: 6 x 3
##   author        subreddit          posts
##   <chr>         <chr>              <dbl>
## 1 Arutyh        Tulpas                44
## 2 Sankakugeri   wwesupercard          38
## 3 NotAReelclown bestoflegaladvice     43
## 4 NotAReelclown shittykickstarters    14
## 5 hangryharry   churning              19
## 6 Arutyh        Pathfinder_RPG        58

## Bipartite networks can be “projected”

• People who comment in the same communities
projections = bipartite_projection(G)
sr = projections[[1]]
people = projections[[2]]

people %>% delete.vertices(degree(.) < 1) %>%
plot_graph()

## Projections

sr %>% delete.vertices(degree(.) < 1) %>%
plot_graph()

V(sw)$gender = sample(c(1,2,3), length(V(sw)), replace = T) colors <- c('green','orange','red') V(sw)$color <- colors[as.integer(V(sw)$gender)] plot(sw ) ## Edge attributes • Usually this is weight #tmp = delete.edges(sr, which(E(sr)$weight < 2))
people %>%
delete.vertices(degree(.) < 1) %>%
plot(
layout = layout_with_fr(.),
vertex.size = 9,
vertex.label.cex = .4,
edge.width = E(.)\$weight
)

## Assignments

• Homework 3 (extended family network)
• Install R and RStudio (optional)