Introduction

Social network analysis is used to study how people are connected. In a network, each person is represented by a node, and each relationship between two people is represented by an edge.

For this exercise, I created a personal social network using myself, my parents, my siblings, and my best friend. The purpose of the analysis is to understand how my family relationships are structured, identify the most connected people, and examine how information could move through the network.

Load Required Packages

library(tidyverse)
library(igraph)
library(knitr)
library(kableExtra)
library(scales)

Create the People Table

The network contains ten people. Most belong to the family group, while one person is categorized as a friend.

people <- tibble(
  name = c(
    "Leilani",
    "Sister1",
    "Mom",
    "Dad",
    "Sister2",
    "Sister3",
    "Sister4",
    "Brother1",
    "Brother2",
    "Best Friend"
  ),
  group = c(
    "Self",
    "Family",
    "Family",
    "Family",
    "Family",
    "Family",
    "Family",
    "Family",
    "Family",
    "Friend"
  )
)

people %>%
  kable(
    caption = "People Included in My Social Network",
    col.names = c("Person", "Relationship Group")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
People Included in My Social Network
Person Relationship Group
Leilani Self
Sister1 Family
Mom Family
Dad Family
Sister2 Family
Sister3 Family
Sister4 Family
Brother1 Family
Brother2 Family
Best Friend Friend

Create the Relationship Table

The relationship table reflects my family structure:

  • Both parents are connected to Sister1 and Sister2.
  • Mom is connected to Brother1.
  • Dad is connected to Brother2, Sister3, and Sister4.
  • I am connected to every person in the network.
  • My best friend is connected to me and Sister1.
relationships <- tribble(
  ~from,         ~to,

  # Leilani's direct relationships
  "Leilani",     "Mom",
  "Leilani",     "Dad",
  "Leilani",     "Sister1",
  "Leilani",     "Sister2",
  "Leilani",     "Sister3",
  "Leilani",     "Sister4",
  "Leilani",     "Brother1",
  "Leilani",     "Brother2",
  "Leilani",     "Best Friend",

  # Connection between parents
  "Mom",         "Dad",

  # Children shared by both parents
  "Mom",         "Sister1",
  "Dad",         "Sister1",
  "Mom",         "Sister2",
  "Dad",         "Sister2",

  # Mom's connection
  "Mom",         "Brother1",

  # Dad's connections
  "Dad",         "Brother2",
  "Dad",         "Sister3",
  "Dad",         "Sister4",

  # Selected sibling relationships
  "Sister1",     "Sister2",
  "Sister2",     "Sister3",
  "Sister3",     "Sister4",
  "Brother1",    "Brother2",

  # Best friend connection
  "Sister1",     "Best Friend"
)

relationships %>%
  kable(
    caption = "Relationships Included in the Network",
    col.names = c("Person 1", "Person 2")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
Relationships Included in the Network
Person 1 Person 2
Leilani Mom
Leilani Dad
Leilani Sister1
Leilani Sister2
Leilani Sister3
Leilani Sister4
Leilani Brother1
Leilani Brother2
Leilani Best Friend
Mom Dad
Mom Sister1
Dad Sister1
Mom Sister2
Dad Sister2
Mom Brother1
Dad Brother2
Dad Sister3
Dad Sister4
Sister1 Sister2
Sister2 Sister3
Sister3 Sister4
Brother1 Brother2
Sister1 Best Friend

Build the Network

The network is undirected because each relationship is treated as mutual.

my_network <- graph_from_data_frame(
  d = relationships,
  vertices = people,
  directed = FALSE
)

my_network
## IGRAPH 7a699db UN-- 10 23 -- 
## + attr: name (v/c), group (v/c)
## + edges from 7a699db (vertex names):
##  [1] Leilani --Mom         Leilani --Dad         Leilani --Sister1    
##  [4] Leilani --Sister2     Leilani --Sister3     Leilani --Sister4    
##  [7] Leilani --Brother1    Leilani --Brother2    Leilani --Best Friend
## [10] Mom     --Dad         Sister1 --Mom         Sister1 --Dad        
## [13] Mom     --Sister2     Dad     --Sister2     Mom     --Brother1   
## [16] Dad     --Brother2    Dad     --Sister3     Dad     --Sister4    
## [19] Sister1 --Sister2     Sister2 --Sister3     Sister3 --Sister4    
## [22] Brother1--Brother2    Sister1 --Best Friend

The network contains 10 people and 23 relationships.

Visualize the Network

The first graph displays the people and their connections. Each color represents a relationship group.

set.seed(550)

group_colors <- c(
  "Self" = "#E76F51",
  "Family" = "#2A9D8F",
  "Friend" = "#E9C46A"
)

V(my_network)$color <- group_colors[V(my_network)$group]
V(my_network)$size <- ifelse(V(my_network)$name == "Leilani", 34, 27)

plot(
  my_network,
  layout = layout_with_fr(my_network),
  vertex.label = V(my_network)$name,
  vertex.label.color = "black",
  vertex.label.cex = 0.85,
  vertex.frame.color = "white",
  edge.color = "gray65",
  edge.width = 1.5,
  main = "My Family and Friendship Network"
)

legend(
  "topleft",
  legend = names(group_colors),
  col = group_colors,
  pch = 19,
  pt.cex = 1.5,
  bty = "n"
)

The graph shows that I am positioned at the center of the network because I am directly connected to every person. Mom and Dad also have several connections because they are connected to different groups of children. My best friend is connected to the network through me and Sister1.

Degree Centrality

Degree centrality measures the number of direct connections each person has.

degree_scores <- tibble(
  person = V(my_network)$name,
  group = V(my_network)$group,
  degree = degree(my_network)
) %>%
  arrange(desc(degree))

degree_scores %>%
  kable(
    caption = "Degree Centrality Results",
    col.names = c("Person", "Group", "Direct Connections")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
Degree Centrality Results
Person Group Direct Connections
Leilani Self 9
Dad Family 7
Sister1 Family 5
Mom Family 5
Sister2 Family 5
Sister3 Family 4
Sister4 Family 3
Brother1 Family 3
Brother2 Family 3
Best Friend Friend 2
degree_scores %>%
  ggplot(aes(x = reorder(person, degree), y = degree, fill = group)) +
  geom_col() +
  coord_flip() +
  scale_fill_manual(values = group_colors) +
  labs(
    title = "Number of Direct Connections by Person",
    x = NULL,
    y = "Degree Centrality",
    fill = "Group"
  ) +
  theme_minimal()

Leilani has the highest degree centrality because she is connected to all nine other people. Mom and Dad are also highly connected because they each have relationships with several children.

Betweenness Centrality

Betweenness centrality measures how often a person lies on the shortest path between other people.

betweenness_scores <- tibble(
  person = V(my_network)$name,
  group = V(my_network)$group,
  betweenness = round(
    betweenness(my_network, normalized = TRUE),
    3
  )
) %>%
  arrange(desc(betweenness))

betweenness_scores %>%
  kable(
    caption = "Normalized Betweenness Centrality Results",
    col.names = c("Person", "Group", "Betweenness")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
Normalized Betweenness Centrality Results
Person Group Betweenness
Leilani Self 0.366
Dad Family 0.120
Sister1 Family 0.042
Mom Family 0.037
Sister2 Family 0.019
Sister3 Family 0.009
Brother1 Family 0.009
Brother2 Family 0.009
Sister4 Family 0.000
Best Friend Friend 0.000

Leilani is expected to have the highest betweenness because many paths between family members and the best friend pass through her. Mom and Dad may also have important bridging roles because they connect different sets of children.

Closeness Centrality

Closeness centrality measures how close each person is to everyone else in the network.

closeness_scores <- tibble(
  person = V(my_network)$name,
  group = V(my_network)$group,
  closeness = round(
    closeness(my_network, normalized = TRUE),
    3
  )
) %>%
  arrange(desc(closeness))

closeness_scores %>%
  kable(
    caption = "Normalized Closeness Centrality Results",
    col.names = c("Person", "Group", "Closeness")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
Normalized Closeness Centrality Results
Person Group Closeness
Leilani Self 1.000
Dad Family 0.818
Sister1 Family 0.692
Mom Family 0.692
Sister2 Family 0.692
Sister3 Family 0.643
Sister4 Family 0.600
Brother1 Family 0.600
Brother2 Family 0.600
Best Friend Friend 0.562

Leilani should have the highest closeness score because she can reach every person directly. Mom and Dad should also have relatively high closeness scores because they are connected to several people in the family.

Combined Centrality Results

centrality_results <- tibble(
  person = V(my_network)$name,
  group = V(my_network)$group,
  degree = degree(my_network),
  betweenness = round(
    betweenness(my_network, normalized = TRUE),
    3
  ),
  closeness = round(
    closeness(my_network, normalized = TRUE),
    3
  )
) %>%
  arrange(desc(degree), desc(betweenness))

centrality_results %>%
  kable(
    caption = "Combined Network Centrality Results",
    col.names = c(
      "Person",
      "Group",
      "Degree",
      "Betweenness",
      "Closeness"
    )
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
Combined Network Centrality Results
Person Group Degree Betweenness Closeness
Leilani Self 9 0.366 1.000
Dad Family 7 0.120 0.818
Sister1 Family 5 0.042 0.692
Mom Family 5 0.037 0.692
Sister2 Family 5 0.019 0.692
Sister3 Family 4 0.009 0.643
Brother1 Family 3 0.009 0.600
Brother2 Family 3 0.009 0.600
Sister4 Family 3 0.000 0.600
Best Friend Friend 2 0.000 0.562

Network Density

Network density compares the number of existing relationships with the total number of possible relationships.

network_density <- edge_density(my_network)

network_density
## [1] 0.5111111

The density of this network is 0.511. The value is below 1 because not every person is directly connected to every other person. This is realistic because some siblings share the same parent while others are connected through different parents.

Network Diameter and Average Path Length

The network diameter is the greatest number of steps between any two people. The average path length is the average number of connections required to move from one person to another.

network_diameter <- diameter(my_network)
average_path <- mean_distance(my_network)

path_summary <- tibble(
  measure = c("Network diameter", "Average path length"),
  value = c(network_diameter, round(average_path, 3))
)

path_summary %>%
  kable(
    caption = "Network Distance Measures",
    col.names = c("Measure", "Value")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
Network Distance Measures
Measure Value
Network diameter 2.000
Average path length 1.489

Because Leilani is connected to everyone, the network should have a relatively small diameter and average path length. People who are not directly connected can still reach one another through Leilani or another family member.

Community Detection

Community detection identifies groups of people who are more closely connected to each other.

communities <- cluster_louvain(my_network)

community_results <- tibble(
  person = V(my_network)$name,
  original_group = V(my_network)$group,
  detected_community = membership(communities)
) %>%
  arrange(detected_community, person)

community_results %>%
  kable(
    caption = "Detected Communities in the Network",
    col.names = c("Person", "Original Group", "Detected Community")
  ) %>%
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE
  )
Detected Communities in the Network
Person Original Group Detected Community
Brother1 Family 1
Brother2 Family 1
Leilani Self 1
Mom Family 1
Best Friend Friend 2
Sister1 Family 2
Dad Family 3
Sister2 Family 3
Sister3 Family 3
Sister4 Family 3
set.seed(550)

plot(
  communities,
  my_network,
  layout = layout_with_fr(my_network),
  vertex.label = V(my_network)$name,
  vertex.label.color = "black",
  vertex.label.cex = 0.85,
  vertex.size = 28,
  vertex.frame.color = "white",
  edge.color = "gray65",
  main = "Communities Detected in My Social Network"
)

The community results may separate the network according to the family members connected more closely with Mom, the family members connected more closely with Dad, and the friend connection.

Interpretation of Findings

My social network contains ten people and is centered around family relationships. I am directly connected to every person in the network, which gives me the highest degree centrality. This means I have the largest number of immediate relationships.

My parents also hold important positions. Mom is connected to Sister1, Sister2, and Brother1, while Dad is connected to Sister1, Sister2, Brother2, Sister3, and Sister4. Because Sister1 and Sister2 are connected to both parents, they help link the two sides of the family.

My best friend has fewer connections than most family members because she is directly connected only to me and Sister1. However, she is still part of the larger network because those two connections allow her to reach everyone else indirectly.

The analysis demonstrates that people can be influential in different ways. I have the most direct connections and act as the main bridge across the whole network. Mom and Dad connect different groups of children, while Sister1 and Sister2 help connect both sides of the family.

Marketing Application

Businesses can use similar network analysis methods to identify customers who are highly connected or who act as bridges between social groups. A person with high degree centrality may be able to share information with many people directly. A person with high betweenness may be useful for spreading information between groups that would otherwise remain separate.

Conclusion

This exercise demonstrates how social network analysis can be applied to real family and friendship relationships. Degree centrality identifies the people with the most direct connections, betweenness centrality identifies the people who act as bridges, and closeness centrality shows who can reach the rest of the network most efficiently.

Overall, Leilani is the central person in the network because she is connected to everyone. Mom and Dad also have important roles because they connect different groups of children. The results show how social network analysis can help explain relationship structure, influence, and communication within a real-world network.

References

Csardi, G., & Nepusz, T. (2006). The igraph software package for complex network research. InterJournal, Complex Systems, 1695.

Xu, Z. J. (2026). Six degrees of connection: A marketing student’s guide to social network analysis in R. RPubs.