# Plotting the complement of a graph without changing the name of the vertices

I have a graph in the form {Dog -> Apple, Apple -> Screwdriver}, I used to plot a graph in the following way:

GraphPlot[{Dog -> Apple, Apple -> Screwdriver}]


I'd like to plot the complement of the graph, the following chain of commands does the job,

GraphPlot[
GraphComplement[
UndirectedGraph[Graph[{Dog -> Apple, Apple -> Screwdriver}]]]]


but it has the disadvantage that the names of the vertices are changed into numbers. I'd like to keep the names. How can I do this?

g1 = Graph[{Dog -> Apple, Apple -> Screwdriver}, VertexLabels -> "Name",
GraphLayout -> "CircularEmbedding", ImagePadding -> 40]


g2 = GraphComplement[UndirectedGraph[g1], VertexLabels -> "Name",   ImagePadding -> 40,
VertexCoordinates -> GraphEmbedding[g1]]


Using GraphPlot

GraphPlot[AdjacencyMatrix[g2], VertexLabeling -> True] /.
Framed[i_, rest__] :> Framed[VertexList[g2][[i]], rest]


or

m = AdjacencyMatrix[UndirectedGraph@g1];
am = 1 - IdentityMatrix[Length[m]] - m;

GraphPlot[am, VertexLabeling -> True, DirectedEdges -> False, AspectRatio -> 1,
VertexRenderingFunction -> ({FaceForm[Orange],
Rectangle[# - {.2, .01}, {.2, .01} + #], Text[VertexList[g1][[#2]], #1]} &)]


• This looks really nice, thank you! Can it be done by using GraphPlot? I'd prefer that function since it has many methods for drawing the graph, and also it labels the vertices more discretely (using only a tooltip) so I can only check a label if I'm interested in said vertex. Also I'm sorry that I dod not specify this in the original question. – Daniel Soltész May 28 '16 at 22:26