I would like to swap labels of nodes on a directed graph.
For instance:
h = Graph[{2 \[DirectedEdge] 1, 3 \[DirectedEdge] 1, 4 -> 2, 5 -> 2},
EdgeStyle -> Arrowheads[.04],
VertexLabels -> Placed["Name", Center], VertexSize -> 0.2,
VertexStyle -> White, EdgeStyle -> Blue,
VertexShapeFunction -> "Square"]
h = ReverseGraph[h, VertexCoordinates -> GraphEmbedding[h]]
Drop[VertexOutComponent[h, 2, 1], 1]
This code yields the out vertices of the directed graph namely 4 and 5 (dropping the vertex 2 that we start from).
How does Mathematica incorporate operations over labels such as:
Exchange the label of the starting node (2) with the minimum label of the out-vertices of 2 (i.e. 4 which is minimum among the labels of the out-vertices of 2: i.e. the minimum of the labels of nodes 4 and 5).
ETA: I found documentation on VertexReplace. However it does not give me the right outcome as it deals with Vertices, not the labels of vertices.
A more general question: these are basic constructions on graphs. I have the elementary introduction to the Wolfram Language and the Mathematica book, neither of which are comprehensive enough to deal with general graph questions. The online info is very scattered. Are there thorough introductions available to graph manipulation (labels, vertices, edges) for Mathematica that include basic constructions such as the above?
Graph[g, VertexLabels -> Thread[VertexList[g], labelVector]]
$\endgroup$