BaşlayınÜcretsiz Başlayın

Number of edges over time

You're now going to get some practice plotting other evolving graph statistics. We'll start with a simpler exercise to kick things off. First off, plot the number of edges over time.

To do this, you'll create a list of the number of edges per month. The index of this list will correspond to the months elapsed since the first month.

Bu egzersiz

Intermediate Network Analysis in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Import matplotlib.pyplot as plt.
  • Create a list of the number of edges per month called edge_sizes. Use a list comprehension to do this, where you iterate over Gs using an iterator variable called g, and your output expression is len(g.edges()).
  • Plot edge sizes over time.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import matplotlib
____

fig = plt.figure()

# Create a list of the number of edges per month
edge_sizes = [____]

# Plot edge sizes over time
plt.plot(____)
plt.xlabel('Time elapsed from first month (in months).') 
plt.ylabel('Number of edges')                           
plt.show() 
Kodu Düzenle ve Çalıştır