VertexIndex

VertexIndex[g,v]

gives the integer index for the vertex v in the graph g.

VertexIndex[{vw,},]

uses rules vw to specify the graph g.

Details

Examples

open allclose all

Basic Examples  (1)

Find the integer index of a vertex:

The index corresponds to the position in the vertex list:

Scope  (4)

VertexIndex works with undirected graphs:

Directed graphs:

Use rules to specify the graph:

VertexIndex works with large graphs:

Properties & Relations  (11)

The VertexIndex of a vertex corresponds to its position in VertexList:

VertexIndex is typically faster than Position:

VertexQ can be used to tell whether VertexIndex will succeed:

Try a vertex item:

Use EdgeIndex to find the integer index of an edge:

VertexIndex gives the row and column ordering used in AdjacencyMatrix:

Test whether and are adjacent:

VertexIndex gives the row and column ordering used in WeightedAdjacencyMatrix:

Find the weight of the edge :

VertexIndex gives the row and column ordering used in AdjacencyMatrix:

Find the shortest distance between and :

VertexIndex gives the row and column ordering used in KirchhoffMatrix:

Find the vertex degree of :

VertexIndex and EdgeIndex give the row and column ordering used in IncidenceMatrix:

Test whether is incident to :

VertexIndex gives the ordering of VertexDegree:

Find the vertex degree for 1:

Use VertexDegree directly:

VertexIndex gives the ordering of centralities:

Find centrality measures for 1:

Possible Issues  (1)

Some vertices do not seem to have integer indices:

Membership is tested using SameQ rather than Equal:

By using identical expressions the integer index is found:

Introduced in 2010
 (8.0)
 |
Updated in 2015
 (10.3)