# How do I make some edges in a graph invisible?

I have a number of nodes, each with a numeric label and arbitrary connections between these nodes. When I plot the graph I would like nodes similar in value to be colocated as far as possible within the constraints of the arbitrary connections above. My first thought is to create extra connections between nodes sharing similar values, but if I then plot such a graph those connections will obscure the graph of arbitrary connections.

My question then becomes how can I make the edges in the latter set invisible, so the connections influence the layout of the former without obscuring the plot?

• please share the code that produces the plot – Fraccalo Feb 27 '20 at 14:46
• HighlightGraph[CompleteGraph[5], {Style[UndirectedEdge[3, 4], Opacity[0]]}] – ktm Feb 27 '20 at 15:08
• If edgestohide is the the list of edges to be hidden in graph g, you can use Graph[g, EdgeStyle->{Alternatives@@edgestohide ->Opacity[0]}] ; or, to remove those edges, Graph[EdgeDelete[g, edgestohide], VertexCoordinates->GraphEmbedding[g]] – kglr Feb 28 '20 at 10:45

Compute the vertex coordinates for your modified graph (GraphEmbedding) then transfer them to the original graph (VertexCoordinates option).