GraphAssortativity
✖
GraphAssortativity
gives the assortativity coefficient of the graph g using vertex property "prop".
gives the assortativity coefficient of the graph g with respect to the vertex partition {{vi 1,vi 2,…},…}.
gives the assortativity coefficient of the graph g using data {x1,x2,…} for vertices {v1,v2,…}.
Details and Options

- For a graph with
edges and adjacency matrix entries
, the assortativity coefficient is given by
, where
is the out-degree for the vertex vi and
is 1 if there is an edge from vi to vj and 0 otherwise.
- For quantitative data where x1,x2,… are used,
is taken to be xixj.
- For categorical data where x1,x2,… are used,
is taken to be 1 if xi and xj are equal and 0 otherwise.
- In GraphAssortativity[g], xi is taken to be the vertex out-degree for the vertex vi.
- In GraphAssortativity[g,"prop"], xi is taken to be AnnotationValue[{g,vi},"prop"] for the vertex vi.
- In GraphAssortativity[g,{{vi 1,vi 2,…},…}], vertices in a subset {vi 1,vi 2,…} have the same categorical data xi 1=xi 2=….
- GraphAssortativity[g,Automatic->{x1,x2,…}] takes the vertex list to be VertexList[g].
- The option "DataType"->type can be used to specify the type for the data x1,x2,…. Possible settings are "Quantitative" and "Categorical".
- The option "Normalized"->False can be used to compute the assortativity modularity.
- For a graph with
edges and adjacency matrix entries
, the assortativity modularity is given by
, where
is the out-degree for the vertex vi.
- GraphAssortativity works with undirected graphs, directed graphs, weighted graphs, multigraphs, and mixed graphs.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (12)Survey of the scope of standard use cases
GraphAssortativity works with undirected graphs:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-tzs5an


https://wolfram.com/xid/0bzranqs7bdmc3ysq-d7rrmc


https://wolfram.com/xid/0bzranqs7bdmc3ysq-gcbs2g


https://wolfram.com/xid/0bzranqs7bdmc3ysq-ffb0ew


https://wolfram.com/xid/0bzranqs7bdmc3ysq-ffsn8

Use rules to specify the graph:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-bndh30

Compute the assortativity coefficient using vertex property data:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-msp35


https://wolfram.com/xid/0bzranqs7bdmc3ysq-gfd9b1


https://wolfram.com/xid/0bzranqs7bdmc3ysq-dn3zoj

A partition or assignment of a subset of VertexList:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-8bjvs

GraphAssortativity works with symbolic expressions:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-nwyp8y

GraphAssortativity works with large graphs:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-gw1usj

https://wolfram.com/xid/0bzranqs7bdmc3ysq-cuju06


https://wolfram.com/xid/0bzranqs7bdmc3ysq-gfsfsb

Applications (3)Sample problems that can be solved with this function
Compare the assortativity coefficient of vertex partitions by vertex color:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-lt2pno

https://wolfram.com/xid/0bzranqs7bdmc3ysq-j9ko80

Disassortativity by number of friends in a friendship network:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-ntpxnb

https://wolfram.com/xid/0bzranqs7bdmc3ysq-echrlr

A partition of the network shows assortative mixing:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-lvmgei

https://wolfram.com/xid/0bzranqs7bdmc3ysq-i1l4m5


https://wolfram.com/xid/0bzranqs7bdmc3ysq-dwtlyz

A friendship network at a high school, with vertices color coded by race. Analyze the preference for students to associate with others who are similar:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-5fvaf
Highly social students are friends with other highly social students:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-gr6fi5

Positive tendency for students to associate with others of the same race:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-f13ors

Properties & Relations (2)Properties of the function, and connections to other functions
The assortativity coefficient is between -1 and 1:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-gx8bnc


https://wolfram.com/xid/0bzranqs7bdmc3ysq-d25t36

Completely disassortative graph:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-gvlkw

GraphAssortativity is Pearson correlation coefficient of degree between connected vertices:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-p69xs

https://wolfram.com/xid/0bzranqs7bdmc3ysq-vyb15

Correlation gives the Pearson correlation coefficient:

https://wolfram.com/xid/0bzranqs7bdmc3ysq-d9l23

https://wolfram.com/xid/0bzranqs7bdmc3ysq-da50v4

https://wolfram.com/xid/0bzranqs7bdmc3ysq-cg553e

Wolfram Research (2012), GraphAssortativity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphAssortativity.html (updated 2015).
Text
Wolfram Research (2012), GraphAssortativity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphAssortativity.html (updated 2015).
Wolfram Research (2012), GraphAssortativity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphAssortativity.html (updated 2015).
CMS
Wolfram Language. 2012. "GraphAssortativity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphAssortativity.html.
Wolfram Language. 2012. "GraphAssortativity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphAssortativity.html.
APA
Wolfram Language. (2012). GraphAssortativity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphAssortativity.html
Wolfram Language. (2012). GraphAssortativity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphAssortativity.html
BibTeX
@misc{reference.wolfram_2025_graphassortativity, author="Wolfram Research", title="{GraphAssortativity}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphAssortativity.html}", note=[Accessed: 23-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_graphassortativity, organization={Wolfram Research}, title={GraphAssortativity}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphAssortativity.html}, note=[Accessed: 23-May-2025
]}