# Place table inside a graph

I have a simple graph:

mygraph = Graph[{1 -> 2, 2 -> 3, 3 -> 1}]


and a simple table:

mytable =
TableForm[{{a, b}, {c, d}, {e, f}},
TableHeadings -> {{"r1", "r2", "r3"}, {"c1", "c2"}}]


and I would like to place the table adjacent one of the vertices in the graph.

I've tried Epilog, and converting mytable into some form of graphic to Show[] them overlapped, without success.

As mentioned:

Graph[{1 -> 2, 2 -> 3, 3 -> 1},
Epilog ->
Graphics@TableForm[{{a, b}, {c, d}, {e, f}},
TableHeadings -> {{"r1", "r2", "r3"}, {"c1", "c2"}}]]


(and obvious variations thereon) fails.

• Can you show your attempt with Epilog? – Szabolcs Feb 25 '19 at 17:55
• Perhaps GraphicsGrid could help, since it automatically outputs a Graphics object? Something along the lines of GraphicsGrid[ {{"", "c1", "c2"}, {"r1", a, b}, {"r2", c, d}, {"r3", e, f}}, Dividers -> {{False, True}, {False, True}}] – MarcoB Feb 25 '19 at 19:12
• Graphics is not a graphics primitive, and won't convert something to graphics. It can't be used in Epilog. Use either Inset or Text (and set the coordinates too). – Szabolcs Feb 25 '19 at 19:40

You can use Epilog -> Inset[...]:

Graph[mygraph,  ImagePadding -> {{100, 10}, {40, 10}},
Epilog -> Inset[mytable, PropertyValue[{mygraph, 1}, VertexCoordinates], Right, Scaled[1]]]


Alternatively, you can label a specific vertex using Labeled or VertexLabels -> ...:

Graph[mygraph,  VertexLabels -> {_ :> "Name", 1 -> Placed[mytable, Before]}]


or

Graph[{Labeled[3, mytable, Before], 2, 3}, EdgeList@mygraph, VertexLabels -> "Name"]


• Thanks very much. (Accept) – David G. Stork Feb 26 '19 at 3:50