Neo4j最短路径/最小节点

时间:2017-07-21 01:12:35

标签: neo4j cypher

我有以下neo4j数据库设计:

  • 节点:
    • 课程
    • 技能
    • 工作
  • 关系:
    • 课程有技巧
    • 乔布斯有技能

** 课程和技能都没有线性/依赖性。例如。没有必要修课程A才能修课程。

我想解决的问题:

鉴于工作节点#3(具有技能#1,#2和#3),可以采取哪些课程来获得这些技能(按最少课程数排序)?即如果您想在Job X工作,您可以采取哪些课程选项/路径来获得所需的技能?

示例数据:

CREATE (PythonProgramming:Course { name: 'python_programming'})
CREATE (DataScience:Course { name: 'introduction_to_data_science'})
CREATE (MachineLearning:Course { name: 'machine_learning'})
CREATE (Statistics:Course { name: 'statistics'})
CREATE (Regression:Course { name: 'regression'})

CREATE (Python:Skill {name: "python"})
CREATE (Probability:Skill {name: "probability"})
CREATE (LogisticRegression:Skill {name: "logistic_regression"})

CREATE (Google:Job {name: "google"})

CREATE
  (DataScience)-[:HAS_SKILL]->(Python),
  (DataScience)-[:HAS_SKILL]->(LogisticRegression),
  (DataScience)-[:HAS_SKILL]->(Probability),
  (MachineLearning)-[:HAS_SKILL]->(LogisticRegression),
  (MachineLearning)-[:HAS_SKILL]->(Probability),
  (Statistics)-[:HAS_SKILL]->(Probability),
  (PythonProgramming)-[:HAS_SKILL]->(Python),
  (Regression)-[:HAS_SKILL]->(LogisticRegression),

  (Google)-[:REQUIRES_SKILL]->(Python),
  (Google)-[:REQUIRES_SKILL]->(LogisticRegression),
  (Google)-[:REQUIRES_SKILL]->(Probability)

根据这些数据,Google上Job的最短路径应该是:

  1. 数据科学(拥有所有3项技能)
  2. Python Programming + MachineLearning
  3. Python编程+统计+回归

0 个答案:

没有答案