I've been trying to visualize a sitemap for analysis purposes. So far, using Leonid Shifrin's makeTreeRojo function, I've been able to build a somehow decent visualization.
First, I fetch and format the sites' structure (in a naive way, I guess):
kaSiteMap = Import["http://es.khanacademy.org/sitemap.xml"];
kaSiteMapLoc = Cases[kaSiteMap, XMLElement["loc", __], \[Infinity]];
kaSiteMapURLs =
StringReplace[#, "https://" -> ""] & /@
((Import /@ (Flatten@kaSiteMapLoc[[All, 3]])) //
Cases[#, XMLElement["loc", __], \[Infinity]][[All, 3]] & // Flatten);
kaSiteMapPreProcTree = Select[(StringSplit[#, "/"] & /@ kaSiteMapURLs) // Union, #[[1]] != "es.khanacademy.orgNone" &];
Next, I use a modified version of makeTreeRojo
ClearAll[makeTreeRojo];
Module[{makeTreeRojoAux},
makeTreeRojo[wrds_] :=
DeleteCases[StartOfString @@ makeTreeRojoAux[wrds], List, Infinity, Heads->True];
makeTreeRojoAux[{b___, {}, a___}] := Prepend[makeTreeRojoAux[{b, a}], Nothing];
makeTreeRojoAux[wrds_] :=
Reap[Scan[Sow[Rest[#], First@#] &, wrds], _, #1 @ makeTreeRojoAux[#2] &][[2]];
]
and then I apply it to kaSiteMapPreProcTree
kaSiteMapTree = (kaSiteMapPreProcTree // makeTreeRojo);
Finally, I create the tree using
Needs["GraphUtilities`"]
ExpressionTreePlot[kaSiteMapTree, Left, PlotRangePadding -> 0.001, LayerSizeFunction -> (# &), ImageSize -> Full, AspectRatio -> 120, VertexRenderingFunction -> (Text[StringReplace[ToString@#2, "[]" -> ""], #1] &)]
which is grate in its own right.
Besides the rather amateurish code, what I'd really like to do is to output a nice visualization where the structure of the site is well portrayed in a landscape A0 ($1189 \times 841 \text{ mm}^2$) size image (resolution should be as high as needed for the text to show up correctly).
I think my best bet is to convert the three into a graph and work from there, but I've had a really hard time doing this. I've tried and worked all sorts of codes available on the site and failed miserably. Also, I've zero knowledge on graph theory and it is the first time I try to do something like this.
Just to get the engines going, here is an image of my work taking Center
and AspectRatio -> 1
in the TreePlot directives:
Thanks for the time!