0Pricing
Neo4j Graph Database Fundamentals · 课时

相似度与链接预测算法

探索节点相似度和链接预测算法,发现图中隐藏的结构以及可能形成的未来连接。

相似度与链接预测算法 是 CoddyKit 上的免费 Neo4j Graph Database Fundamentals 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Neo4j Graph Database Fundamentals 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Neo4j Graph Database Fundamentals 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

Beyond Paths and Centrality

You have seen pathfinding, centrality, and community detection. Another family answers: how alike are two nodes and which connections are likely to form next?

What Is Node Similarity

Similarity algorithms score how comparable two nodes are based on the neighbors or items they share.

Two users who bought many of the same products are similar.

Jaccard Similarity

The Jaccard coefficient divides the size of the shared neighbor set by the size of the combined set. It ranges from 0 to 1.

// Jaccard = |A intersect B| / |A union B|
// 3 shared neighbors, 7 total distinct -> 0.43

Running Node Similarity in GDS

The Graph Data Science library provides a node similarity procedure that compares nodes by shared relationships.

CALL gds.nodeSimilarity.stream('myGraph')
YIELD node1, node2, similarity
RETURN gds.util.asNode(node1).name AS a,
       gds.util.asNode(node2).name AS b,
       similarity
ORDER BY similarity DESC;

Cosine and Overlap Similarity

Other measures include cosine similarity (for weighted vectors) and overlap similarity. Choose based on whether weights matter.

What Is Link Prediction

Link prediction estimates how likely two currently unconnected nodes are to connect in the future, based on graph structure.

It powers friend suggestions and product recommendations.

Common Neighbors

The simplest predictor: the more common neighbors two nodes share, the more likely they connect. Many social suggestions use this idea.

MATCH (a:Person {name: 'Alice'})-[:FRIEND]->(common)<-[:FRIEND]-(b:Person)
WHERE NOT (a)-[:FRIEND]->(b) AND a <> b
RETURN b.name, count(common) AS sharedFriends
ORDER BY sharedFriends DESC;

Adamic-Adar

Adamic-Adar refines common neighbors by giving less weight to highly-connected shared neighbors, since a hub connection is less informative.

RETURN gds.alpha.linkprediction.adamicAdar(node1, node2) AS score;

Preferential Attachment

Preferential attachment assumes nodes with many connections are more likely to gain more. It multiplies the degrees of the two nodes.

RETURN gds.alpha.linkprediction.preferentialAttachment(node1, node2) AS score;

Choosing the Right Measure

No single measure is best. Test several against known outcomes and pick the one that predicts your real links most accurately.

Putting It to Use

Similarity and link prediction feed recommendation systems, deduplication, and network growth analysis. They turn structure into actionable suggestions.

Quick Check

Test your understanding of these algorithms.

Recap

You explored similarity and link prediction:

  • Jaccard, cosine, and overlap measure node similarity
  • Link prediction estimates future connections
  • Common neighbors, Adamic-Adar, and preferential attachment are key predictors
  • Test measures against real outcomes

常见问题解答

「相似度与链接预测算法」课时是免费的吗?

是的 — 「相似度与链接预测算法」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Neo4j Graph Database Fundamentals 课程的其余内容,请升级到 CoddyKit PRO。 Neo4j Graph Database Fundamentals 课程共包含 4 节课。

「相似度与链接预测算法」这节课中我会学到什么?

探索节点相似度和链接预测算法,发现图中隐藏的结构以及可能形成的未来连接。 你通过在浏览器中直接运行的动手代码来练习 Neo4j Graph Database Fundamentals,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Neo4j Graph Database Fundamentals 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Neo4j Graph Database Fundamentals 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「相似度与链接预测算法」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Neo4j Graph Database Fundamentals 课中编写并运行代码吗?

能。每节 Neo4j Graph Database Fundamentals 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 寻路算法(BFS、DFS)
  2. 中心性算法(PageRank)
  3. 社区检测算法
  4. 相似度与链接预测算法
← 返回 Neo4j Graph Database Fundamentals