Web 结构可视化中的边缘标签
我一直在研究 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道在大图的情况下边缘标签会是什么样子。但这里是如何在 Mathematica 8 中完成的。
我希望这有帮助。
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.
I hope this helps.
BR
将
EdgeLabels
放入Tooltip
s下面将显示边和顶点的名称作为工具提示。 (当然,您可以删除
VertexLabels
。我将它们包括在内是因为EdgeLabels
通常很长。)它对于浏览网络应该很有帮助。但当然,它不会打印标签。
Place
EdgeLabels
insideTooltip
sThe 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 theEdgeLabels
were often very long.)It should be helpful for browsing the network. But of course, it will not print out the labels.