from torch_geometric.utils import degree from collections import Counter def plot_degree(data): # Get list of degrees for each node degrees = degree(data.edge_index[0]).numpy() # Count the number of nodes for each degree numbers = Counter(degrees) # Bar plot fig, ax = plt.subplots(figsize=(18, 6)) ax.set_xlabel('Node degree') ax.set_ylabel('Number of nodes') plt.bar(numbers.keys(), numbers.values(), color='#0A047A') # Plot node degrees from the original graph plot_degree(data) # Plot node degrees from the last subgraph plot_degree(subdata)