liveBook · Manning

Degree-weighted path count

As explained in Knowledge Graphs and LLMs in Action

A degree-weighted path count is a path-based graph metric that weights paths according to the degrees of the entities they traverse.

Degree-weighted path count (DWPC) measures how prevalent a specified metapath is between source and target nodes while reducing the influence of highly connected intermediate nodes. Unlike path count (PC), which assigns every path a value of 1, DWPC weights each path inversely according to node degrees. section 4.3 section 10.2.2

A typical DWPC workflow is:

  • Choose a metapath, such as Compound–binds–Gene–associates–Disease, which specifies node and relationship types rather than one concrete path. section 4.3 section 10.2.2
  • Match the concrete path instances between the selected source and target nodes and count them as PC. section 4.3
  • Collect the degrees along each path, apply inverse degree damping, and sum the resulting path contributions. section 4.3 section 10.2.2
  • Order candidate relationships by DWPC, then inspect the underlying paths to support interpretation and validation. section 4.3.1 section 4.3.1

Metformin and type 2 diabetes

For the CbGaD metapath, a Neo4j query computes PC and DWPC using degree terms raised to −0.4. Running it for metformin and type 2 diabetes mellitus produces a DWPC value of 0.0007. A path through a gene with degree 10 contributes more than one through a gene with degree 100, reducing hub-driven noise. section 10.2.2 section 10.2.2

Listing 10.15 DWPC between metformin and type 2 diabetes for CbGaD
MATCH path = (c:Compound)-[:BINDS_CbG]-(g)-[:ASSOCIATES_DaG]-(d:Disease) 
WHERE c.name = 'Metformin' AND d.name = 'type 2 diabetes mellitus'
WITH
[
  count{(v)-[:BINDS_CbG]-()},
  count{()-[:BINDS_CbG]-(g)},
  count{(g)-[:ASSOCIATES_DaG]-()},
  count{()-[:ASSOCIATES_DaG]-(d)}
] 
AS degrees, path, d 
WITH
  d.identifier AS disease_id,
  d.name AS disease_name,
  count(path) AS PC, 
  sum(reduce(pdp = 1.0, d in degrees| pdp * d ^ -0.4)) AS DWPC
RETURN
  disease_id, disease_name, PC, DWPC

Inspect the complete Cypher query for calculating PC and DWPC on the metformin–type 2 diabetes CbGaD metapath. section 10.2.2

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains metapaths, path counts, degree damping, Cypher computation, ranking, and path inspection without deriving the metric mathematically.
Examples
Uses Hetionet disease-process enrichment, celiac disease interactomics, and metformin–type 2 diabetes metapath features.
What it assumes
Assumes knowledge-graph nodes, relationships, and Cypher queries while defining metapaths and path counts through concrete examples.
What you can do after
Apply it via Neo4j to compute, rank, and inspect degree-adjusted relationships across biomedical metapaths.
How it connects
Connects metapaths, path count, knowledge graphs, graph feature engineering, drug repurposing, and Neo4j.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.