Explanation required for the Slot function

I have been trying to understand the following function

l = {{1, 3}, {3, 4}};
GraphPlot[{1 -> 2, 3 -> 4, 1 -> 3, 2 -> 4, 1 -> 2, 3 -> 4},
VertexLabeling -> True,
EdgeRenderingFunction -> (If[
Intersection[l, {#2}] != {}, {Red, Arrow[#1, .1]}, {Blue,
Arrow[#1, .1]}] &)]

(Courtesy of the link: Coloring edges in GraphPlot).

I am unable to understand how the slot function is working..i.e., how Intersection[l,{#2}] is working out.

Could someone please explain this

Thanks

=================

  

 

Have you already read the Pure Functions tutorial and the parameters of EdgeRenderingFunction listed in the GraphPlot documentation?
– Edmund
Jan 23 at 4:01

=================

1 Answer
1

=================

You can get insight into what the arguments for EdgeRenderingFunction are by “looking under the hood”,e.g.

GraphPlot[{1 -> 2, 3 -> 4, 1 -> 3, 2 -> 4, 1 -> 2, 3 -> 4},
VertexLabeling -> True,
EdgeRenderingFunction -> (If[Intersection[l, {#2}] != {},
Print[{#1, #2, #3}]; {Red, Arrow[#1, .1]}, {Blue,
Arrow[#1, .1]}] &)]

You will slot 1 (#1) are the coordinates of the edge ends, #2 is the vertex pair, and the third slot is any label specified for edge (in this case).

So the code aims to color edges {1,3},{3,4} blue (non-empty intersection with l) or red (disjoint with l).