Loads the graph, which is stored as the variable G
(the |>
sends the output to the next line)
Selects the nodes “spreadsheet” to edit. To activate the edges, run activate(edges)
Calculates the eigenvector centrality and saves it as a new column in the nodes spreadsheet. Note that we keep using |>
until we get to ggraph()
Tells R we want to take the network and make a plot from it. This is where we set the layout
Remember to add edges first.
The first argument is the “aesthetic mapping” - this maps aspects of the plot to variables in your data. In this case, we change the width of the edges based on the variable “weight”, which must be in our edges “spreadsheet”
We can also change the look of the plot universally. These options go outside of aes()
This code does similar operations to the nodes. It changes the size based on the centrality (which we calculated and defined in line 3) and changes the color of all nodes to gold