Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Fraud Detection in R

Cursus bekijken

Oefeninstructies

  • Create an object vertex_colors that contains the colors "grey", "lightblue" and "darkorange" (in this order).
  • Add an attribute color to V(net) which holds the color of each node depending on account_type.
  • Plot the network net with its new node attributes.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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
___
Code bewerken en uitvoeren