在Neo4j图中找到最小加权生成树

时间:2018-03-16 12:30:51

标签: neo4j graph-databases minimum-spanning-tree

我在neo4j中绘制了一个图表,其中包含以下节点:

  • 驱动程序
  • 学校
  • 学生

具有以下条件:

  • 驱动程序通过“连接”关系连接到所有学生,“距离”作为属性
  • 每个学生通过相同的“连接”关系以相同的“距离”属性相互连接
  • 每个学生也通过相同的“连接”关系与一个学校相连,并具有相同的“距离”属性

现在我想获得驾驶员将覆盖的最小路径,以便与N个学生一起到达学校。为此,我使用neo4j预定义程序(算法):

MATCH (n:Driver{name:"Driver2"}),(s:student),(sc:school),(n)-[c:connects]->
(s),(s)-[d:connects]->(sc) CALL 
algo.spanningTree.minimum('students','connects','distance',ID(n)) YIELD 
loadMillis, computeMillis, writeMillis, effectiveNodeCount
RETURN loadMillis, computeMillis, writeMillis, effectiveNodeCount

给出如下结果:

[
{
"keys": [
  "loadMillis",
  "computeMillis",
  "writeMillis",
  "effectiveNodeCount"
],
"length": 4,
"_fields": [
  {
    "low": 5,
    "high": 0
  },
  {
    "low": 1,
    "high": 0
  },
  {
    "low": 0,
    "high": 0
  },
  {
    "low": 1,
    "high": 0
  }
],
"_fieldLookup": {
  "loadMillis": 0,
  "computeMillis": 1,
  "writeMillis": 2,
  "effectiveNodeCount": 3
}
},
{
"keys": [
  "loadMillis",
  "computeMillis",
  "writeMillis",
  "effectiveNodeCount"
 ],
"length": 4,
"_fields": [
  {
    "low": 5,
    "high": 0
  },
  {
    "low": 0,
    "high": 0
  },
  {
    "low": 0,
    "high": 0
  },
  {
    "low": 1,
    "high": 0
  }
],
"_fieldLookup": {
  "loadMillis": 0,
  "computeMillis": 1,
  "writeMillis": 2,
  "effectiveNodeCount": 3
 }
},
{
"keys": [
  "loadMillis",
  "computeMillis",
  "writeMillis",
  "effectiveNodeCount"
],
"length": 4,
"_fields": [
  {
    "low": 4,
    "high": 0
  },
  {
    "low": 0,
    "high": 0
  },
  {
    "low": 0,
    "high": 0
  },
  {
    "low": 1,
    "high": 0
  }
 ],
 "_fieldLookup": {
  "loadMillis": 0,
  "computeMillis": 1,
  "writeMillis": 2,
  "effectiveNodeCount": 3
 }
},
{
"keys": [
  "loadMillis",
  "computeMillis",
  "writeMillis",
  "effectiveNodeCount"
],
"length": 4,
"_fields": [
  {
    "low": 4,
    "high": 0
  },
  {
    "low": 0,
    "high": 0
  },
  {
    "low": 0,
    "high": 0
  },
  {
    "low": 1,
    "high": 0
  }
],
"_fieldLookup": {
  "loadMillis": 0,
  "computeMillis": 1,
  "writeMillis": 2,
  "effectiveNodeCount": 3
}
}
]

我的问题是:如何解释这些数据?如果不是正确的方式那么我应该使用哪个Neo4j程序(算法)?

0 个答案:

没有答案