Web 结构可视化中的边缘标签

发布于 2024-12-09 14:34:11 字数 547 浏览 1 评论 0原文

我一直在研究 Mathematica 的可视化和网络爬虫功能。基于一些演示代码,我能够可视化网络。这是大学网页上的一个示例:

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

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

但是,我一直在尝试找出将 EdgeLabels[] 应用于此 Graph[] 命令的方法,但徒劳无功。我希望将每个链接写在每一行上,只是为了让大家了解链接簇到底代表什么。

我尝试将生成的超链接连接列表应用于它,但这不起作用,并且来自文档/堆栈/说明书上其他地方的任何显而易见的命令也不起作用。

我预计输出会非常混乱。

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}, 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

反目相谮 2024-12-16 14:34:11

我不知道在大图的情况下边缘标签会是什么样子。但这里是如何在 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}]

在此处输入图像描述
我希望这有帮助。

BR

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}]

enter image description here
I hope this helps.

BR

随风而去 2024-12-16 14:34:11

EdgeLabels放入Tooltips

下面将显示边和顶点的名称作为工具提示。 (当然,您可以删除VertexLabels。我将它们包括在内是因为EdgeLabels通常很长。)

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]

它对于浏览网络应该很有帮助。但当然,它不会打印标签。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文