Graph/centrality- Is there a way to avoid "Expected Cost to be positive" error?

2 Ansichten (letzte 30 Tage)
Hi! I'm conducting centrality analysis on a set of nodes (XYZ) and edges. My edge cost is euclidean distance. However, I currently get an error each time I calculated weighted closeness or weighted betweeness saying that "expected cost to be positive." Why am I getting this error?
Here is my code:
figure('Name','Closeness-weighted')
wcc = centrality(G,'closeness','Cost',G.Edges.Weight);
p.NodeCData = wcc;
title('Closeness Centrality Scores - Weighted')
It is a large node dataset, and I think some of the edges start and end at the same node. Is this the problem? Can i remove these easily?
Sorry! I'm a beginner. Any help or resources would be greatly appreciated.

Akzeptierte Antwort

William Wadsworth
William Wadsworth am 24 Okt. 2020
After contacting technical support, there is currently a bug in the centrality functions with large datasets (>100 nodes). They are currently looking into it. :)

Weitere Antworten (1)

Steven Lord
Steven Lord am 15 Okt. 2020
Are any of your weights non-positive? Specifically check if any are equal to 0.
  4 Kommentare
Steven Lord
Steven Lord am 18 Okt. 2020
If the edges start and end at the same location, are they self loops or are they connecting two nodes that happen to be at the same place? If the former consider specifying 'omitselfloops' when you construct the graph to eliminate those self loops.
William Wadsworth
William Wadsworth am 18 Okt. 2020
Hi Steven! Thanks for this, I added omitselfloops which definitely cleaned up the data a lot. I'm still getting the the positivity error though, perhaps it is the second option... or ( I've added a picture so you can see what's going on) some points are not connected to the main network as shown... perhaps this is where the problem lies? Any ideas? :)
Thanks again!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by