获取neo4jd3.js的数据格式

时间:2019-01-05 07:16:53

标签: d3.js neo4j cypher

首先,我是NEO4J的新手。现在我想从NEO4J获得这样的数据格式,以便与neo4jd3.js一起使用

我的查询如下

MATCH graph = (n:Node)-[r:CITE]-(m:Node)
where n.cluster = "79835"
return  {   
    data: [{
        graph: 
        {
            nodes:collect({
                          id: n.id,
                          labels: ["Node"],
                          properties:
                            {
                                cluster: n.cluster
                            }
                         }),
            nodes:collect({
                         id: m.id,
                         labels: ["Node"],
                         properties:
                            {
                                cluster: m.cluster
                            }
                         }),
            relationships:collect({
                                 startNode: n.id,
                                 endNode: m.id,
                                 id: toString(id(r)),
                                 type: "CITE",
                                 properties:
                                    {
                                        useclass: r.usage_class,
                                        context: r.context,
                                        weight: r.weight
                                    }
                                })
            }
        }]
}

这段代码将给出这样的结果

[
  {
    "keys": [
  "{   \n\t\tdata: [{\n            graph: \n            {\n\t\t\t\tnodes:collect({\n                              id: n.id,\n                              labels: [\"Node\"],\n                              properties:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcluster: n.cluster\n\t\t\t\t\t\t\t\t}\n                             }),\n                nodes:collect({\n                             id: m.id,\n                             labels: [\"Node\"],\n                             properties:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcluster: m.cluster\n                                }\n                             }),\n                relationships:collect({\n                                     startNode: n.id,\n                                     endNode: m.id,\n                                     id: toString(id(r)),\n                                     type: \"CITE\",\n                                     properties:\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tuseclass: r.usage_class,\n                                            context: r.context,\n                                            weight: r.weight\n                                        }\n                                     })\n\t\t\t}\n\t\t}]\n}"
],
"length": 1,
"_fields": [
  {
    "data": [
      {
        "graph": {
          "nodes": [
            {
              "id": "1188",
              "labels": [
                "Node"
              ],
              "properties": {
                "cluster": "245591"
              }
            },
            {
              "id": "22356",
              "labels": [
                "Node"
              ],
              "properties": {
                "cluster": "24831"
              }
            },
            {
              "id": "9717",
              "labels": [
                "Node"
              ],
              "properties": {
                "cluster": "10774"
              }
            }
          ],
          "relationships": [
            {
              "endNode": "1188",
              "id": "11779",
              "startNode": "22350",
              "properties": {
                "useclass": "MENTION",
                "context": "- e biological research. Although it is possible to obtain biologically meaningful results with these algorithms, some of their characteristics often complicate their use for clustering expression data =-=[43]-=-. They require, for example, the predefinition of one or more user-defined parameters that are hard to estimate by a biologist (e.g., the predefinition of the number of clusters in -means and SOM\n",
                "weight": "1"
              },
              "type": "CITE"
            },
            {
              "endNode": "22356",
              "id": "11778",
              "startNode": "22350",
              "properties": {
                "useclass": "EXTEND",
                "context": "- periment. In a two-channel cDNA microarray experiment, for example, normalization adjusts for differences in labeling, detection efficiency, and in the quantity of initial RNA within the two channels =-=[23]-=-. Normalization is necessary before one can compare the results from different microarray experiments. Second, transformation of the data using a nonlinear function (often the logarithm is used, espec\n",
                "weight": "1"
              },
              "type": "CITE"
            }
          ]
        }
      }
    ]
  }
],
"_fieldLookup": {
  "{   \n\t\tdata: [{\n            graph: \n            {\n\t\t\t\tnodes:collect({\n                              id: n.id,\n                              labels: [\"Node\"],\n                              properties:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcluster: n.cluster\n\t\t\t\t\t\t\t\t}\n                             }),\n                nodes:collect({\n                             id: m.id,\n                             labels: [\"Node\"],\n                             properties:\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcluster: m.cluster\n                                }\n                             }),\n                relationships:collect({\n                                     startNode: n.id,\n                                     endNode: m.id,\n                                     id: toString(id(r)),\n                                     type: \"CITE\",\n                                     properties:\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tuseclass: r.usage_class,\n                                            context: r.context,\n                                            weight: r.weight\n                                        }\n                                     })\n\t\t\t}\n\t\t}]\n}": 0
}

} ]

我的问题是仅返回了m个节点。我希望此密码以这种格式返回结果。结果应同时包含n个节点和m个节点。

感谢您的帮助。

0 个答案:

没有答案