Visualize filtered graph using nxviz
Here, you'll visualize the filtered graph using a circos plot. The circos plot is a natural choice for this visualization, as you can use node grouping and coloring to visualize the partitions, while the circular layout preserves the aesthetics of the visualization.
Deze oefening maakt deel uit van de cursus
Intermediate Network Analysis in Python
Oefeninstructies
- Compute degree centrality scores of each node using the bipartite module degree centralities, but based on the degree centrality in the original graph.
- Use the
nx.bipartite.degree_centrality()function for this, with the argumentsGandnodes=forum_nodes.
- Use the
- Create a new
circosplot with nodes colored and grouped (parametersnode_color_byandgroup_by) by their partition label ('bipartite'), and ordered (parametersort_by) by their degree centrality ('dc') and display it.- To ensure that the nodes are visible when displayed, we have included the argument
node_enc_kwargs={'radius': 10}.
- To ensure that the nodes are visible when displayed, we have included the argument
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Import necessary modules
from nxviz import circos
import networkx as nx
import matplotlib.pyplot as plt
# Compute degree centrality scores of each node
dcs = ____(____, nodes=____)
for n, d in G_sub.nodes(data=True):
G_sub.nodes[n]['dc'] = dcs[n]
# Create the circos plot: c
c = _____(___, _____, _____, _____, node_enc_kwargs={'radius': 5})
# Display the plot
plt.show()