Convert to Matrix Representations of Graphs
Convert to Matrix Representations of Graphs
g = Graph[{12, 13, 23, 24, 34}, ImageSize -> 100];
h = DirectedGraph[CompleteGraph[4, ImageSize -> 100], "Acyclic"];
k = PetersenGraph[3, 2, ImageSize -> 100];graphs = {g, h, k};mat = {AdjacencyMatrix, IncidenceMatrix, KirchhoffMatrix};
style = {Background -> {None, {Hue[.25, .15, .9], GrayLevel[.9], GrayLevel[.9], GrayLevel[.9]}}, FrameStyle -> Directive[Thick, White], Dividers -> All, Spacings -> {1, 2}};Style[Grid[Join[{{"Graph", "Adjacency Matrix", "Incidence Matrix", "Kirchhoff Matrix"}}, Thread[Prepend[Outer[MatrixForm[#1[#2], TableSpacing -> {.5, .5}, TableAlignments -> Right]&, mat, graphs], graphs]]], style], FontFamily -> "Verdana"]