Visualizing node attributes
The structure of a network typically depends on the attributes of the nodes embedded in it. Being able to visualize these attributes in a graph can help us see patterns, and to understand better the relationships in the data. Using different colors and shapes for the nodes are useful tools to show this information in a graph. The node attribute account type
can take 3 different values and we define three different colors that depend on this attribute.
The network net
is added to your workspace. The updated V(net)$account_type
object from the previous exercise is already available in your workspace: each node is an account of type 1, 2 or 3.
This exercise is part of the course
Fraud Detection in R
Exercise instructions
- Create an object
vertex_colors
that contains the colors"grey"
,"lightblue"
and"darkorange"
(in this order). - Add an attribute
color
toV(net)
which holds the color of each node depending onaccount_type
. - Plot the network
net
with its new node attributes.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Each account type is assigned a color
___ <- c(___, ___, ___)
# Add attribute color to V(net) which holds the color of each node depending on its account_type
___ <- ___[___(___)$___]
# Plot the network
___