ImageVerifierCode 换一换
格式:DOC , 页数:71 ,大小:425.50KB ,
资源ID:8885423      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/8885423.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(NetworkAnalysiswithigraph.doc)为本站上传会员【xrp****65】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

NetworkAnalysiswithigraph.doc

1、Network Analysis with igraph 友情提示: 这是在R语言环境下进行社会网络分析或者图论分析的工具,中间有些语句已经在新版本已经不能正常运行了,比如创建网络的语句 > g <- graph( c(0,1, 1,2, 3,4, 5,6) ) 在igraph的0.6-2版不能运行,可以改为 > g <- graph( c(1,2, 1,3, 3,4, 5,6) ) 也就是新版的顶点id是不能出现0的。 这个教程的作者是igraph包的创始人Gábor Csárdi,虽然他没有写完整,但是这个教程仍具有权威性,结合帮助文件可以助你快速掌握这个分析工具。

2、 Gábor Csárdi Department of Biophysics, Research Institute for Nuclear and Particle Physics of the Hungarian Academy of Sciences 29-33 Konkoly-Thege Miklós road, Budapest H-1121, Hungary Center for Complex Systems Studies, Kalamazoo College 1200 Academy st, Kalamazoo, 49006, MI, USA Copyright

3、C) 2006 Gábor Csárdi Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A

4、copy of the license is included in the section entitled “GNU Free Documentation License”. Table of Contents Introduction A short igraph Tour Installation The igraph data model Graphs Objects Regular Graphs Creating Graphs Random Graphs Importing and Exporting Graphs Graph Visualization

5、 Graph, Vertex and Edge Attributes Vertex and Edge Sequences Connected Components Analysis of Citation Networks Centrality Measures Path Lengths and Similar Measures Graph Motifs Network Flows and Related Concepts Graph Operators Licenses for igraph and this manual Bibliography Index

6、 Installation The igraph R package can be installed just like any other R packages. Perhaps the easiest way is to use the install.packages() command. This downloads either a source of binary package appropriate for the running system from CRAN and installs it by default to the system directori

7、es. The package can be loaded by typing library(igraph) after installation. If the user doesn't have rights to write to system directories the lib argument of the install.packages() command can be used to set an alternate installation directory. It is good R practice to keep the user's privatel

8、y installed packages in a separate directory (say ~/.R/library), if this is the case igraph can be installed like this: install.packages("igraph", lib="~/.R/library") The R package search path needs to be modified as well to let R know about our private package directory: .libPaths( c("~/.R/lib

9、rary", .libPaths()) ) This command can also be added to the ~/.Rprofile file to set the search path automatically every time you start R. See ?Startup and ?.libPaths() for more information about R's startup mechanism and the way directories are searched for packages and ?install.packages about in

10、stalling R packages. The igraph data model Directed graphs Undirected graphs Examples This section introduces the igraph data model. It is recommended that the reader should be familiar with this model of computation to understand the semantics of the igraph functions better. An

11、igraph graph is either directed or undirected, igraph cannot handle mixed graphs with both directed and undirected edges. Directed graphs The igraph data model is slightly different for directed and undirected graphs, we start with the directed case. In igraph vertices are identified by vertex id

12、s: integer number between zero and |V|-1, if |V| is the number of vertices in the graph. Thus the numbering of vertex ids is always continual, all igraph operations on graphs keep this important property. Directed igraph edges are ordered pairs or vertex ids. A directed graph is an ordered multise

13、t of directed edges and some additional meta data: the number of vertices in the graph and a boolean tag to mark the graph as directed. Here is an example of a directed igraph graph: ( vertices: 6, directed: yes, ( (0,2), (2,2), (2,3), (3,3), (3,4),

14、 (3,4), (4,1) ) ) Just like the vertices have vertex ids, igraph edges also have ids: edge ids are integer numbers between zero and |E|-1, |E| is the number of edges in the graph. Undirected graphs An undirected igraph edge is a two-element or one-element set of vertex ids. The two

15、 element set is a non-loop edge, ie. the edge connects different vertices, while loop edges are represented with a single-element set. An undirected graph is an ordered multiset of undirected edges, plus the usual meta data: the number of vertices and the fact that the graph is undirected. Here is a

16、n example for an undirected graph: ( vertices: 6, directed: no, ( {0,2}, {2}, {2,3}, {3}, {3,4}, {3,4}, {4,1} ) ) This graph contains both loop edges ({2} and {3}, ie. (2-2) and (3-3)) and multiple edges ({3,4} twice). Examples We g

17、ive some simple examples on how this data model is used in computations. The first example is the are.connected() function, this decides whether two vertices are connected by an edge. Lets assume that G1 and G2 are the graphs from the previous two sections, G1 is the directed, G2 the undirected grap

18、h. Now if we check with are.connected() whether vertices 0 and 2 are connectedin G1, the function searches for the (0,2) directed pair, and since it finds it it returns positive result. If the same search is performed on G2, the function searches for the {0,2} set and the result is, again, positive.

19、 Now it is perhaps obvious by now that if we suppply the vertices in the opposite order, ie. 2 and 0 then in G1 the (2,0) ordered pair is requested, so the answer is negative. For G2 {0,2}={2,0} is searched again, the answer is still positive. Another simple example is the neighbors() command, thi

20、s can be used to find the neighboring vertices of a vertex. neighbors() (like many other functions in igraph) has a parameter called mode. This parameter defines how the search is performed in directed graphs. Let us assume that we are interested in the neighbors of vertex 3. If mode is out then the

21、 graph's edge list (which is a multiset) is searched for elements having 3 in the first position of the ordered pair and returns the vertex ids in the second position in these elements. So the answer is (3,4,4). Now if mode is in then the role of the first and second positions is exchanged and (2,3)

22、 is returned. The third possible value of mode is all, in this case pairs having 3 at either at the first or second positions are searched and the other vertex id in the pair is returned: (2,3,4,4). Note that 3 is returned only once even if it is found both ways. This of course corresponds to the no

23、rmal graph theoretic conventions. The mode argument is always ignored when dealing with undirected graphs, as these graphs store an edge as an unordered pair (ie. a set). For example running neighbors() on graph G2 and vertex 3, the result is (2,3,4,4). Note that if we set mode to all on a direc

24、ted graph that essentially means that we use the corresponding undirected graph for calculation. Also note that the corresponding undirected graph always have the same number of edges as the directed counterpart, eg. if the directed graph contains (3,4) and (4,3) these edges make two {3,4} edges in

25、the undirected graph. Some igraph functions have a mode for other purposes: eg. graph.tree() and graph.star(). Graphs Objects igraph uses graph objects to represent graphs, a graph object is an opaque type in the sense that users are not expected to manipulate graph objects directly. In

26、stead igraph provides functions to create and manipulate graph objects. This organization has the advantage that the internal representation can be changed any time without breaking any code, assuming the users keep the rules. To facilitate the proper usage of igraph graph objects we do not present

27、the internal graph representation here. There are several functions which create graph objects, here is a very incomplete list of them: graph(), graph.star(), graph.tree(), graph.adjacency(), barabasi.game(). For example graph() creates a directed graph from a list of edges: > g <- graph( c(0,

28、1, 1,2, 3,4, 5,6) ) > g Vertices: 7 Edges: 4 Directed: TRUE Edges: [0] 0 -> 1 [1] 1 -> 2 [2] 3 -> 4 [3] 5 -> 6 Graph objects have an R class igraph and the is.igraph function can be used to check that an R object is an igraph graph object: > class( graph( 1:10 ) ) [1] "igraph" > i

29、s.igraph( graph( 1:10 ) ) [1] TRUE > is.igraph( 1:10 ) [1] FALSE Regular Graphs Empty graphs Full graphs Stars and Rings Lattices Trees The Graph Atlas Empty graphs igraph privides some ways for generating regular graph strucures: lattices, trees, etc. Let us begin with the

30、 simplest case: the empty graph: > g <- graph.empty() This command creates an empty graph and stores it in a variable named g. If you type in the name of a variable containing a graph object, R prints some information about the graph, and its edge list: > g Vertices: 0 Edges: 0 Directed: T

31、RUE This small example illustrates a number of things: empty graphs can be created by the graph.empty() command; by default this command creates a graph with no vertices and no edges (well this is what the word empty means); by default this command creates directed graphs. graph.empty() has an opti

32、onal parameter: n, the number of vertices in the graph. (A graph with non-zero number of vertices and no edges is still called and empty graph.) > g <- graph.empty(n=10) > g Vertices: 10 Edges: 0 Directed: TRUE This is a graph with ten vertices and zero edges. Full graphs A full graph is

33、completely the opposite of empty graphs: it contains (one copy of) all possible edges. A full graph can be created by the graph.full() command. By default it creates undirected graphs with no loop (ie. self) edges: > f <- graph.full(3) > f Vertices: 3 Edges: 3 Directed: FALSE Edges: [0]

34、 0 -- 1 [1] 0 -- 2 [2] 1 -- 2 The command has a directed parameter which can be set to TRUE to generated directed graphs: > f <- graph.full(3, directed=TRUE) > f Vertices: 3 Edges: 6 Directed: TRUE Edges: [0] 0 -> 1 [1] 0 -> 2 [2] 1 -> 0 [3] 1 -> 2 [4] 2 -> 0 [5] 2 -> 1 Note th

35、at igraph prints undirected edges with “--” and directed ones with “->”, stressing that the order of the vertex ids in the edges are important only in directed graphs. Here is an example of an undirected full graph: Some igraph functions provide information about the structure of a graph, is.d

36、irected() returns a logical constant, TRUE is the argument graph is directed and FALSE otherwise. are.connected() gives TRUE if the given vertices are connected with an edge and FALSE otherwise. It works slightly differently for directed and undirected graphs; for undirected graphs the order of the

37、vertex id parameters doesn't matter; for directed graph it searches for an edge from the first vertex to the second: > is.directed(graph.full(10)) [1] FALSE > is.directed(graph.full(10, directed=TRUE)) [1] TRUE > g <- graph.full(10) > are.connected(g, 1,4) [1] TRUE > g <- graph.empty(n=10)

38、 > are.connected(g, 1,4) [1] FALSE If a graph is very big, then it is probably not a good idea to list its edges to the screen. In this case the standard summary() function can be used to print some useful information about the graph: > big <- graph.full(1000) > summary(big) Vertices: 1000 E

39、dges: 499500 Directed: FALSE graph.full() also has a loops parameter to include loop edges in graph. graph.full() never creates graphs with multiple edges. Stars and Rings In a star graph, a single distinguished vertex is connected to every other vertices and there are no other edges present

40、 In igraph three types of star graphs can be created, the mode argument decides which one to generate: in creates a directed graph in which every edge points to the distinguished vertex, out creates a directed graph with opposite directedness and undirected creates an undirected star. The graph

41、ring() command can create various ring graphs (ie. one-dimensional lattices). The directed, mutual and circular parameters give the exact shape of the graph, see the figure for details. Lattices An n-dimensional lattice (sometimes also called grid) is a graph in which the vertices are placed a

42、t the integer coordinate points of the n-dimensional Euclidean space and each vertex connects to vertices which are exactly one unit away from it. Ie. if the lattice is two dimensional and the length of the lattice is 5 along the first and 3 along the second dimension, then it has 15 vertices and th

43、ey're placed at coordinates (1,1), (1,2), (1,3), (2,1), … (5,3) and two vertices are connected if the difference of one of their coordinates is one or minus one and all their other coordinates are exactly the same. In igraph lattices are generated with graph.lattice(). It has two different forms

44、 In the first form, the parameter length, the length of the lattice along every dimension and parameter dim, the dimensionality of the lattice are given. In the second form the parameter dimvector is given, this contains the length of the lattice along each dimensions separately. The default is the

45、 second form. The following two are equivalent, they create the same graphs: > l1 <- graph.lattice(length=5, dim=2) > l2 <- graph.lattice( c(5,5) ) The second form is obviously more general. graph.lattice() generates non-circular lattices by defaults. In a circular lattice the difference of th

46、e coordinates of the vertices is calculated modulo the size of the lattice along the given dimension so for example in the circular 5x3 two dimensional lattice vertices (1,1) and (1,3) are also connected just like (1,1) and (5,1). The circular parameter of graph.lattice() can be set to TRUE to gener

47、ate circular graphs. graph.lattice() generates undirected graphs by default, but the directed parameter can be set to TRUE to generate directed lattices. The direction of the edges is such that the edge points from the vertex with the smaller vertex id to the vertex with the larger vertex id. If t

48、he mutual parameter is also set to TRUE then two directed edges are created in both direction. Trees igraph has some limited capabilities for creating trees with the graph.tree() function. The only kind of trees this function can generate are almost complete regular trees. In a complete regular t

49、ree every vertex has the same number of children except for the leafs which have no children at all. An almost complete regular tree is made from a complete regular tree by removing some of the leafs from it. The directedness of the edges of tree is determined by the mode parameter. See the figure

50、 for the possible values of this parameter. The Graph Atlas igraph can generate graphs from the book An Atlas of Graphs by Roland C. Read and Robin J. Wilson. The atlas contains all undirected graphs with up to seven vertices, numbered from 0 up to 1252. The graphs are listed: 1. in increasing

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服