VertexList¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
VertexList[g]
gives the list of vertices of the graph g.
Examples (6)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (4)¶
In[1]:= VertexList[Graph[{1,2,3,4},{1->2,2->3,3->4,4->1}]]
Out[1]= {1, 2, 3, 4}
In[2]:= VertexList[Graph[{c->a, a->b}]]
Out[2]= {c, a, b}
In[3]:= VertexList[Graph[{}, {}]]
Out[3]= {}
In[4]:= VertexList[5]
Out[4]= VertexList[5]
Applications (2)¶
Vertices derived from the edges
Vertices may be any expressions
Implementation notes¶
Algorithm. builtin_vertex_list is a thin reader: for a valid graph it returns a copy of
the graph's vertex List ā the first argument of the canonical Graph[List[verts],
List[edges]] node ā in canonical order, with no computation. For a non-graph argument it defers
to the hypergraph reader hyp_vertex_list, which handles a Hypergraph[...] argument or returns
unevaluated.
Data structures. None beyond the deep copy of the stored vertex list; the canonical graph
already holds its vertices in the order VertexList reports.
Complexity / limits. O(V) for the copy. Always exactly one argument.
Protected. The query/representation heads (VertexList,EdgeList,VertexCount,EdgeCount,AdjacencyList,VertexDegree,VertexInDegree,VertexOutDegree,EdgeWeight) are all thin readers over the canonical form and return unevaluated on a non-graph argument.- Canonical order is the explicit vertex list, or first-appearance order when
Graph[e]derived the vertices from the edges.
Attributes: Protected.
References¶
See also: EdgeList, VertexCount, EdgeCount, AdjacencyList, VertexDegree, VertexInDegree, VertexOutDegree, EdgeWeight
- Source:
src/graph/vertexlist.c - Specification:
docs/spec/builtins/graphs.md - Tests:
tests/test_graph.c - Tests:
tests/test_graph_algos.c - Tests:
tests/test_graph_ops.c - Tests:
tests/test_hypergraph.c
Notes & additional examples¶
Notes¶
VertexList[g] returns the vertices of g in canonical order. When a graph is built from edges
alone, the vertices are derived from the edge endpoints in order of first appearance.
Vertices are arbitrary expressions, not just integers; a path on symbols a, b, c lists
them unchanged.