Closeness Centrality Returns 0

Hi I have a heterogeneous graph and I am trying to compute the closeness centrality on a subset:

A - (SENDS_TO) - B

Imagine this is part of a larger graph, e.g.,

A - (SENDS_TO) - B - (LIKES) - C - (FRIENDS) - D - (BUYS_FROM) - A

I am currently using the tg_closeness_cent_approx algo as

tg_closeness_cent_approx (
v_type = [“A”, “B”],
e_type = “SENDS_TO”,
re_type = “SENDS_TO”
max_size = 5000
)

There are ~2k A nodes and 172k B nodes. Each A is connected to a B.

However my results are all score=0.

Would anyone have an idea why?

Please try this one gsql-graph-algorithms/tg_closeness_cent.gsql at master · tigergraph/gsql-graph-algorithms · GitHub

2 Likes

Thanks I will try.

However this one seems to work well for my purposes (and is more readable):

https://github.com/tigergraph/ecosys/blob/master/GSQL/graph_algorithms/algorithms/examples/closeness_cent.gsql

This is an old version, the new one has better performance on large graph.

2 Likes

While we would have to study your situation a little more to see why you are getting 0, I do think that you subgraph is probably not a good candidate for closeness centrality.

Closeness centrality only makes sense when every vertex CAN REACH every other vertex. The centrality measure is calculating how many steps it takes on average to get to those other vertices.

If I understand your schema correctly, by including only A and B and only one edge type, it probably is not true that every vertex can reach every other vertex. If you can say instead “well, it’s not one connected graph, but it’s a reasonable number of connected subgraphs”, then we can treat each group separately and average their results. That is what the wf (Wasserman-Faust) parameter is for.

2 Likes

Thanks @Victor_Lee I will look into the wf parameter

1 Like