gives the edge cycle matrix of a graph g.
EdgeCycleMatrix[{vw,…}]
uses rules vw to specify the graph g.
EdgeCycleMatrix
gives the edge cycle matrix of a graph g.
EdgeCycleMatrix[{vw,…}]
uses rules vw to specify the graph g.
Details
- EdgeCycleMatrix is also known as tie-set matrix or loop matrix.
- EdgeCycleMatrix returns a matrix cij where each row corresponds to a cycle i in the graph g, and each column corresponds to an edge ej.
- For an undirected graph, cij is 1 if edge ej is part of cycle i and zero otherwise.
- For a directed graph, cij is 1 if edge ej is part of cycle i, -1 if edge ej in reverse direction is part of cycle i, and zero otherwise.
- Edge ej is the edge at position j in EdgeList[g], and the index j for an edge ej can be found from EdgeIndex[g,ej].
- EdgeCycleMatrix gives a basis for all the cycles in the graph g.
- EdgeCycleMatrix works with undirected graphs, directed graphs, multigraphs, and mixed graphs.
Background & Context
- EdgeCycleMatrix returns a matrix cij in which each row corresponds to a cycle i in a graph and each column corresponds to an edge ej. An edge cycle matrix is determined by the incidences of edges and cycles in a graph, and cycles in an edge cycle matrix form a cycle basis of a graph. Cycle bases are useful in the study of chemical graphs, to generate large cycle families, and to compute voltage or current in a circuit. Edge cycle matrices are also known as tie-set or loop matrices.
- For an undirected graph, cij is 1 if edge ej is part of cycle i and zero otherwise. For a directed graph, cij is 1 if edge ej is part of cycle i,
if edge ej in reverse direction is part of cycle i, and zero otherwise. - FindFundamentalCycles is a related function that can be used to return a list of fundamental cycles of a graph.
Examples
open all close allBasic Examples (2)
Find the edge cycle matrix of a graph:
g = WheelGraph[4]EdgeCycleMatrix[g]//MatrixFormObtain a cycle basis of a graph:
g = GridGraph[{3, 3}];Pick[EdgeList[g], #, 1] & /@ EdgeCycleMatrix[g]HighlightGraph[g, #] & /@ %Scope (6)
EdgeCycleMatrix works with undirected graphs:
EdgeCycleMatrix[[image]]//MatrixFormEdgeCycleMatrix[[image]]//MatrixFormEdgeCycleMatrix[[image]]//MatrixFormEdgeCycleMatrix[[image]]//MatrixFormUse rules to specify the graph:
EdgeCycleMatrix[{1 -> 2, 1 -> 4, 2 -> 3, 2 -> 5, 3 -> 6, 4 -> 5, 4 -> 7, 5 -> 6, 5 -> 8, 6 -> 9, 7 -> 8, 8 -> 9}]//MatrixFormEdgeCycleMatrix works with large graphs:
g = GridGraph[{10, 10, 10}];EdgeCycleMatrix[g]//TimingApplications (1)
Obtain a cycle basis of a graph:
g = WheelGraph[4]basis = Pick[EdgeList[g], #, 1] & /@ EdgeCycleMatrix[g]addedges[edges_] := Cases[Tally[Flatten[edges]], {e_, _ ? OddQ} :> e]cycles = addedges[Pick[basis, #, 1]]& /@ Most[Tuples[{1, 0}, 3]]Properties & Relations (3)
Use EdgeList to obtain a cycle representation:
g = GridGraph[{3, 3}];Pick[EdgeList[g], #, 1] & /@ EdgeCycleMatrix[g]HighlightGraph[g, #]& /@ %A connected graph with n vertices and m edges has an edge cycle matrix of dimensions (m-n+1):
g = PetersenGraph[];{n, m} = {VertexCount[g], EdgeCount[g]};Dimensions[EdgeCycleMatrix[g]] == {m - n + 1, m}Compute the EdgeCycleMatrix from the IncidenceMatrix:
g = WheelGraph[4, DirectedEdges -> True]m = IncidenceMatrix[g];NullSpace[m]//MatrixFormCompare with EdgeCycleMatrix:
EdgeCycleMatrix[g]//MatrixFormSee Also
Related Guides
Text
Wolfram Research (2014), EdgeCycleMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/EdgeCycleMatrix.html (updated 2015).
CMS
Wolfram Language. 2014. "EdgeCycleMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/EdgeCycleMatrix.html.
APA
Wolfram Language. (2014). EdgeCycleMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/EdgeCycleMatrix.html
BibTeX
@misc{reference.wolfram_2026_edgecyclematrix, author="Wolfram Research", title="{EdgeCycleMatrix}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/EdgeCycleMatrix.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_edgecyclematrix, organization={Wolfram Research}, title={EdgeCycleMatrix}, year={2015}, url={https://reference.wolfram.com/language/ref/EdgeCycleMatrix.html}, note=[Accessed: 12-June-2026]}