How do I turn this formula of the average degree of a graph into Python code?
Each node is a position in the arrays


values = value of the node
conn = indexes of connected nodes


If its an undirected graph, each node must have all the nodes to which they are attached.
Instead, in directed graphs, only the start node has the index.
For your image:

values = ['A','B','C','D','E']
conn = [[1,2,3],[0,4],[0,3,4],[0,2,3],[1,3]]


Example = 'A' -> 1 ('B') ,2 ('C') ,3 ('D')

def averageGraph(conn):
    if conn.all() != None:
        average = 0
        for node in conn:
            average = average + len(node) #len(node) = nº nodes connected = degree
        return average / len(conn)
    else:
        return None