VertexQ

VertexQ[g,v]

yields True if v is a vertex in the graph g and False otherwise.

Examples

open allclose all

Basic Examples  (2)

Test whether an item is a vertex of a graph:

Test items of various kinds:

Scope  (5)

VertexQ works with undirected graphs:

Directed graphs:

Multigraphs:

Mixed graphs:

VertexQ works with large graphs:

Compare performance with a test based on VertexList:

Applications  (3)

Check input to a function:

Take the correct action depending on whether an item is a vertex or an edge:

Act on a vertex:

Act on an edge:

Use Graph and VertexQ for fast set membership tests:

Compare with MemberQ:

Properties & Relations  (3)

VertexQ[g,v] is equivalent to MemberQ[VertexList[g],v]:

The performance of VertexQ is typically higher:

Use VertexIndex to find the position of a vertex in VertexList[g]:

VertexIndex is typically faster than Position:

Use EdgeQ to test whether an edge is part of a graph:

Possible Issues  (1)

Some vertices do not seem to be recognized:

Membership is tested using SameQ rather than Equal:

By using identical expressions it can still be tested:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2024_vertexq, author="Wolfram Research", title="{VertexQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/VertexQ.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_vertexq, organization={Wolfram Research}, title={VertexQ}, year={2010}, url={https://reference.wolfram.com/language/ref/VertexQ.html}, note=[Accessed: 22-November-2024 ]}