3
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ please share the code that produces the plot $\endgroup$
    – Fraccalo
    Feb 27, 2020 at 14:46
  • 2
    $\begingroup$ HighlightGraph[CompleteGraph[5], {Style[UndirectedEdge[3, 4], Opacity[0]]}] $\endgroup$
    – ktm
    Feb 27, 2020 at 15:08
  • 1
    $\begingroup$ 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]] $\endgroup$
    – kglr
    Feb 28, 2020 at 10:45

1 Answer 1

1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.