I would like to plot the k-cores of a graph in a nice visualization which can illustrate the different k-core values (for instance, https://www.researchgate.net/figure/Illustration-of-the-k-core-decomposition-Here-k-max-3_fig1_326621799). A sample of dataset is the following:
Node Target Label
A F 1
A B 1
A N 1
B A 0
B F 0
C F 1
A V 1
D S 0
D E 0
F A 1
F B 1
F G 1
G E 0
E W 0
To identify the nodes with at least degree k I am using the following piece of code:
G = nx.from_pandas_edgelist(df, 'Node', 'Target')
kcore=nx.k_core(G)
plt.subplot(121)
plt.title('Full')
nx.draw(G,with_labels=True)
plt.subplot(122)
plt.title('Main')
nx.draw(kcore,with_labels=True)
plt.show()
I'm trying to figure it out, for example using a loop across k values or assigning different colors depending on the value of k...
Any help or tips would be welcome.
