I've been trying to loop through each of the nodes in my network chart to calculate the degree centrality of the nodes. Have been able to do so for other normalized centrality measures, but did not get any success with the unnormalized ones. Below are my code:
This works:
let dcn = cy.elements().degreeCentralityNormalized();
cy.nodes().forEach(n => {
n.data({
dcn: dcn.degree(n)
});
});
However, this doesn't work:
let dc = cy.elements().degreeCentrality();
cy.nodes().forEach(n => {
n.data({
dc: dc.degree(n)
});
});
Have been getting the following error message:
Uncaught TypeError: Cannot read property 'connectedEdges' of undefined at ca.degreeCentrality
Not sure why this is the case. Appreciate any help here!