Week 2 Challenge Instructions

challenge_2
Describing the Basic Structure of a Network
Author

Yakub Rabiutheen

Published

March 5, 2023

Code
library(readr)
Warning: package 'readr' was built under R version 4.1.3
Code
library(igraph)
Warning: package 'igraph' was built under R version 4.1.3

Attaching package: 'igraph'
The following objects are masked from 'package:stats':

    decompose, spectrum
The following object is masked from 'package:base':

    union

Challenge Overview

For my Challenges , I will be doing the Game of Thrones Likes vs Dislike Dataset.

Code
got_like_dislike <- read_csv("_data/got/got_like_dislike.csv")
Rows: 46 Columns: 49
-- Column specification --------------------------------------------------------
Delimiter: ","
chr  (3): Current house, Former house, Name
dbl (46): Lysa Arryn, Petyr Baelish, Joffrey Baratheon, Margaery Tyrell, Ren...

i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
  1. List and inspect List the objects to make sure the datafiles are working properly.

Below are the list of Objects in the Game of Thrones Like_Dislike Dataset

2.Network Size What is the size of the network? You may use vcount and ecount.

First I will transform this into an igraph object

Code
got_like_dislike.ig <- graph_from_data_frame(got_like_dislike)
Warning in graph_from_data_frame(got_like_dislike): In `d' `NA' elements were
replaced with string "NA"
Code
vcount(got_like_dislike.ig)
[1] 11
Code
ecount(got_like_dislike.ig)
[1] 46

This Network has 11 vertices and 46 edges.

3.Network features Are these networks weighted, directed, and bipartite?

Code
is.bipartite(got_like_dislike.ig)
[1] FALSE
Code
is.directed(got_like_dislike.ig)
[1] TRUE
Code
is.weighted(got_like_dislike.ig)
[1] FALSE

This Network is a Directed, NonWeigthed and NonBipartite netowrk.

4.Network Attributes Now, using commands from either statnet or igraph, list the vertex and edge attributes.

Below are the Network Attributes

Code
igraph::vertex_attr_names(got_like_dislike.ig)
[1] "name"

Here are the Names of Characters being used in Dislike vs Like

Code
igraph::edge_attr_names(got_like_dislike.ig)
 [1] "Name"                  "Lysa Arryn"            "Petyr Baelish"        
 [4] "Joffrey Baratheon"     "Margaery Tyrell"       "Renly Baratheon"      
 [7] "Robert Baratheon"      "Stannis Baratheon"     "Brienne of Tarth"     
[10] "Bronn"                 "Gregor Clegane"        "Sandor Clegane"       
[13] "Xaro Xhoan Daxos"      "Gendry"                "Balon Greyjoy"        
[16] "Theon Greyjoy"         "Jaqen H'ghar"          "Hodor"                
[19] "Khal Drogo"            "Cersei Lannister"      "Jaime Lannister"      
[22] "Lancel Lannister"      "Tyrion Lannister"      "Tywin Lannister"      
[25] "Maester Luwin"         "Melisandre"            "Jeor Mormont"         
[28] "Jorah Mormont"         "Osha"                  "Podrick Payne"        
[31] "Pyat Pree"             "Grand Maester Pycelle" "Ros"                  
[34] "Davos Seaworth"        "Shae"                  "Jon Snow"             
[37] "Arya Stark"            "Bran Stark"            "Catelyn Stark"        
[40] "Robb Stark"            "Sansa Stark"           "Daenerys Targaryen"   
[43] "Viserys Targaryen"     "Samwell Tarly"         "Loras Tyrell"         
[46] "Varys"                 "Eddard Stark"         

Dyad Census

Code
igraph::dyad.census(got_like_dislike.ig)
$mut
[1] 1

$asym
[1] 12

$null
[1] 42

It’s interesting that lot of Null values, which means there are Characters that no one Likes or Dislikes. Which would make sense as some characters such as Khal Dago don’t have any interaction with most GOT characters.

Transtivity

Code
transitivity(got_like_dislike.ig)
[1] 0.2368421
Code
transitivity(got_like_dislike.ig, type = 'global')
[1] 0.2368421

A Global Transitvity of 0.2368 indicates that there are some local clusters or communities in the network, but they are not highly interconnected or cohesive.

Code
transitivity(got_like_dislike.ig, type = 'average') 
[1] 0.5867347

The average transitivity value of 0.5867347 suggests that there may be certain nodes or subgroups of nodes in the network that have a much higher level of clustering or tendency to form triangle.

Now I will look at Path Length , Number of Components and number of nodes in each connected component of the network.

Code
average.path.length(got_like_dislike.ig,directed = T)
[1] 1.3
Code
igraph::components(got_like_dislike.ig)$no
[1] 1
Code
igraph::components(got_like_dislike.ig)$csize
[1] 11

1.The average path length of 1.3 indicates relatively small and tightly interconnected network. 2. The value of 1 indicates that there is only one connected component in the network, which means that all nodes in the network are connected to each other by paths. 3.There are 11 nodes in the largest connected component of the network. This indicates that the network is highly connected, and there are no isolated nodes or subgroups of nodes that are disconnected from the rest of the network.