gives the assortativity coefficient of a graph g using vertex degrees.
GraphAssortativity[g,"prop"]
gives the assortativity coefficient of the graph g using vertex property "prop".
GraphAssortativity[g,{{vi 1,vi 2,…},…}]
gives the assortativity coefficient of the graph g with respect to the vertex partition {{vi 1,vi 2,…},…}.
GraphAssortativity[g,{v1,v2,…}{x1,x2,…}]
gives the assortativity coefficient of the graph g using data {x1,x2,…} for vertices {v1,v2,…}.
GraphAssortativity[{vw,…},…]
uses rules vw to specify the graph g.
GraphAssortativity
gives the assortativity coefficient of a graph g using vertex degrees.
GraphAssortativity[g,"prop"]
gives the assortativity coefficient of the graph g using vertex property "prop".
GraphAssortativity[g,{{vi 1,vi 2,…},…}]
gives the assortativity coefficient of the graph g with respect to the vertex partition {{vi 1,vi 2,…},…}.
GraphAssortativity[g,{v1,v2,…}{x1,x2,…}]
gives the assortativity coefficient of the graph g using data {x1,x2,…} for vertices {v1,v2,…}.
GraphAssortativity[{vw,…},…]
uses rules vw to specify the graph g.
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].
- GraphAssortativity takes the following options:
-
"DataType" Automatic data type "Normalized" True whether the result should be normalized "Weighted" Automatic edge weights - 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 all close allBasic Examples (2)
Scope (12)
GraphAssortativity works with undirected graphs:
GraphAssortativity[[image]]GraphAssortativity[[image]]GraphAssortativity[[image]]GraphAssortativity[[image]]GraphAssortativity[[image]]Use rules to specify the graph:
GraphAssortativity[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}]Compute the assortativity coefficient using vertex property data:
GraphAssortativity[[image], "VertexColor"]GraphAssortativity[[image], {{1, 2, 7}, {3, 4}, {5, 6}}]GraphAssortativity[[image], Range[7] -> RandomReal[1, 7]]A partition or assignment of a subset of VertexList:
GraphAssortativity[[image], {{1, 2, 7}, {3, 4}}]GraphAssortativity works with symbolic expressions:
GraphAssortativity[[image], Automatic -> {a, b, c, d}, "DataType" -> "Quantitative"]GraphAssortativity works with large graphs:
g = ExampleData[{"NetworkGraph", "Internet"}];VertexCount[g]N[GraphAssortativity[g]]//TimingOptions (4)
"DataType" (2)
Use "DataType"->"Quantitative":
g = GridGraph[{2, 3}]data = {0.1, 0.1, 0.2, 0.2, 0.3, 0.3};GraphAssortativity[g, Automatic -> data]GraphAssortativity[g, Automatic -> data, "DataType" -> "Quantitative"]Use "DataType"->"Categorical":
g = GridGraph[{2, 3}]data = {a, b, b, a, a, a};GraphAssortativity[g, Automatic -> data]GraphAssortativity[g, Automatic -> data, "DataType" -> "Categorical"]"Weighted" (1)
By default, edge weights are used:
g = [image];GraphAssortativity[g]Use "Weighted"->False to ignore edge weights:
GraphAssortativity[g, "Weighted" -> False]"Normalized" (1)
By default, the normalized value of modularity is computed as the assortativity coefficient:
g = GridGraph[{2, 3}]GraphAssortativity[g]Use "Normalized"->False to compute the assortativity modularity:
GraphAssortativity[g, "Normalized" -> False]Applications (3)
Compare the assortativity coefficient of vertex partitions by vertex color:
graphs = {[image], [image], [image], [image]};Labeled[#, GraphAssortativity[#, "VertexColor"]]& /@ graphsDisassortativity by number of friends in a friendship network:
g = ExampleData[{"NetworkGraph", "ZacharyKarateClub"}];N[GraphAssortativity[g]]A partition of the network shows assortative mixing:
partition = FindGraphPartition[g];HighlightGraph[g, Table[Subgraph[g, i], {i, partition}]]N[GraphAssortativity[g, partition]]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:
g = \!\(\*GraphicsBox[«10»]\);Highly social students are friends with other highly social students:
N[GraphAssortativity[g]]Positive tendency for students to associate with others of the same race:
N[GraphAssortativity[g, "Race"]]Properties & Relations (2)
The assortativity coefficient is between -1 and 1:
N[GraphAssortativity[RandomGraph[{100, 200}]]]GraphAssortativity[GraphData[{5, 20}]]Completely disassortative graph:
GraphAssortativity[StarGraph[5]]GraphAssortativity is Pearson correlation coefficient of degree between connected vertices:
g = RandomGraph[{10, 20}];GraphAssortativity[g]Correlation gives the Pearson correlation coefficient:
x = EdgeList[g] /. i_j_ :> {VertexDegree[g, i], VertexDegree[g, j]};y = EdgeList[g] /. i_j_ :> {VertexDegree[g, j], VertexDegree[g, i]};Correlation[Flatten[x], Flatten[y]]See Also
Related Guides
Text
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.
APA
Wolfram Language. (2012). GraphAssortativity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphAssortativity.html
BibTeX
@misc{reference.wolfram_2026_graphassortativity, author="Wolfram Research", title="{GraphAssortativity}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphAssortativity.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_graphassortativity, organization={Wolfram Research}, title={GraphAssortativity}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphAssortativity.html}, note=[Accessed: 13-June-2026]}