In this [1] code snippet when the line "if h.shape[edges * 1] == 1:" encounters a singleton the assignment stats = {v: 0 for v in vertices} overwrites the "stats" dictionary. In my tests, when using a graph with 5000 edges and the last edge checked had a centrality equal to 0, as it was a singleton, I obtained a dictionary with only one edge and centrality value.
To fix this, just use the same update method used in else, so that it is equal to [2]. This way I obtained a complete dictionary, with all the edges of the hypergraph and their centralities.
[1] - buggy code
stats = dict()
for h in comps:
if edges:
vertices = h.edges
else:
vertices = h.nodes
if h.shape[edges * 1] == 1:
stats = {v: 0 for v in vertices}
else:
g = h.get_linegraph(s=s, edges=edges)
stats.update({k: v for k, v in func(g, **kwargs).items()})
if f:
return {f: stats[f]}
return stats
[2] - corrected code:
stats = dict()
for h in comps:
if edges:
vertices = h.edges
else:
vertices = h.nodes
if h.shape[edges * 1] == 1:
stats.update({v: 0 for v in vertices})
else:
g = h.get_linegraph(s=s, edges=edges)
stats.update({k: v for k, v in func(g, **kwargs).items()})
return stats
Sorry for my bad english.
In this [1] code snippet when the line "if h.shape[edges * 1] == 1:" encounters a singleton the assignment stats = {v: 0 for v in vertices} overwrites the "stats" dictionary. In my tests, when using a graph with 5000 edges and the last edge checked had a centrality equal to 0, as it was a singleton, I obtained a dictionary with only one edge and centrality value.
To fix this, just use the same update method used in else, so that it is equal to [2]. This way I obtained a complete dictionary, with all the edges of the hypergraph and their centralities.
[1] - buggy code
[2] - corrected code:
ty for the library.