liveBook · Manning

In-degree

As explained in Graph Algorithms for Data Science

In-degree is the number of incoming relationships connected to a node in a directed network.

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

How Graph Algorithms for Data Science covers it

How deep it goes
Defines incoming degree and demonstrates Cypher and GDS calculations, distributions, rankings, and graphlet positions; it defers formal proofs.
Examples
Uses followers, retweet amplification, top-user tables, Cypher listings, distribution statistics, and two-node directed graphlets.
What it assumes
Assumes directed nodes and relationships plus basic Cypher; introduces in-degree, out-degree, graphlets, and GDS orientation.
What you can do after
Evaluate in-degree distributions, rank nodes, query incoming relationships, and store degree values for graphlet analysis.
How it connects
Connects in-degree with out-degree, degree distribution, degree centrality, graphlets, motifs, Cypher, and GDS.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.