WOLFRAM

GraphTriangleCount
GraphTriangleCount

New in 14.1

gives the number of triangles in the graph g.

Details

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Count triangles in a graph:

Out[2]=2

Count triangles in social networks:

Out[2]=2

Scope  (4)Survey of the scope of standard use cases

GraphTriangleCount works with undirected graphs:

Out[1]=1

Directed graphs:

Out[1]=1

Use rules to specify the graph:

Out[1]=1

GraphTriangleCount works with large graphs:

Out[2]=2
Out[3]=3

Applications  (1)Sample problems that can be solved with this function

Compute the transitivity of a graph:

Out[4]=4

Compare with GlobalClusteringCoefficient:

Out[5]=5

Properties & Relations  (2)Properties of the function, and connections to other functions

Use MatrixPower to count triangles in a graph:

Out[16]=16
Out[18]=18

Use FindCycle to list triangles in a graph:

Out[3]=3
Out[4]=4

Possible Issues  (1)Common pitfalls and unexpected behavior

Multi-edges are ignored:

Out[1]=1
Wolfram Research (2024), GraphTriangleCount, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphTriangleCount.html.
Wolfram Research (2024), GraphTriangleCount, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphTriangleCount.html.

Text

Wolfram Research (2024), GraphTriangleCount, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphTriangleCount.html.

Wolfram Research (2024), GraphTriangleCount, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphTriangleCount.html.

CMS

Wolfram Language. 2024. "GraphTriangleCount." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GraphTriangleCount.html.

Wolfram Language. 2024. "GraphTriangleCount." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GraphTriangleCount.html.

APA

Wolfram Language. (2024). GraphTriangleCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphTriangleCount.html

Wolfram Language. (2024). GraphTriangleCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphTriangleCount.html

BibTeX

@misc{reference.wolfram_2025_graphtrianglecount, author="Wolfram Research", title="{GraphTriangleCount}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/GraphTriangleCount.html}", note=[Accessed: 08-July-2025 ]}

@misc{reference.wolfram_2025_graphtrianglecount, author="Wolfram Research", title="{GraphTriangleCount}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/GraphTriangleCount.html}", note=[Accessed: 08-July-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_graphtrianglecount, organization={Wolfram Research}, title={GraphTriangleCount}, year={2024}, url={https://reference.wolfram.com/language/ref/GraphTriangleCount.html}, note=[Accessed: 08-July-2025 ]}

@online{reference.wolfram_2025_graphtrianglecount, organization={Wolfram Research}, title={GraphTriangleCount}, year={2024}, url={https://reference.wolfram.com/language/ref/GraphTriangleCount.html}, note=[Accessed: 08-July-2025 ]}