EdgeIndex
Details
- EdgeIndex is also known as edge ordering.
- EdgeIndex gives the ordering used in functions such as EdgeList and IncidenceMatrix.
- EdgeIndex[g,e] gives the position for an edge e in EdgeList[g].
- EdgeIndex[g,e] gives the column position for an edge e in IncidenceMatrix[g].
Examples
open all close allBasic Examples (1)
Scope (4)
EdgeIndex works with undirected graphs:
EdgeIndex[[image], ab]EdgeIndex[[image], ab]Use rules to specify the graph:
EdgeIndex[{a -> b, b -> c, c -> a}, ab]EdgeIndex works with large graphs:
g = GridGraph[{10, 10, 10, 10}];Timing[EdgeIndex[g, 12]]Properties & Relations (5)
The EdgeIndex of an edge corresponds to its position in EdgeList:
g = CompleteGraph[4, DirectedEdges -> True, EdgeStyle -> Arrowheads[Small]]Table[EdgeList[g][[EdgeIndex[g, e]]] === e, {e, EdgeList[g]}]Sort the vertices in undirected edges for comparison:
g = CompleteGraph[4]Table[Sort[EdgeList[g][[EdgeIndex[g, e]]]] === Sort[e], {e, EdgeList[g]}]EdgeIndex is typically faster than Position:
g = GridGraph[{10, 10, 10, 10}];{Timing[EdgeIndex[g, 12]], Timing[Position[EdgeList[g], 12 | 21]]}EdgeQ can be used to tell whether EdgeIndex will succeed:
g = [image];{EdgeQ[g, 32], EdgeIndex[g, 32]}{EdgeQ[g, 24], EdgeIndex[g, 24]}Use VertexIndex to find the integer index of a vertex:
VertexIndex[Graph[{23, 31}], 2]VertexIndex and EdgeIndex give the row and column ordering used in IncidenceMatrix:
g = Graph[{ad, ab, bc, cd}];(m = IncidenceMatrix[g])//MatrixFormm[[VertexIndex[g, a], EdgeIndex[g, ad]]]Possible Issues (1)
Some edges do not seem to have integer indices:
v = Block[{ϵ = 10 ^ -15}, Range[1.1, 1.4, 0.1] + ϵ]g = Graph[v, Table[v[[i]]v[[i + 1]], {i, 1, 3}], VertexShapeFunction -> "Name"]EdgeIndex[g, 1.11.2]Membership is tested using SameQ rather than Equal:
{v[[1]]v[[2]] === 1.11.2, v[[1]]v[[2]] == 1.11.2}By using identical expressions, the integer index is found:
EdgeIndex[g, v[[1]]v[[2]]]See Also
Related Guides
Text
Wolfram Research (2010), EdgeIndex, Wolfram Language function, https://reference.wolfram.com/language/ref/EdgeIndex.html (updated 2015).
CMS
Wolfram Language. 2010. "EdgeIndex." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/EdgeIndex.html.
APA
Wolfram Language. (2010). EdgeIndex. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/EdgeIndex.html
BibTeX
@misc{reference.wolfram_2026_edgeindex, author="Wolfram Research", title="{EdgeIndex}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/EdgeIndex.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_edgeindex, organization={Wolfram Research}, title={EdgeIndex}, year={2015}, url={https://reference.wolfram.com/language/ref/EdgeIndex.html}, note=[Accessed: 12-June-2026]}