I want to build a small GUI, where the user can select either a single edge or a single node of a graph. I got to this point:
selection = {};
Dynamic[Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3,
3 \[UndirectedEdge] 1},
PlotLabel -> selection,
VertexShapeFunction -> (EventHandler[
Disk[#1, .1], {"MouseClicked" :> (selection = {#2})}] &),
EdgeShapeFunction -> (EventHandler[
Arrow[#1, .1], {"MouseClicked" :> (selection = {#2})}] &),
GraphHighlight -> selection,
GraphHighlightStyle -> "Thick",
ImageSize -> 200
]]
Which gives the following (note that I already highlighted an edge by clicking on it for clarity):

Now if I try to click on one of the nodes, the dynamic visualization breaks, giving back the unevaluated result:

Note, that the GraphHighlight and PlotLabel options correctly registered the click, as the selected node is on their right hand sides. Any idea what the difference is in this context between edges and nodes? The two clicking functionality are meant to be identical.


