We notice some colors are closer to each other than others. We might want to use a clustering algorithm to see how they relate to each other.

luv_clust <- hclust(dist(ggplot2::luv_colours[, 1:3]))
class(luv_clust)
## [1] "hclust"

With the tidygraph::as_tbl_graph() function we can transorm the dataset into classes “tbl_graph”, “igraph” to make it ready to use for making a visualization of the network data.

luv_graph <- as_tbl_graph(luv_clust)
luv_graph
## # A tbl_graph: 1313 nodes and 1312 edges
## #
## # A rooted tree
## #
## # Node Data: 1,313 × 4 (active)
##    height leaf  label members
##     <dbl> <lgl> <chr>   <int>
##  1     0  TRUE  "101"       1
##  2     0  TRUE  "427"       1
##  3   778. FALSE ""          2
##  4     0  TRUE  "571"       1
##  5     0  TRUE  "426"       1
##  6     0  TRUE  "424"       1
##  7     0  TRUE  "425"       1
##  8     0  FALSE ""          2
##  9   590. FALSE ""          3
## 10  1652. FALSE ""          4
## # ℹ 1,303 more rows
## #
## # Edge Data: 1,312 × 2
##    from    to
##   <int> <int>
## 1     3     1
## 2     3     2
## 3     8     6
## # ℹ 1,309 more rows
class(luv_graph)
## [1] "tbl_graph" "igraph"