I have a grid, and I delete a vertex, while keeping the embedding:

g = GridGraph[{15, 15}];
g = SetProperty[g, VertexCoordinates -> GraphEmbedding[g]];
g = VertexDelete[g, {50}];

Before deleting the vertices, I check their graph embedding:

I check the graph embedding before and after vertex deletion, via the code:


The result is that beforehand, the output was "{4., 4.}" and "{5., 4.}". After vertex deletion it is "{4., 4.}" and "{5., 5.}".

For some reason however the embedding is visually the same. Then why is this an issue? I use the following code to draw directed edges of a given graph path:

graphArrow[edge_] := 
HighlightGraph[g, someData, VertexSize -> Medium, 
  Epilog -> {Black, Arrowheads[.03], 
    graphArrow /@ someData}];

The result is that some of the arrows drawn in Epilog look "diagonal", due to this graph embedding artefact. Example:

HighlightGraph[g, 49 -> 64, VertexSize -> Medium, 
 Epilog -> {Black, Arrowheads[.03], graphArrow /@ {49 -> 64}}]

How can I fix this and correctly draw directed edges?

  • $\begingroup$ I see, you can use PropertyValue[{g, (*vertex*)}, VertexCoordinates] instead of GraphEmbedding[g][[edge[[1]]]] $\endgroup$ – Kuba Jun 9 '17 at 12:36
  • $\begingroup$ or GraphEmbedding[g][[VertexIndex[g, edge[[1]]]]] $\endgroup$ – halmir Jun 12 '17 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.