def avg_num_followers(graph):
    """Average number of followers in graph."""
    num_nodes = 0
    num_followers = 0
    for node in graph.nodes(data=True):
        if 'followers_total' in node[1]:
            num_followers += node[1]['followers_total']
            num_nodes += 1

    if num_nodes == 0:
        return 0
    else:
        return num_followers / num_nodes