开发者

EdgeLabels in a Web Structure Visualization

开发者 https://www.devze.com 2023-04-12 18:18 出处:网络
I\'ve been playing around with Mathematica\'s visualization and webcrawling capabilities. Building on some demonstration code, I\'m able to visualize the a network. Here\'s an example on a university

I've been playing around with Mathematica's visualization and webcrawling capabilities. Building on some demonstration code, I'm able to visualize the a network. Here's an example on a university webpage:

webcrawler[rooturl_, depth_] :=
  Flatten[Rest[NestList[
       Union[Flatten[Thread[# -> Import[#,"Hyperlinks"]] & /@ Last /@ #]] &, 
       {"" -> rooturl开发者_JAVA百科}, depth]]];

Graph[webcrawler[
  "http://www.yorku.ca/", 2], {ImageSize -> Full}]

However, I've been trying fruitlessly to figure out a way to apply EdgeLabels[] to this Graph[] command. I would like to have each link written on each line, just to give a sense of what exactly the link clusters represent.

I've tried applying a generated list of the Hyperlink connections to it, which didn't work, and neither did any of the readily obvious commands from documentation/elsewhere on stack/the cookbook.

I envision a very cluttered output.


I don't know in case of a large graph how will the edge label look. But here how it can be done in Mathematica 8.

webcrawler[rooturl_, depth_] := 
Flatten[Rest[
NestList[
 Union[Flatten[
    Thread[# -> Import[#, "Hyperlinks"]] & /@ 
     Last /@ #]] &, {"" -> rooturl}, depth]]];
dats = webcrawler["http://www.uni-kl.de/", 2];
Graph[dats ,EdgeLabels ->Table[dats[[i]] -> dats[[i]][[2]],
{i,Length[dats]}], {ImageSize -> Full}]

EdgeLabels in a Web Structure Visualization

I hope this helps.

BR


Place EdgeLabels inside Tooltips

The following will display the names of both the edges and the vertices as tooltips. (You can remove the VertexLabels, of course. I included them because the EdgeLabels were often very long.)

data = webcrawler["http://www.yorku.ca/", 2];
Graph[data,
   EdgeLabels -> Placed["Name", Tooltip],
   EdgeShapeFunction -> "Line",
   VertexLabels -> Placed["Name", Tooltip], 
   EdgeStyle -> {Orange},
   VertexSize -> {"Scaled", 0.007},
   ImageSize -> 800]

It should be helpful for browsing the network. But of course, it will not print out the labels.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号