def getNodesValence(graphs):
    """
    Outputs a 2-dimensions array containing, for each graph, a list of
    the numbers of nodes having the valence (ie, number of branches)
    corresponding to the index in the list.
    For example, if there are 3 nodes with valence equal to 5 in the graph of
    the i-th graph, then the output at coordinates (i,5) will be 3.
    For K3, the output is [0,0,3] because all 3 nodes have valence 2.
    Note that it applies to a set of graphs and therefore outputs a set of
    valence vectors.
    """
    nodesValence = []
    for graph in graphs:
        val = [0]*(len(graph)+1) # Could be reduced to occupy less memory
        for node in graph:
            val[ len(node) ] += 1
        nodesValence.append(val)
    return nodesValence