[graph-tool] Temporal community detection with DSBM
ulgenklc
bengieru at buffalo.edu
Fri Feb 26 20:00:19 CET 2021
This is more of like an implementation question.
I'm PhD student in math and I've been trying out different dynamic community
detection(DCD) algorithms to compare their performance. I was stuck on
graph-tool's implementation for a few months because the documentation for
the layered networks was really short and I noticed this mailing list just
now.
I have multiple questions: first, am I initiating the network correctly
below? My network is a list of weighted adjacency matrices corresponding to
each snapshots.
g = Graph()
e_weight = g.new_ep("double")
e_layer = g.new_ep("int")
g.add_edge_list(edge_list, hashed = True, eprops=[e_weight, e_layer]) ##
edge_list has (v1,v2,w,t) format
g.edge_properties["edge_weight"] = e_weight ## weights of the intralayer
edges
g.edge_properties["edge_layer"] = e_layer ## since this is a multilayer
network, each edge has to come with a layer information that it belongs to(a
layer is a snapshot of the temporal network and has nothing to do with
nested model which I will use the word 'level' for)
Then, when I run the optimizer with the below code, I feel like I'm doing
something wrong. I want to use 'independent layers' model since this is a
temporal network and edge weights within each layer are varying between
[0,1].
for deg_corr in [True, False]:
state = minimize_nested_blockmodel_dl(g, layers = True, deg_corr =
deg_corr,
state_args=dict(ec =
g.ep.edge_layer,
layers = True,
recs=[g.ep.edge_weight],
rec_types=["real-exponential"]))
S1 = state.entropy()
# we will pad the hierarchy with another four empty levels, to
# give it room to potentially increase
state = state.copy(bs=state.get_bs() + [np.zeros(1)] * 4, sampling =
True)
for i in range(100): # this should be sufficiently large
state.multiflip_mcmc_sweep(beta=np.inf, niter=10)
S2 = state.entropy()
print(S1,S2, S2-S1)
I have a serious problem with getting the node labels. The code below only
returns the node membership information for N nodes(size of the aggregated
network). But since this is an evolving network, nodes are expected to
change communities over time, so below code should return NxT(number of
nodes times number of layers) many community labels?
levels = state.get_levels()
for s in levels:
print(s)
This returns the network partition at different levels of the nested SBM but
only for N many nodes.
What am I missing?
--
Sent from: https://nabble.skewed.de/
More information about the graph-tool
mailing list