# Graph rendering not working as expected

I'm running the older Mathematica v6 which seems to go through the edges of graphs twice. Is this a bug? Is it fixed on the latest version? Please just try this command:

GraphPlot[{1 -> 2, 2 -> 3, 3 -> 1},
EdgeRenderingFunction -> (If[True, Print["e ", ##]; Black] &),
VertexRenderingFunction -> (If[True, Print["v ", ##]; Black] &)]

v {0.496926,0.867793}11
e {{0.496926,0.867793},{0.999994,0.00354563}}{1,2}None{1,2}
e {{0.999994,0.00354563},{0.,0.}}{2,3}None{2,3}
e {{0.,0.},{0.496926,0.867793}}{3,1}None{3,1}
e {{0.496926,0.867793},{0.999994,0.00354563}}{1,2}None{1,2}
e {{0.999994,0.00354563},{0.,0.}}{2,3}None{2,3}
e {{0.,0.},{0.496926,0.867793}}{3,1}None{3,1}
v {0.496926,0.867793}11
v {0.999994,0.00354563}22
v {0.,0.}33

-
Please do not use [bug] as tag unless the problem has been confirmed as bug by WRI. –  m_goldberg Jul 8 '13 at 23:27
Same result in version 9.0.1. I don't understand why this occurs. Good question. –  Oleksandr R. Jul 9 '13 at 7:35
I wouldn't call this a bug. Edges are only rendered once, and it shouldn't be of concern how many times the edge rendering function is evaluated. You should construct the edge rendering function so it has no side effects, and the number of times it's evaluated has no effect on the result. –  Szabolcs Jul 9 '13 at 8:09
@m_goldberg ... or a number of SE users agrees it's a bug. –  Sjoerd C. de Vries Jul 9 '13 at 9:00
If it's a problem you can wrap the function in Hold and release it after the graphics expression is created: GraphPlot[{1->2,2->3,3->1},EdgeRenderingFunction->Hold[(Print["e ",##];Arrow[#1,0.1])&]]//ReleaseHold –  Simon Woods Jul 9 '13 at 9:14

While your code gives the same result on Mathematica 9.0.1, a similar expression using Graph (versions 8 and above only):

Graph[{1 -> 2, 2 -> 3, 3 -> 1},
EdgeShapeFunction   -> ((Print["e ", ##]; {Red, Arrow[#]}) &),
VertexShapeFunction -> ((Print["v ", ##]; {Green, Disk[#1, .025]}) &)]


gives these results:

e {{-0.866025,-0.5},{0.866025,-0.5}} 1 -> 2
e {{0.866025,-0.5},{1.83697*10^-16,1.}} 2 ->3
e {{1.83697*10^-16,1.},{-0.866025,-0.5}} 3 ->1
v {-0.866025,-0.5} 1 {0.0203996,0.0203996}
v {0.866025,-0.5} 2 {0.0203996,0.0203996}
v {1.83697*10^-16,1.} 3 {0.0203996,0.0203996}


-
Thanks for the v9 check and workaround. I can't agree with those who don't want to call this a bug. Maybe GraphPlot is just slower than necessary (but I suspect that edge graphics also get rendered twice which could effect non-opaque alpha-level objects), so maybe it's minor, but I'm sure the original Mathematica designer did not intend for this. By the way, I don't have access to v9, so am working around the bug in other ways. –  bobuhito Jul 15 '13 at 16:28
@bobuhito given the shift to new graphing functions in 8 and 9, perhaps this 'bug' isn't so likely to be fixed. (and thanks for accept:) –  cormullion Jul 15 '13 at 16:56