#NEWLINE# def degree_assortativity_coefficient( G , x = 'out' , y = 'in' , weight = None , nodes = None ) : #NEWLINE# #INDENT# 'Compute degree assortativity of graph.\n\n    Assortativity measures the similarity of connections\n    in the graph with respect to the node degree.\n\n    Parameters\n    ----------\n    G : NetworkX graph\n\n    x: string (\'in\',\'out\')\n       The degree type for source node (directed graphs only).\n    \n    y: string (\'in\',\'out\')\n       The degree type for target node (directed graphs only).\n\n    weight: string or None, optional (default=None)\n       The edge attribute that holds the numerical value used \n       as a weight.  If None, then each edge has weight 1.\n       The degree is the sum of the edge weights adjacent to the node.\n\n    nodes: list or iterable (optional)\n        Compute degree assortativity only for nodes in container. \n        The default is all nodes.\n\n    Returns\n    -------\n    r : float\n       Assortativity of graph by degree.\n    \n    Examples\n    --------\n    >>> G=nx.path_graph(4)\n    >>> r=nx.degree_assortativity_coefficient(G)\n    >>> print("%3.1f"%r)\n    -0.5\n\n    See Also\n    --------\n    attribute_assortativity_coefficient\n    numeric_assortativity_coefficient\n    neighbor_connectivity\n    degree_mixing_dict\n    degree_mixing_matrix\n\n    Notes\n    -----\n    This computes Eq. (21) in Ref. [1]_ , where e is the joint\n    probability distribution (mixing matrix) of the degrees.  If G is\n    directed than the matrix e is the joint probability of the \n    user-specified degree type for the source and target.\n\n    References\n    ----------\n    .. [1] M. E. J. Newman, Mixing patterns in networks,\n       Physical Review E, 67 026126, 2003\n    .. [2] Foster, J.G., Foster, D.V., Grassberger, P. & Paczuski, M. \n       Edge direction and the structure of networks, PNAS 107, 10815-20 (2010).\n    ' #NEWLINE# M = degree_mixing_matrix ( G , x = x , y = y , nodes = nodes , weight = x ) #NEWLINE# return numeric_ac ( M )