# Can I Use a List To Position An Arbitrary Number of Graphic Objects?

I can use a function to compute the positions of individual nodes of a neural network based on how many there are in each layer (nodesPerLayerList below). Now I want to display them all in position. The Map function below does put out the requested number of circles, but does not position them. The multiple Graphics examples in the hands-on start book type out each object explicitly.

Is there a simple way? Must I loop?

nodesPerLayerList = { 2 , 4 , 3 , 4 , 1 , 1  } ;
nodeCenterList = positionNodes[ nodesPerLayerList ] ;
nodeCenterList

(*
{{{10,30},4},{{10,42},4},{{24,18},4},{{24,30},4},{{24,42},4},
{{24,53},4},{{38,24},4},{{38,36},4},{{38,48},4},{{52,18},4},{{52,30},4},
{{52,42},4},{{52,53},4},{{65,36},4},{{79,36},4}}
*)


And then

Map[ Graphics[ Circle[] ] , nodeCenterList ]

• Welcome to Mathematica.SE and thank you for taking the time to format your post correctly even in your first question ever. Just in case you don't know already: When you see good questions and answers, vote them up by clicking the gray triangles because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! If you have questions about a solution, you can comment on it. Jun 7 '18 at 19:51
• Thank you to both halirutan and henrik for your very welcoming and helpful responses. I am off to summer school in a couple weeks and am, in the mean time, renewing my acquaintance with the top row of my keyboard, all too often with a pinkie on the shift key. Jun 8 '18 at 11:44

Map was already very close. Try Graphics[Circle @@@ nodeCenterList] (have a look at Apply to understand what is happening). Try also Map[Circle ,nodeCenterList] and observe that there will be too many braces. Apply gets rid of them by replacing them.
Note also that Circle[] stands for the unit circle centered at {0,0}.
In the end, just wrap a Graphics around all graphics primitives. You can also join Graphics with Show.
• So, what are they? =D Line always wants to get a list of points. In this case, Map is more suitable, e.g., Line /@ {{{10, 30}, {10, 42}}, {{38, 48}, {52, 18}}} (like @@@ is the infix form of Apply, /@ is the infix form of Map. Jun 9 '18 at 17:15
• Hi James, I see what you are about to do. You can also reference the vertices by their position in the list nodeCenterList and extract the midpoints automatically like this. If you plot the vertices as white Disks on top of the edges, you don't have to compute the points where an edge meets the circles: edges = {{1, 3}, {1, 4}, {1, 5}}; edgepts = Partition[nodeCenterList[[Flatten[edges], 1]], 2]; Graphics[{ Line /@ edgepts, EdgeForm[{Black, Thick}], FaceForm[White], Disk @@@ nodeCenterList }] Jun 9 '18 at 17:26
• You might also be interested in Graph (with VertexCoordinates set to ). That's the datatype specific for to networks and there are many styling options. Here an example: Graph[ Range[Length[nodeCenterList]], edges, VertexCoordinates -> nodeCenterList[[All, 1]], VertexShapeFunction -> (Disk[#1, 4] &), VertexStyle -> Directive[Lighter@Red], EdgeShapeFunction -> (Line[#1] &), EdgeStyle -> Directive[Thick, Dashed, Black], VertexLabels -> Placed["Name", Center], VertexLabelStyle -> Directive[White, Italic, 14] ] Jun 9 '18 at 17:32