In-degree counts the incoming relationships connected to a node in a directed network. Comparing in-degree with out-degree separates received connections from outgoing connections. section 5.1.1 section 5.6
In Neo4j, count incoming relationships with a relationship pattern such as (u)<-[:FOLLOWS]-(). APOC statistics can then summarize the resulting values with minimum, maximum, mean, and percentiles. section 5.1.1
Listing 5.2 Evaluating the node out-degree distribution with the apoc.agg.statistics function
MATCH (u:User)
WITH u, count{ (u)<-[:FOLLOWS]-() } AS inDegree
RETURN apoc.agg.statistics(inDegree)
Use the Cypher listing to calculate each user's in-degree and summarize the distribution with apoc.agg.statistics. section 5.1.1
For a projected in-memory graph, GDS degree centrality calculates out-degree by default; set orientation:'REVERSE' to return in-degree. Stats mode summarizes the distribution without storing results. section 6.2.1
Listing 6.6 Returns the top five users with the highest in-degree
CALL gds.degree.stats('amplify', {orientation:'REVERSE'})
YIELD centralityDistribution
Use the GDS listing to request the highest in-degree values by reversing the algorithm's default relationship orientation. section 6.2.1
Followers and retweet amplification
In the followers network, the highest in-degree users include elonmusk with 540 incoming links, AndrewYNg with 301, and NASA with 267. In the inferred retweet amplification network, the highest in-degree score is Paula_Piccard at 117. section 5.1.1 section 6.2.1
In-degree also identifies a node's position in directed graphlets: counting incoming connections counts graphlets where the node occupies the incoming position. An exercise stores these values as inDegree properties. section 8.1.1
