Hi,
I have been trying to calculate both the global and local clustering coefficients for a weighted network. Based on the documentation and a few previous discussions in the forum, it appears that the weighted clustering coefficient should be in the range of [0,1], right? However, what I get is always > 1. Could anyone help clarify?
A sample network is attached (it is already a simple undirected network):
sample.csv (33.7 KB)
And here is the code I used:
df_edgelist = pd.read_csv('sample.csv')
# normalize edge weight (which is the S000 column) according to the documentation
df_min_max_scaled = df_edgelist.copy()
column = 'S000'
df_min_max_scaled[column] = (df_min_max_scaled[column] - df_min_max_scaled[column].min()) / (df_min_max_scaled[column].max() - df_min_max_scaled[column].min())
# create a graph and calculate clustering coefficient
g = Graph(directed=False)
ep_flow = g.new_ep("float") # define a new edge property map representing normalized edge weight
ep_dist = g.new_ep("float")
vp_name = g.new_vp("int")
vp_name = g.add_edge_list(df_min_max_scaled.to_numpy(), hashed=True, eprops=[ep_flow, ep_dist])
c_w, num_tria_w, num_triples_w = global_clustering(g, weight = ep_flow, ret_counts=True)
gcc_w = c_w[0]
The code for calculating local clustering coefficient is very similar.
Another question is that how is local clustering coefficient calculated for weighted networks? It is not clearly defined in the documentation. However, it was clearly documented for the global clustering coefficient.
Thank you!