Hi there,
I'm looking for help. I'm trying to find degree of node against the root node.
// here n is a variable like 1,2,3,4 .... nth
match p=(n:Config)-[*..(n)]-(b) where n.id= "Conf001"
unwind nodes(p) as nodes unwind relationships(p) as re
with collect(DISTINCT{id: nodes.id, label: COALESCE(nodes.name, nodes.title), type:labels(nodes)[0]}) as nl,
collect(DISTINCT{id:ID(re),label: TYPE(re), source: properties(startNode(re)).id, target: properties(endNode(re)).id}) as rl
return {nl: nl, rl: rl}
this query return me all nodes and all relationships here is the output
{
"nl": [
{
"id": "Conf001",
"label": "node 1",
"type": "Config"
},
{
"id": "M00006",
"label": "node 2",
"type": "Model"
},
{
"id": "M00004",
"label": "node 3",
"type": "Model"
}
],
"rl": [
{
"id": 40,
"label": "MARKETED_UNDER",
"source": "Conf001",
"target": "M00006"
},
{
"id": 38,
"label": "MARKETED_UNDER",
"source": "Conf001",
"target": "M00004"
}
]
}
What I also want to get degree of the node like this
"nl": [
{
"id": "Conf001",
"label": "node 1",
"type": "Config",
"degree": 0
},
{
"id": "M00006",
"label": "node 2",
"type": "Model",
"degree": 1
},
{
"id": "M00004",
"label": "node 3",
"type": "Model",
"degree": 1
}
]
Can somebody guide me
Thank you so much