# Adjacency Matrix of Sierprinski matrix

how can i make adjacency matrix of sierprinski graphs? • Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) 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](tinyurl.com/4srwe26 Jan 7 '20 at 5:38

ClearAll[meshF, edgesF, verticesF, coordsF, meshGraph]

meshF = DiscretizeGraphics @ Show[CantorMesh[#, 2],
RegionBoundary[RegionDifference[Rectangle[],
CantorMesh[#, 2]]] & /@ Range[#]] &;

verticesF = MeshCells[meshF[#], 0][[All, 1]] &;

edgesF = UndirectedEdge @@@ MeshCells[meshF[#], 1][[All, 1]] &;

coordsF = MeshCoordinates[meshF[#]] &;

meshGraph = Graph[verticesF@#, edgesF@#, VertexCoordinates -> coordsF[#], ##2] &;


Examples:

Row[meshGraph[#, ImageSize -> Small] & /@ Range[0, 2], Spacer] Row[meshGraph[#, ImageSize -> 1 -> (# + 1) 100,
VertexLabels -> Placed["Name", Center],
VertexSize -> (1 + #)/5] & /@ Range[0, 2], Spacer] Row[ArrayPlot[AdjacencyMatrix[meshGraph@#], Mesh -> All,
ImageSize -> 300] & /@ Range[0, 2], Spacer] Update: An alternative approach successively re-scaling a Rectangle using TransformedRegion and ScalingTransform:

ClearAll[subDivide]
subDivide = # /. c_Polygon :> {c,
TransformedRegion[c, ScalingTransform[{1, 1}/3, #]] & /@ First[c]} &;


Examples:

Graphics[{FaceForm[], EdgeForm[{Thin, Black}],
Nest[subDivide, Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}], 4]}] polygons = Cases[
Graphics[{FaceForm[], EdgeForm[{Thin, Black}],
Nest[subDivide, Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}], 5]}],
_Polygon, All];

Graphics[{RandomColor[], #} & /@ polygons,  ImageSize -> Large] • if graph is given, how can i find adjacency matrix? Jan 7 '20 at 7:12
• @MohitJames, you can use AdjacencyMatrix[g] if g is a Graph object.
– kglr
Jan 7 '20 at 7:14