Load in DATA. This is the Airport DATA from the Google drive.

load(file = "USAirports.rda")


Looking at Nodes and Edges:

ls()
## [1] "network_edgelist" "network_igraph"   "network_nodes"    "network_statnet"
vcount(network_igraph)
## [1] 755
ecount(network_igraph)
## [1] 23473
print(network_statnet)
##  Network attributes:
##   vertices = 755 
##   directed = TRUE 
##   hyper = FALSE 
##   loops = FALSE 
##   multiple = FALSE 
##   bipartite = FALSE 
##   total edges= 8228 
##     missing edges= 0 
##     non-missing edges= 8228 
## 
##  Vertex attribute names: 
##     City Distance vertex.names 
## 
##  Edge attribute names not shown
#print(network_igraph)

Right off the bat, it looks like the igraph and statnet variables are showing different edges. The network igraph is showing 755 nodes and 23473 edges. The network statnet is showing 755 nodes, and 8228 edges.

Weighted, Directed, Single Mode Network?

is_bipartite(network_igraph)
## [1] FALSE
is_directed(network_igraph)
## [1] TRUE
is_weighted(network_igraph)
## [1] FALSE

Using the Network Igraph set, we have a single mode network, which is directed, and is not weighted.


Looking at Vertex and Edge Attributes:

vertex_attr_names(network_igraph)
## [1] "name"     "City"     "Position"
network::list.vertex.attributes(network_statnet)
## [1] "City"         "Distance"     "na"           "vertex.names"
edge_attr_names(network_igraph)
## [1] "Carrier"    "Departures" "Seats"      "Passengers" "Aircraft"  
## [6] "Distance"
network::list.edge.attributes(network_statnet)
## [1] "Aircraft"   "Carrier"    "Departures" "Distance"   "na"        
## [6] "Passangers" "Seats"      "weight"

Igraph Attribute Names: name, City, Position

Igraph edge names: Carrier, Departures, Seats, Passengers, Aircraft, Distance

Statnet attribute names: City, Distance, na, vertex.names

statnet edge names: Aircraft, Carrier, Departures, Distance, na, Passangers, Seats, weight


Accessing Attribute DATA:

V(network_igraph)$name %>% head()
## [1] "BGR" "BOS" "ANC" "JFK" "LAS" "MIA"
V(network_igraph)$City %>% head()
## [1] "Bangor, ME"    "Boston, MA"    "Anchorage, AK" "New York, NY" 
## [5] "Las Vegas, NV" "Miami, FL"
V(network_igraph)$Position %>% head()
## [1] "N444827 W0684941" "N422152 W0710019" "N611028 W1495947" "N403823 W0734644"
## [5] "N360449 W1150908" "N254736 W0801726"
(network_igraph)$Carrier %>% head()
## NULL
head(network_statnet %v% "vertex.names")
## [1] "1G4" "A23" "A27" "A29" "ABE" "ABI"
head(network_statnet %v% "City")
## [1] "Bangor, ME"    "Boston, MA"    "Anchorage, AK" "New York, NY" 
## [5] "Las Vegas, NV" "Miami, FL"
head(network_statnet %e% "weight")
## [1] "193"  "253"  "141"  "3135" "4097" "1353"


Summarizing Attribute DATA

summary(E(network_igraph)$Distance)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##       0     223     496     639     903    6089
summary(network_statnet %e% "Distance")
##    Length     Class      Mode 
##      8228 character character

The way the summary function worked on the statnet set makes me think the statnet dataset is incorrectly set up at the moment.
#### Dyad Census

dyad.census(network_igraph)
## $mut
## [1] 10449
## 
## $asym
## [1] 2574
## 
## $null
## [1] 271612
sna::dyad.census(network_statnet)
##       Mut Asym   Null
## [1,] 3605 1018 280012


Triad Census

triad.census(network_igraph)
##  [1] 68169544   665870  2427052     1445     1289     2465    15322    19171
##  [9]       91       39   114868      202      376      558     6422    18671
sna::triad.census(network_statnet)
##           003    012     102 021D 021U 021C  111D  111U 030T 030C    201 120D
## [1,] 68169544 712579 2380343 1445 1289 2465 15322 19171   91   39 114868  202
##      120U 120C  210   300
## [1,]  376  558 6422 18671


Transivity

transitivity(network_igraph)
## [1] 0.3384609
gtrans(network_statnet)
## [1] 0.3266617

The transitivity for igraph and statnet data sets were pretty close.

Local Transivity

first_five_names <- V(network_igraph)$name %>% head(5)
first_five_names
## [1] "BGR" "BOS" "ANC" "JFK" "LAS"
first_five_transivity <- transitivity(network_igraph, type = "local", vids = V(network_igraph)[first_five_names])

cbind(first_five_names,first_five_transivity)
##      first_five_names first_five_transivity
## [1,] "BGR"            "0.581818181818182"  
## [2,] "BOS"            "0.35292389068469"   
## [3,] "ANC"            "0.0824960338445267" 
## [4,] "JFK"            "0.385964912280702"  
## [5,] "LAS"            "0.223852116875373"
transitivity(network_igraph, type = "global")
## [1] 0.3384609
transitivity(network_igraph, type = "average")
## [1] 0.6452844

LA seems to have low transivity while BGR has the highest at .58.


Distances in the Network

distances(network_igraph, "BGR","BOS")
##     BOS
## BGR   1
distances(network_igraph,"BOS", "ANC")
##     ANC
## BOS   2
average.path.length(network_igraph)
## [1] 3.52743
average.path.length(network_igraph, directed = F)
## [1] 3.447169


Identifying Isolates

names(igraph::components(network_igraph))
## [1] "membership" "csize"      "no"
components(network_igraph)$no
## [1] 6
components(network_igraph)$csize
## [1] 745   2   2   3   2   1
components(network_igraph)$membership %>% head()
## BGR BOS ANC JFK LAS MIA 
##   1   1   1   1   1   1
#Isolates
isolates(network_statnet)
## [1] 166
as.vector(network_statnet %v% "vertex.names")[c(isolates(network_statnet))]
## [1] "DET"

Detroit seems to be the only isolate.