I'd like to custom name the vertices of a (complete) graph and have those names reflected in the edges.
shiftGraph produces a complete graph with vertices labels from imin to imax.
CompleteGraph[imax - imin + 1, DirectedEdges -> True,
VertexLabels -> Thread[Rule[Range[1, imax - imin + 1],Range[imin, imax]]]];
shiftGraph[2,4] yields:
But those vertex labels are not inherited by the edges:
EdgeList[shiftGraph[2, 4]]
yields
{1 [DirectedEdge] 2, 1 [DirectedEdge] 3, 2 [DirectedEdge] 1, 2 [DirectedEdge] 3, 3 [DirectedEdge] 1, 3 [DirectedEdge] 2}
Is that expected or desirable? I suppose the fix is to apply the VertexLabels rules to the edges. Cleaner methods?
VertexLabels
only affects the display of the vertices - the underlying vertex names are still 1 to n (compare also withGraph
). Unfortunately, you can't specify the vertex names forCompleteGraph
upon construction, so you'll have to rename them after the fact usingVertexReplace
$\endgroup$