Plot degree centrality pada proyeksi
Di sini, Anda akan membandingkan sebaran degree centrality untuk masing-masing graf berikut: graf asli G, proyeksi graf orang peopleG, dan proyeksi graf klub clubsG. Ini akan menegaskan perbedaan perhitungan skor degree centrality antara metrik degree centrality versi bipartit dan unipartit. Daftar node people dan clubs telah dimuat untuk Anda.
Ingat dari video bahwa fungsi bipartit memerlukan sebuah kontainer berisi node sebagai argumen, tetapi tetap akan mengembalikan seluruh skor degree centrality. Ingat juga bahwa skor degree centrality disimpan sebagai dictionary (memetakan node ke skor).
Latihan ini merupakan bagian dari kursus
Analisis Jaringan Menengah di Python
Instruksi latihan
- Plot sebaran degree centrality dari graf asli
G, menggunakan fungsi degree_centrality dari modul bipartit:nx.bipartite.degree_centrality(). Fungsi ini menerima dua argumen: grafG, dan salah satu daftar node (peopleatauclubs). - Plot sebaran degree centrality dari graf
peopleG, menggunakan fungsidegree_centralitybiasa/non-bipartit dari NetworkX:nx.degree_centrality(). - Plot sebaran degree centrality dari graf
clubsG, menggunakan fungsidegree_centralitybiasa/non-bipartit dari NetworkX:nx.degree_centrality().
Latihan interaktif langsung praktik
Cobalah latihan ini dengan melengkapi kode contoh ini.
import matplotlib.pyplot as plt
# Plot the degree centrality distribution of both node partitions from the original graph
plt.figure()
original_dc = ____
# Remember that you can directly plot dictionary values.
plt.hist(____, alpha=0.5)
plt.yscale('log')
plt.title('Bipartite degree centrality')
plt.show()
# Plot the degree centrality distribution of the peopleG graph
plt.figure()
people_dc = ____
plt.hist(____)
plt.yscale('log')
plt.title('Degree centrality of people partition')
plt.show()
# Plot the degree centrality distribution of the clubsG graph
plt.figure()
clubs_dc = ____
plt.hist(____)
plt.yscale('log')
plt.title('Degree centrality of clubs partition')
plt.show()