def dict2matrix(wDict,std=0,diag=0):
    """Transform the contiguity dictionary to a matrix

    :param wDict: Contiguity dictionary 
    :type wDict: dictionary
    :param std: 1 to get the standarized matrix 
    :type std: dictionary
    
    **Example 1** ::
    
    >>> import clusterpy
    >>> lay = clusterpy.importArcData("clusterpy/data_examples/china")
    >>> wmatrix = clusterpy.contiguity.dict2matrix(lay.Wrook)

    :rtype: list, List of lists representing the contiguity matrix
    """
    data = []
    nAreas = len(list(wDict.keys()))
    for i in wDict:
        data.append([0]*nAreas)
        data[i][i] = diag
        ne = len(wDict[i])+ diag
        for j in wDict[i]:
            if std:
                data[i][j] = 1 / float(ne)
            else:
                data[i][j] = 1
    return data