# Replacing graph nodes with matrices

I would like to label a graph with matrices. Suppose the graph is simple: And I have an array mats that contains the labels for vertices 1,2,3,4 (these are just random 0-1 matrices; ignore the entries): What is the appropriate syntax to employ VertexRenderingFunction to achieve having each vertex i replaced by (an image of) the MatrixForm of mats[[i]]? Or perhaps I am looking in the wrong direction entirely...?

It looks to me like you're using DirectedEdges, which are designed to work with Graph as opposed to GraphPlot. If you'd like to use GraphPlot and VertexRenderingFunction, you can do like so:

matrix = {
{0, 1, 0},
{0, 0, 1},
{0, 0, 1}
};
matrix = {
{1, 0, 0},
{1, 0, 1},
{1, 0, 0}
};
matrix = {
{1, 0, 1},
{0, 0, 0},
{0, 1, 1}
};
matrix = {
{1, 1, 0},
{0, 1, 1},
{0, 0, 0}
};
vertexRenderer[position_, v_] :=
{Text[Framed[matrix[v], Background -> RGBColor[1, 1, 0.8],
FrameStyle -> RGBColor[0.94, 0.85, 0.36]], position]};
GraphPlot[{1 -> 2, 1 -> 3, 3 -> 4},
DirectedEdges -> True,
VertexRenderingFunction -> vertexRenderer] You might seriously consider using the newer (and generally better) Graph based functionality and leverage the fact that virtually anything can be a vertex - including your matrices. Then, labeling the vertices is as simple as using VertexLabels.

Graph[{matrix -> matrix, matrix -> matrix, matrix -> matrix},
VertexLabels -> "Name", PlotRangePadding -> {{0.01, 0.2}, {0.01, 0.2}}] If desired, you can always use VertexShapeFunction to get more control over the appearance.

• Thank you so much! The second method is especially easy. – Joseph O'Rourke Aug 30 '14 at 11:40