Exercise

Neighborhood link-based features

Sometimes, the feature values of neighboring nodes have an effect on behavior. In this exercise, you will look at the attribute value of neighboring nodes and compute their average. You will do this for degree, triangles, transitivity, and betweenness.

You need to:

  • Multiply the adjacency matrix with the network attribute you want to find the average of, to obtain the overall value in the neighborhood.
  • To get the average, divide by the node's degree, given by the vector degree which has been pre-loaded.
  • Finally, convert the result to a vector and assign to network as a node attribute.

Instructions 1/4

undefined XP
  • 1

    Compute the neighborhoods' average degree using the degree node attribute of network and name it averageDegree.

  • 2

    Use the triangles node attribute to compute averageTriangles, just as you computed averageDegree with degree.

  • 3

    Compute averageTransitivity using the node attribute transitivity.

  • 4

    Use the node attribute betweenness to compute averageBetweenness.