Package ‘igraph’

March 2, 2013
Version 0.6.5-1 Date 2013-02-27 Title Network analysis and visualization Author See AUTHORS file. Maintainer Gabor Csardi <csardi.gabor@gmail.com> Description Routines for simple graphs and network analysis. igraph can handle large graphs very well and provides functions for generating random and regular graphs, graph visualization, centrality indices and much more. Depends stats Imports Matrix Suggests igraphdata, stats4, rgl, tcltk, graph, Matrix, ape, XML, jpeg, png License GPL (>= 2) URL http://igraph.sourceforge.net SystemRequirements gmp, libxml2

R topics documented:
igraph-package . . aging.prefatt.game alpha.centrality . . arpack . . . . . . . articulation.points . as.directed . . . . . as.igraph . . . . . . assortativity . . . . attributes . . . . . autocurve.edges . . barabasi.game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 7 10 11 15 16 18 19 21 23 24

2 betweenness . . . . . . . . . . . . . . . . . . . . biconnected.components . . . . . . . . . . . . . bipartite.mapping . . . . . . . . . . . . . . . . . bipartite.projection . . . . . . . . . . . . . . . . bonpow . . . . . . . . . . . . . . . . . . . . . . canonical.permutation . . . . . . . . . . . . . . . centralization . . . . . . . . . . . . . . . . . . . cliques . . . . . . . . . . . . . . . . . . . . . . . closeness . . . . . . . . . . . . . . . . . . . . . clusters . . . . . . . . . . . . . . . . . . . . . . cocitation . . . . . . . . . . . . . . . . . . . . . cohesive.blocks . . . . . . . . . . . . . . . . . . Combining attributes . . . . . . . . . . . . . . . communities . . . . . . . . . . . . . . . . . . . . community.to.membership . . . . . . . . . . . . compare.communities . . . . . . . . . . . . . . . components . . . . . . . . . . . . . . . . . . . . constraint . . . . . . . . . . . . . . . . . . . . . contract.vertices . . . . . . . . . . . . . . . . . . conversion . . . . . . . . . . . . . . . . . . . . . conversion between igraph and graphNEL graphs convex.hull . . . . . . . . . . . . . . . . . . . . decompose.graph . . . . . . . . . . . . . . . . . degree . . . . . . . . . . . . . . . . . . . . . . . degree.sequence.game . . . . . . . . . . . . . . dendPlot . . . . . . . . . . . . . . . . . . . . . . dendPlot.communities . . . . . . . . . . . . . . dendPlot.igraphHRG . . . . . . . . . . . . . . . diameter . . . . . . . . . . . . . . . . . . . . . . dominator.tree . . . . . . . . . . . . . . . . . . . Drawing graphs . . . . . . . . . . . . . . . . . . dyad.census . . . . . . . . . . . . . . . . . . . . eccentricity . . . . . . . . . . . . . . . . . . . . edge.betweenness.community . . . . . . . . . . edge.connectivity . . . . . . . . . . . . . . . . . erdos.renyi.game . . . . . . . . . . . . . . . . . evcent . . . . . . . . . . . . . . . . . . . . . . . fastgreedy.community . . . . . . . . . . . . . . . forest.fire.game . . . . . . . . . . . . . . . . . . get.adjlist . . . . . . . . . . . . . . . . . . . . . get.edge.ids . . . . . . . . . . . . . . . . . . . . get.incidence . . . . . . . . . . . . . . . . . . . get.stochastic . . . . . . . . . . . . . . . . . . . girth . . . . . . . . . . . . . . . . . . . . . . . . graph-isomorphism . . . . . . . . . . . . . . . . graph-motifs . . . . . . . . . . . . . . . . . . . . graph-operators . . . . . . . . . . . . . . . . . . graph-operators-by-name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

R topics documented: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 28 29 31 32 34 36 39 40 42 43 44 48 51 55 56 57 58 59 60 62 63 64 65 66 67 68 70 72 73 74 80 81 82 84 86 87 89 90 92 93 94 95 96 97 101 103 104

R topics documented: graph.adjacency . . . . . . . graph.automorphisms . . . . graph.bfs . . . . . . . . . . graph.bipartite . . . . . . . . graph.constructors . . . . . . graph.coreness . . . . . . . graph.data.frame . . . . . . graph.de.bruijn . . . . . . . graph.density . . . . . . . . graph.dfs . . . . . . . . . . graph.diversity . . . . . . . graph.famous . . . . . . . . graph.formula . . . . . . . . graph.full.bipartite . . . . . graph.graphdb . . . . . . . . graph.incidence . . . . . . . graph.kautz . . . . . . . . . graph.knn . . . . . . . . . . graph.laplacian . . . . . . . graph.lcf . . . . . . . . . . . graph.matching . . . . . . . graph.maxflow . . . . . . . graph.strength . . . . . . . . graph.structure . . . . . . . Graphs from adjacency lists . grg.game . . . . . . . . . . growing.random.game . . . Hierarchical random graphs . igraph console . . . . . . . . igraph options . . . . . . . . igraph.sample . . . . . . . . igraph.undocumented . . . . igraphdemo . . . . . . . . . independent.vertex.sets . . . infomap.community . . . . . interconnected.islands . . . . is.chordal . . . . . . . . . . is.dag . . . . . . . . . . . . is.degree.sequence . . . . . is.igraph . . . . . . . . . . . is.multiple . . . . . . . . . . is.mutual . . . . . . . . . . . is.named . . . . . . . . . . . is.separator . . . . . . . . . is.weighted . . . . . . . . . iterators . . . . . . . . . . . k.regular.game . . . . . . . . kleinberg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3 106 109 110 112 114 116 117 119 120 121 123 125 127 129 130 132 133 134 136 137 138 140 142 143 150 151 152 153 157 158 160 161 162 163 164 166 167 168 169 170 171 172 173 174 176 177 180 181

4 label.propagation.community . layout . . . . . . . . . . . . . layout.drl . . . . . . . . . . . layout.grid . . . . . . . . . . . layout.mds . . . . . . . . . . . layout.merge . . . . . . . . . layout.star . . . . . . . . . . . layout.sugiyama . . . . . . . . leading.eigenvector.community line.graph . . . . . . . . . . . maximum.cardinality.search . minimal.st.separators . . . . . minimum.size.separators . . . minimum.spanning.tree . . . . modularity . . . . . . . . . . . multilevel.community . . . . . neighborhood . . . . . . . . . nexus . . . . . . . . . . . . . optimal.community . . . . . . page.rank . . . . . . . . . . . permute.vertices . . . . . . . . Pie charts as vertices . . . . . plot.igraph . . . . . . . . . . . power.law.fit . . . . . . . . . . preference.game . . . . . . . . print.igraph . . . . . . . . . . read.graph . . . . . . . . . . . reciprocity . . . . . . . . . . . revolver . . . . . . . . . . . . rewire . . . . . . . . . . . . . rewire.edges . . . . . . . . . . rglplot . . . . . . . . . . . . . running.mean . . . . . . . . . scg . . . . . . . . . . . . . . . scgExtra . . . . . . . . . . . . scgGrouping . . . . . . . . . . scgSemiProjectors . . . . . . . shortest.paths . . . . . . . . . similarity . . . . . . . . . . . simplify . . . . . . . . . . . . Spectral coarse graining . . . . spinglass.community . . . . . static.fitness.game . . . . . . . static.power.law.game . . . . . stCuts . . . . . . . . . . . . . stMincuts . . . . . . . . . . . structure.info . . . . . . . . . subgraph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

R topics documented: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 184 189 192 193 194 195 196 200 202 203 204 205 207 208 209 210 212 215 217 219 220 221 223 225 226 228 233 234 238 239 240 241 241 245 247 249 251 254 255 256 258 261 262 264 265 267 268

igraph-package subgraph.centrality . tkigraph . . . . . . . tkplot . . . . . . . . topological.sort . . . traits . . . . . . . . . transitivity . . . . . . triad.census . . . . . unfold.tree . . . . . . Vertex shapes . . . . vertex.connectivity . walktrap.community watts.strogatz.game . write.graph . . . . . Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5 269 271 271 273 274 275 278 279 280 284 286 287 288 292

igraph-package

The igraph package

Description igraph is a library and R package for network analysis. Introduction The main goals of the igraph library is to provide a set of data types and functions for 1) pain-free implementation of graph algorithms, 2) fast handling of large graphs, with millions of vertices and edges, 3) allowing rapid prototyping via high level languages like R. Igraph graphs Igraph graphs have a class ‘igraph’. They are printed to the screen in a special format, here is an example, a ring graph created using graph.ring: IGRAPH U--- 1 1 -- Ring graph + attr: name (g/c), mutual (g/x), circular (g/x) The ‘IGRAPH’ denotes that this is an igraph graph. Then come four bits that denote the kind of the graph: the first is ‘U’ for undirected and ‘D’ for directed graphs. The second is ‘N’ for named graph (i.e. if the graph has the ‘name’ vertex attribute set). The third is ‘W’ for weighted graphs (i.e. if the ‘weight’ edge attribute is set). The fourth is ‘B’ for bipartite graphs (i.e. if the ‘type’ vertex attribute is set). Then comes two numbers, the number of vertices and the number of edges in the graph, and after a double dash, the name of the graph (the ‘name’ graph attribute) is printed if present. The second line is optional and it contains all the attributes of the graph. This graph has a ‘name’ graph attribute, of type character, and two other graph attributes called ‘mutual’ and ‘circular’, of a complex type. A complex type is simply anything that is not numeric or character. See the documentation of print.igraph for details.

The solution is to assign attributes to the vertices.frame and graph. It uses R’s formula interface.famous can create some special graphs. The igraph package includes some classic random graphs like the Erdos-Renyi GNP and GNM graphs (erdos.edgelist.7 7-.game). To create graphs from field data.4 4-. in the delete. The same is true for the edges as well. igraph provides flexible constructs for selecting a set of vertices or edges based on their attribute values. it is of course enough to type str instead of str.g.9 9--1 1--1 Creating graphs There are many functions in igraph for creating graphs.e.g. If some operation changes the number of vertices in the graphs.1 1 -. degree has a v argument that gives the vertices for which the degree is calculated. Just like for vertices.formula function is easiest.vertex. circular (g/x) + edges: [1] 1-. graph. One of them is the ‘name’ attribute. if possible. See more about attributes in the next section. graph. Vertex ids are always consecutive and they start with one. This argument can be given as a character vector of vertex names. e. I.6 igraph-package If you want to see the edges of the graph as well. e.edges and other functions. graph. .renyi.igraph function. the total number of edges in the graph.game) and the small-world model (watts.5 5-. Edges can also have a ‘name’ attribute. a subgraph is created via induced. and vertex ids don’t allow this because of the renumbering.2 2-. then use the str.6 6-. Attributes In igraph it is possible to assign attributes to the vertices or edges of a graph. both deterministic and stochastic.adjacency are probably the best choices.subgraph. then the vertices are renumbered to satisfty this criteria. Some vertex/edge/graph attributes are treated specially.8 8-. and this is treated specially as well. It is often desirable to follow vertices along a number of graph operations. Another option is graph. for a graph with n vertices the vertex ids are between 1 and n.game) and some recent popular models. its manual page contains many examples. like preferential attachment (barabasi. To create small graphs with a given structure probably the graph. or to the graph itself. Vertex and edge IDs Vertices and edges have numerical vertex ids in igraph. if it exists. This is used for printing the graph instead of the numerical ids.atlas creates graph from the Graph Atlas.strogatz. in all igraph functions. graph.g.Ring graph + attr: name (g/c).3 3-.data. edges can also be selected based on their names. edge ids are always between one and m. see get. mutual (g/x). which takes numeric vertex ids directly. E. These are kept by all operations. stochastic graph constructors are called ‘games’.igraph: > str(g) IGRAPH U--.attribute and iterators for details. Vertex names can also be used to specify a vector or set of vertices.

Each time a new vertex is added it creates a number of links to old vertices and the probability that an old vertex is cited depends on its in-degree (preferential attachment) and age.) The third way requires the rgl package and uses OpenGL. Make sure you read igraph.com> aging.plotting for details. plot is enough.plotting before you start plotting your graphs.graph for details. which uses a Tk GUI for basic interactive graph manipulation. See the rglplot function for the details.net. Other attributes define visualization parameters. The two forms can also be mixed in the same edge selector. (Tk is quite resource hungry.sourceforge. but note that storing the graph in some file formats might result the loss of complex attribute values. Attribute values can be set to any R object. see igraph.aging. possibly directed.graph and write.game 7 We note here. See read. edge going from ‘from’ to ‘to’.igraph function. All attribute values are preserved if you use save and load to store/retrieve your graphs. usually both for reading and writing. so don’t try this for very large graphs. Visualization igraph provides three different ways for visualization. The second function is tkplot. select a single. Join the igraph-help mailing list if you have questions or comments. We suggest that you use the GraphML file format for your graphs. Author(s) Gabor Csardi <csardi.prefatt. except if the graphs are too big.prefatt. The first is the plot. (Actually you don’t need to write plot.game Generate an evolving random graph with preferential attachment and aging Description This function creates a random graph by simulating its evolution. This function uses regular R graphics and can be used with any R device. where ‘from’ and ‘to’ are vertex names. . See especially the documentation section. For big graphs a simpler format is recommended.igraph.gabor@gmail. that vertex names can also be used to select edges. The form ‘from|to’. Further information The igraph homepage is at http://igraph. File formats igraph can handle various graph file formats.

game aging. The exponent of the aging. zero.coef = 1. Then in each time step (starting with the second) a new vertex is added and it initiates a number of edges to the old vertices in the network. The number of bins to use for measuring the age of vertices. See also details below.coef age. see the details below. See also details below.8 Usage aging.deg. see details below. deg.coef = 1. See details below. Logical constant. whether to include edges not initiated by the vertex as a basis of preferential attachment. zero. with the extension that vertex age is divided to be in aging.age.exp. directed = TRUE. directed Logical constant.appeal The degree-dependent part of the ‘attractiveness’ of the vertices with no adjacent edges. aging.dist = NULL.prefatt.age. The coefficient of the age-dependent part of the ‘attractiveness’. We start with a network containing a single vertex (and no edges) in the first time step.seq arguments are NULL. whether to generate a directed graph. It is usually zero.exp aging.game (n. See details below.deg.seq out.pref = FALSE. aging. if NULL only adjacent added in the last time. out. .appeal = . The number of edges to add in each time step. See details below. The probability that an old vertex is connected to is proportional to β α P [i] ∼ (c · ki + a)(d · li + b)· Here ki is the in-degree of vertex i in the current time step and li is the age of vertex i. The preferantial attachment exponent. See details below. See details below.appeal = 1.prefatt. out. time.window The coefficient of the degree-dependent ‘attractiveness’.window = NULL) Arguments n pa.seq is NULL.dist out. See details below. out.coef time.seq = NULL. pa.bin out.exp m aging. usually a non-positive number.dist and out. zero. This argument is used only if both the out.pref The number of vertices in the graph.windows time steps are counted as a basis of the preferential attachment. deg. m = NULL. see details below.bin bins.bin = 3 . The discrete distribution to generate the number of edges to add in each time step if out. Details This is a discrete time step model of a growing graph.appeal The age-dependent part of the ‘attrativeness’ of the vertices with age zero. a vector containing as many elements as the number of vertices. The age is simply defined as the number of time steps passed since the vertex is added. Integer constant. see details below. age. zero.exp. The number of edges each new vertex creates (except the very first vertex).

erdos. zero.exp (β . (out.coef (d.window time steps. aging. The number of edges initiated in each time step is governed by the m.window argument is given (and not NULL) then ki means only the adjacent edges added in the previous time. aging.aging.renyi.appeal (a.com> See Also barabasi. aging.aging.seq should contain non-negative numbers.game(1 . Its first element gives the probability that zero edges are added at a time step.gabor@gmail.exp=-1.game Examples # The maximum degree for graph with different aging exponents g1 <. Even if an undirected graph is generaed ki denotes only the adjacent edges not initiated by the vertex itself except if out. optional.game. If the time.dist is given then it will be used as a discrete probability distribution to generate the number of edges.bin=1 ) g2 <. out. If out.bin=1 ) max(degree(g1)) max(degree(g2)) max(degree(g3)) . This behavior is similar to the prob argument of the sample command. but if they don’t sum up to 1. Author(s) Gabor Csardi <csardi.pref is set to TRUE. mandatory argument). and age.coef (c. and its first element will be ignored. they will be normalized to sum up to 1. the default is 1). optional. Value A new graph. aging. the default is 0). optional.deg. pa. If out. aging. It should be of length n (the number of vertices). etc.game 9 c.pref parameters.exp=-3. the default is 1).aging. deg. α.seq is not given (or NULL) and out. the default value is 1). the second element is the probability that one edge is added.aging. a.age.exp= . pa. d.game(1 . pa. zero.prefatt.prefatt.bin=1 ) g3 <.prefatt.exp (α.exp=1. aging.seq and out. mandatory argument).prefatt. but it directed is set to FALSE then an undirected is created.) By default a directed graph is generated.exp=1. This function might generate graphs with multiple edges. β and b are parameters and they can be set via the following arguments: pa. optional.appeal (b. aging.game(1 .seq is given then it is interpreted as a vector giving the number of edges to be added in each time step.exp=1.

See details below.centrality calculates the alpha centrality of some (or all) vertices in a graph. whether to use sparse matrices for the calculation. then the ‘weight’ edge attribute of the graph is used. (For technical reasons they will be calculated for all vertices. can be directed or undirected Vertex sequence. loops=FALSE. the vertices for which the alpha centrality values are returned. anyway. Note that too long vectors will be truncated and too short vectors will be replicated to match the number of vertices.centrality alpha. e is the vector of exogenous sources of status of the vertices and α is the relative importance of the endogenous versus exogenous factors.) Parameter specifying the relative importance of endogenous versus exogenous factors in the determination of centrality. then the calculation uses the standard adjacency matrix. tol=1e-7. Usage alpha. sparse=TRUE) Arguments graph nodes alpha loops exo The input graph. Logical scalar. alpha=1.centrality Find Bonacich alpha centrality scores of network positions Description alpha. Whether to eliminate loop edges from the graph before the calculation. The alpha centrality of the vertices in a graph is defined as the solution of the following matrix equation: x = αAT x + e.10 alpha. or if it is NA. in most cases this is either a constant – the same factor for every node. if there is one.centrality(graph. The exogenous factors. . see solve. weights=NULL. Tolerance for near-singularities during matrix inversion. exo=1. A character scalar that gives the name of the edge attribute to use in the adjacency matrix. or a vector giving the factor for every vertex. where A is the (not neccessarily symmetric) adjacency matrix of the graph. The ‘Matrix’ package is required for sparse matrix support weights tol sparse Details The alpha centrality measure can be considered as a generalization of eigenvector centerality to directed graphs. nodes=V(graph). It was proposed by Bonacich in 2001 (see reference below). Otherwise. If it is NULL.

the routine may fail is certain cases.arpack. (2001).2.arpack Value A numeric vector contaning the centrality scores for the selected vertices.1 <.1.1) alpha.unpack.4. sym = FALSE.5) ) g.complex(vectors. extra = NULL.5.3. options = igraph.1) ) g. Author(s) Gabor Csardi <csardi.1.3.2) alpha. See Also evcent and bonpow Examples # The examples from Bonacich’s paper g. complex=!sym) arpack.4.4.1) ) alpha. P.graph( c(1.centrality(g.5. and Paulette.frame().centrality(g.1.1.3 <.graph( c(1.2.com> References Bonacich.gabor@gmail. Warning 11 Singular adjacency matrices cause problems for this algorithm. env = parent.default. “Eigenvector-like measures of centrality for asymmetric relations” Social Networks.4. 23.2. nev) . 191-201.2 <.3.3.graph( c(2.centrality(g.4.alpha= . L.5) arpack ARPACK eigenvector calculation Description Interface to the ARPACK library for calculating eigenvectors of sparse matrices Usage arpack(func.3. values.3.3.

See details below.) The second argument is extra. where A is the “input matrix”. The function gets the vector x as the first argument. extra sym options env complex vectors values nev Details ARPACK is a library for solving large scale eigenvalue problems.caam. stadard eigenvalue problem. (The input matrix is never given explicitly.) which Specify which eigenvalues/vectors to compute.complex. Eigenvectors. Currently only ‘I’ is supported. It is a list with the following members. The environment in which func will be evaluated.12 Arguments func arpack The function to perform the matrix-vector multiplication. character constant with exactly two characters. since it can speed up the computation. whether the input matrix is symmetric. Possible values for symmetric input matrices: .rice. possible values: ‘I’. ARPACK requires to perform these by the user. It is most appropriate for large sparse or structured matrices A where structured means that a matrix-vector product w <. The options argument specifies what kind of calculation to perform. etc. Extra argument to supply to func.Av requires order n rather than the usual order n2 floating point operations.edu/software/ARPACK/ for details. Options to ARPACK. then supply FALSE here.e. The package is designed to compute a few eigenvalues and corresponding eigenvectors of a general n by n matrix A. not needed for evcent. The dimension of the eigenproblem. and ‘G’. Please see http://www. igraph does not contain all ARPACK routines.rank. if the matrix is sparse. Whether to convert the eigenvectors returned by ARPACK into R complex vectors. generalized eigenvalue problem. as returned by ARPACK The number of eigenvectors/values to extract. but only non-symmetric ones. (I. then arpack is usually able to calculate the eigenvalues very quickly. they correspond directly to ARPACK parameters. Ax = λx.unpack. Ax = λBx. e. Logical scalar. The function supplied in the fun argument is expected to perform this product. This can be less than or equal to the number of eigenvalues requested in the original ARPACK call. page. but you’re sure that the results will be real. and it should return Ax. By default this is not done for symmetric problems (these only have real eigenvectors/values). The conversion is done by calling arpack. If the product can be done efficiently. a named list to overwrite some of the default option values. This function is an interface to ARPACK. If you have a nonsymmetric problem. as returned by ARPACK. The eigenvalue calculation in ARPACK (in the simplest case) involves the calculation of the Av product where A is the matrix we work with and v is an arbitrary vector. n Numeric scalar. You only need to set this if you call arpack directly. Always supply TRUE here if it is. Eigenvalues. only the ones dealing with symmetric and non-symmetric eigenvalue problems using double precision real numbers.g. On input it has the following fields: bmat Character constant.

e. ncv Number of Lanczos vectors to be generated. A is symmetric. Ax = λM x. nev Numeric scalar. It should be set to zero in the current implementation. Compute nev eigenvalues of smallest magnitude. mode The type of the eigenproblem to be solved. Compute nev largest (in magnitude) eigenvalues. Compute nev eigenvalues of largest real part. M is symmetric semi-definite. Compute nev eigenvalues of largest imaginary part. If this is set to zero then machine precision is used.g. nb Blocksize to be used in the recurrence. Kx = λM x. Possible values if the input matrix is symmetric: 1 2 3 4 5 Ax = λx. maxiter Maximum number of Arnoldi update iterations allowed. Compute nev eigenvalues of smallest real part. Ax = λM x. Compute nev eigenvalues of largest magnitude. If one then exact shifts with respect to the reduced tridiagonal matrix T . If zero then the shifts are provided by the user via reverse communication. Compute nev smallest (algebraic) eigenvalues. A is symmetric. (Cayley transformed mode. half from each end of the spectrum. M is symmetric positive semi-definite. M is symmetric positive semi-definite. Please always leave this on the default value. Please note that only mode==1 was tested and other values might not work properly. Compute nev eigenvalues of smallest imaginary part. M is symmetric positive definite. M is symmetric positive definite. The number of eigenvalues to be computed. ishift Either zero or one. Ax = λM x. page. tol Numeric scalar. K is symmetric positive semi-definite.) Please note that only mode==1 was tested and other values might not work properly. start Not used currently. KG is symmetric indefinite. Compute nev eigenvalues.arpack ‘LA’ ‘SA’ ‘LM’ ‘SM’ ‘BE’ 13 Compute nev largest (algebraic) eigenvalues. . K is symmetric. Ax = λM x. Compute nev smallest (in magnitude) eigenvalues.rank always sets ‘LM’. Later it be used to set a starting vector. Ax = λM x. A is symmetric. compute one more from the high end than from the low end. Stopping criterion: the relative accuracy of the Ritz value is considered acceptable if its error is less than tol times its estimated value. Kx = λKGx. M is symmetric semi-definite. Please always set this to one. Possible values if the input matrix is not symmetric: 1 2 3 4 Ax = λx. When nev is odd. one. Possible values for non-symmetric input matrices: ‘LM’ ‘SM’ ‘LR’ ‘SR’ ‘LI’ ‘SI’ This parameter is sometimes overwritten by the various functions. ldv Numberic scalar.

pp 357-385. Possible values: 0 Normal exit.N. pp 575-595.unpack. R.. On output the following additional fields are added: arpack info Error flag of ARPACK. 13 (1992). If complex=TRUE (the default for non-symmetric problems). Author(s) Rich Lehoucq. 3 No shifts could be applied during a cycle of the Implicitly restarted Arnoldi iteration. the desired eigenvectors as columns.14 sigma Not used currently. vol 88/89. Numeric matrix. References D. SIAM J. One possibility is to increase the size of ncv relative to nev. arpack.complex is a (semi-)internal function that converts the output of the non-symmetric ARPACK solver to a more readable format.C. Complex Shift and Invert Strategies for Real Matrices. (1987). Danny Sorensen. Kristi Maschhoff. sigmai Not use currently. Gabor Csardi <csardi. A named list with the supplied options and some information about the performed calculation.gabor@gmail. including an ARPACK exit code. numreo Total number of steps of re-orthogonalization.B. Sorensen. Chao Yang for ARPACK. It is called internally by arpack. numopb Not used currently. Rice University Technical Report TR95-13. numop Total number of matrix-vector multiplications. Saad. Implicit Application of Polynomial Filters in a k-Step Arnoldi Method.com> for the R interface. iter Number of Arnoldi iterations taken. nconv Number of “converged” Ritz values. Linear Algebra and its Applications. then the matrix is complex. This represents the number of Ritz values that satisfy the convergence critetion. Parlett & Y. B. Apps. Analysis and Implementation of an Implicitly Restarted Arnoldi Iteration. ARPACK can return more error conditions than these. See the details above. Matr. . Value A named list with the following members: values vectors options Numeric vector. Department of Computational and Applied Mathematics. Lehoucq. but they are converted to regular igraph errors. 1 Maximum number of iterations taken. Anal. the desired eigenvalues. Please see the ARPACK documentation for additional details.

options=list(n=1 . page.arpack(f2. sym=TRUE. The ARPACK homepage is at http://www. leading. maxiter=2 )) } articulation. mode="undirected"))) ## First three eigenvalues of the adjacency matrix of a graph ## We need the ’Matrix’ package for this if (require(Matrix)) { g <. as.game(1 .rice.community are some of the functions in igraph which use ARPACK.eigenvector. Examples # Identity matrix f <.erdos. sparse=TRUE) f2 <. 5/1 ) M <. extra=NULL) { cat(".adjacency(g. Usage articulation.caam. hub.points Articulation points of a graph Description Articuation points or cut vertices are vertices whose removal increases the number of connected components in a graph.(length(x)-1)*x[1] .score.articulation.laplacian(graph.points See Also 15 evcent.function(x. extra=NULL) x arpack(f. ncv=4).sum(x[-1]) for (i in 2:length(x)) { y[i] <.").x[i] . sym=TRUE) # double check eigen(graph.x y[1] <.points(graph) .vector(M %*% x) } baev <.rank. n>=2 # Note that this is a linear operation f <. ncv=8. nev=3.function(x. options=list(n=vcount(g).get. options=list(n=1 . nev=2. ncv=3).star(1 . which="LM".renyi.function(x. sym=TRUE) # Graph laplacian of a star graph (undirected).x[1] } y } arpack(f. extra=NULL) { y <. nev=1.edu/software/ ARPACK/.

If a graph contains no articulation points. clu). edge. then the removal of a single articulation point makes it undirected. mode = c("collapse". Value A numeric vector giving the vertex ids of the articulation points of the input graph. If the original graph was connected.directed(graph.points(g) as. vertex.gabor@gmail. "each". then its vertex connectivity is at least two.attr. even if it is directed.directed converts an undirected graph to directed. It is treated as an undirected graph. "mutual"). match(2. is.undirected(graph.full(5). Articuation points or cut vertices are vertices whose removal increases the number of connected components in a graph. as.add.connected.16 Arguments graph Details as.directed Convert between directed and undirected graphs Description as.components.edges(g.comb = getIgraphOpt("edge. Author(s) Gabor Csardi <csardi.graph. c(match(1. clusters.full(5) ) clu <.union( graph.attr.directed The input graph. "arbitrary")) as.connectivity Examples g <.com> See Also biconnected. it converts a directed graph to undirected.clusters(g)$membership g <. Usage as.disjoint.comb")) . mode = c("mutual". clu)) ) articulation. graph.undirected does the opposite.

Conversion algorithms for as. Non-mutual edges are ignored. mutual Two directed edges are created for each undirected edge.directed: arbitrary The number of edges in the graph stays the same. an arbitrarily directed edge is created for each undirected edge. defines the conversion algorithm.undirected(g) # Combining edge attributes g3 <.directed Arguments graph mode The graph to convert.undirected: each The number of edges remains constant. Value A new graph object.star(1 ) as. mutual One undirected edge will be created for each pair of mutual edges.com> See Also simplify for removing multiple and/or loop edges from a graph. In these cases many edges might be mapped to a single one in the new graph. Author(s) Gabor Csardi <csardi. no multiple edges will be created. Please see attribute. For as. This mode might create multiple edges if there are more than one mutual edge pairs between the same pair of vertices. mutual=TRUE) . this version might create graphs with multiple edges.undirected it can be each.directed(g.attr.graph. collapse One undirected edge will be created for each pair of vertices which are connected with at least one directed edge. Details Conversion algorithms for as.combination for details on this.directed it can be mutual or arbitrary.gabor@gmail. and their attributes are combined.ring(1 ) as. collapse or mutual. "mutual") g2 <. See details below. Examples g <.graph. one in each direction.ring(1 . For as. if mode="collapse" or mode="mutual". an undirected edge is created for each directed one. directed=TRUE.comb Specifies what to do with edge attributes.as. edge.graph. 17 Character constant.

circle.undirected(g4. None currently.6. 9.5.4. layout=layout. 5. Author(s) Gabor Csardi <csardi.9.18 E(g3)$weight <. 8.as. layout=layout.label=E(ug3)$weight) ## End(Not run) g4 <.1 . edge. 6.9. e=TRUE) ## Not run: x11(width=1 .4. 7. 3.. edge. edge.circle.comb=list(weight=length)) print(ug4.4. Right now the following objects are supported: • codeigraphHRG These objects are created by the hrg.as.seq_len(ecount(g4)) ug4 <.1 )) E(g4)$weight <.9. 1 ..2.1 .seq_len(ecount(g3)) ug3 <.. .8.fit and hrg.igraph as. The object to convert.gabor@gmail.7.2.8.attr.undirected(g3) print(ug3. Additional arguments.igraph Conversion to igraph Description These fucntions convert various objects to igraph graphs.9.8. Usage ## S3 method for class ’igraphHRG’ as.3.8. height=5) layout(rbind(1:2)) plot( g3..label=E(g3)$weight) plot(ug3.7.com>.8. Value All these functions return an igraph graph. Details You can use as.igraph to convert various objects to igraph graphs. e=TRUE) as.) Arguments x . mode="mutual". .7.igraph(x.8.consensus functions.7.4.9.3.graph(c(1.

M. ai = eij and bj = i eij .e.fit(g) as. Vector giving the vertex types. types1. . types. A second value vector to be using for the incoming edges when calculating assortativity for a directed graph.degree (graph. This argument is ignored for undirected graphs. starting with one. Newman defined two kinds of assortativity coefficients.nominal (graph.E.hrg.full(5) hrg <.full(5) + graph. Supply TRUE here to do the natural thing. If the coefficient is high.J. whether to consider edge directions for directed graphs.igraph(hrg) 19 assortativity Assortativity coefficient Description The assortativity coefficient is positive is similar vertices (based on some external property) tend to connect to each. and negative otherwise. these can be arbitrary numeric values. Usage assortativity (graph. It is defines as r= i eii − 1− ai bi i ai bi i j where eij is the fraction of edges connecting vertices of type i and j . directed = TRUE) Arguments graph types types1 types2 The input graph.integer. They as assumed to be integer numbers. The vertex values. it can be directed or undirected. based on some vertex labeling or values assigned to vertices. This argument is ignored (with a warning) if it is not NULL and undirected assortativity coefficient is being calculated. Supply NULL here if you want to use the same values for outgoing and incoming edges.assortativity Examples g <.graph. the first one is for categorical labels of vertices.nominal calculates this measure. assortativity. directed = TRUE) assortativity. use directed version of the measure for directed graphs and the undirected version for undirected graphs. Non-integer values are converted to integers with as. that means that connected vertices tend to have the same labels or similar assigned values. types2 = NULL. i. directed Details The assortativity coefficient measures the level of homophyly of the graph. directed = TRUE) assortativity. Logical scalar.

Phys. E. 026126 (2003) http://arxiv. respectively. 89. sigmao and sigmai are the The reason of the difference is that in directed networks the relationship is not symmetric. J. close to zero assortativity.degree(ba.gabor@gmail. so it is possible to assign different values to the outgoing and the incoming end of the edges. Lett. Phys. qi = o i standard deviations of q . J.degree(erdos. It is defined as r= 1 2 σq jk (ejk − qj qk ) jk for undirected graphs (qi = j eij ) and as 1 σo σi r= o i jk (ejk − qj qk ) jk o i for directed ones. σq . 208701 (2002) http: //arxiv. m=4)) . moreover.20 assortativity The second assortativity variant is based on values assigned to the vertices. Here qi = j eij .game(1 # BA model. E.3/1 )) . Newman: Assortative mixing in networks.org/abs/cond-mat/ 2 54 5/ Examples # random network.com> References M. Rev. q and q . tends to be dissortative assortativity. assortativity. org/abs/cond-mat/ 2 945 M.game(1 . Rev.renyi.degree uses vertex degree (minus one) as vertex values and calls assortativity. assortativity calculates this measure. Newman: Mixing patterns in networks. j eji . Value A single real number. E 67. Author(s) Gabor Csardi <csardi.

Numeric vector. the color of the vertices when the graph is plotted. vertex and edge attributes Description Attributes are associated values belonging to a graph. name) set. or visualization parameters. value) remove.graph. or simply the weights of the edges in a weighted graph. like the betweenness centrality of the vertices.attribute(graph. even if value is longer.attributes 21 attributes Graph. name.attribute(graph. or meta-data associated with the vertices. vertex attributes with vertices and edge attributes with edges. name index value Details There are three types of attributes in igraph: graph. name. name. name) get. Usage get. or whether the graph is a simple graph. index=E(graph)) set. value) remove.vertex.attribute(graph. the type of the neurons in a graph representing neural circuitry or even some pre-computed structual properties. name. ie. These can represent some property. . Examples of edge attributes are data associated with edges: most commonly edge weights. name.vertex. Examples of vertex attributes are vertex properties. if you don’t assign it to a variable your modifications will be lost! See examples below.attribute(graph. index=V(graph)) set.vertex.graph.attribute(graph.graph. the name of the attribute.attribute(graph. vertices or edges. or other visualization parameters. Note that the original graph is never modified. like the vertex coordinates for the visualization of the graph. like the gender and the age of the individuals in a friendship network. Numeric vector. index=V(graph). a new graph object is returned instead. It is not recycled. the ids of the vertices or edges.attribute(graph.attribute(graph. one without loops and multiple edges.edge. name) get. Examples for graph attributes are the date when the graph data was collected or other types of memos like the type of the data.edge. it will be recycled if needed.attribute(graph. index=E(graph). Character constant. value) remove. Graph attributes are associated with graph. name) Arguments graph The graph object to work on.edge. like data about how the graph was constructed. vertex and edge attributes. the new value(s) of the attributes.

attribute and get.graph.attributes.attributes.igraph can print attributes.com> See Also print. set.attribute and remove.vertex. and V(g)$name queries the name attribute for all vertices.vertex. Graph attributes can be created with the set.graph.attribute.attribute and the assigned graph attributes are listed with list.attribute.combination for details on how igraph combines attributes if several vertices or edges are mapped into one. get.edge.vertex.attribute. like the regular R convention: V(g)$color <.graph.edge.graph.attribute.vertex.attribute.edge. Author(s) Gabor Csardi <csardi.attributes and for edge attributes they are set. There is a simpler notation for using graph attributes: the ‘$’ operator.22 attributes In recent igraph versions. Similarly is vs is a vertex set vs$name gives the values of the name attribute for the vertices in the vertex set.attribute return a new graph object with the updates/removes performed. it works like this: V(g) selects all vertices in a graph. see an example below. list. remove. There is however a (syntactically) much simpler way to handle vertex and edge attribute by using vertex and edge selectors. The functions for vertex attributes are set.graph. get.edge. See also the manual page for iterators about how to create various vertex and edge sets.edge.edge. Expect more in the (near) future."red" It works for vertex subsets as well: V(g)[1:5]$color <.vertex.attribute.attribute and list. remove. set.attributes return a character vector. Graph attributes are queried with get.attribute and list.attribute.attribute return an R object. .attribute.graph.vertex. vertex or edge attributes.gabor@gmail. arbitrary R objects can be assigned as graph.attribute.attribute. set. or a list of R objects if attributes of more vertices/edges are requested. vertex and edge attributes if they are present but this is not done in the current version very extensively.graph. See attribute. Some igraph functions use the values or graph. remove.vertex.attribute function. It can be used both to query and set graph attributes.attributes and list.graph.vertex.edge. the names of the attributes present. and removed with remove. and also remove. get. This form can also be used to set the values of the attributes.edge. Value get.attributes. etc. list."green" The notation for edges is similar: E(g) means all edges E(g)$weight is the weight attribute for all edges.

5) Arguments graph start The input graph.set.autocurve. value=runif(ecount(g))) get.edges Optimal edge curvature when plotting graphs Description If graphs have multiple edges.graph. "weight". "color". .edge. e=TRUE) 23 autocurve. "weight") # The following notation is more convenient g <. The curvature at the two extreme edges. g=TRUE. value=c("red".attribute(g. "color") g <.graph.star(1 ) V(g)$color <. with diffenent curvature.curved vector for plotting a graph with multiple edges. "green")) get.set.c("red".attribute(g. "green") V(g)$color E(g)$weight <.attribute(g. then drawing them as straight lines does not show them when plotting the graphs.graph.runif(ecount(g)) E(g)$weight print(g. All edges will have a curvature between -start and start. v=TRUE. One solution is to bend the edges."RING" g$name g <. so that all of them are visible.edges Examples g <. Usage autocurve.vertex.ring(1 ) g <.edges (graph. start = . so that all edges are visible. "RING") # It is the same as g$name <.edge.vertex. spaced equally. Details autocurve.attribute(g. they will be on top of each other.set. "name".attribute(g.edges calculates the optimal edge.

3. out.1)+1 ) autocurve. 2.igraph. "psumtree-multiple".2.2. "bag").3.game(n.graph( c( .dist and out.game igraph.3. directed = TRUE.graph = NULL) Arguments n power m Number of vertices. start. Usage barabasi.dist = NULL.pref = FALSE. algorithm = c("psumtree". power = 1.1. out. out.plotting for all plotting parameters.appeal = 1. . plot.seq are omitted or NULL.3.1.2. . its length is the number of edges in the graph.game Generate scale-free graphs according to the Barabasi-Albert model Description The BA-model is a very simple stochastic algorithm for building a graph.edges(g) ## Not run: set. ie. zero. linear preferential attachment.3. tkplot and rglplot for plotting functions.1.3.1.1. Examples g <. .seq = NULL. the number of edges to add in each time step This argument is only used if both out.3.com> See Also barabasi. the default is one.gabor@gmail.24 Value A numeric vector. m = NULL.1. The power of the preferential attachment. Author(s) Gabor Csardi <csardi.2. Numeric constant.seed(42) plot(g) ## End(Not run) barabasi.

If both out. the second is the number of edges to add in the second time step and so on. Numeric vector giving the number of edges to add in each time step. It is a discrete time step model and in each time step a single vertex is added.dist does not need to sum up to one.appeal values and never generates multiple edges. .seq and out. bag is the algorithm that was previously (before version 0. but the generation of multiple edges is allowed.barabasi. Its first element is the probability that no edges will be added. NULL or an igraph graph.graph.appeal was not one.seq argument is not NULL. Its first element is ignored as no edges are added in the first time step. then the supplied graph is used as a starting graph for the preferential attachment algorithm.seq arguments. This method might generate multiple edges.) out.6 version igraph used this algorithm if power was not one.seq is given and not NULL then it gives the number of edges to add in a vector. really).seq out. exactly as many times as their (in)degree. psumtree uses a partial prefixsum tree to generate the graph. it should be a positive integer constant and m edges will be added in each time step. otherwise the in-degree is used. out.dist are omitted or NULL then m will be used. If a graph is supplied here and the out.dist out. If out. (out. The algorithm to use for the graph generation. It works by putting the ids of the vertices into a bag (mutliset.graph Details This is a simple stochastic algorithm to generate a graph. the distribution of the number of edges to add in each time step. plus once more. The probability that an old vertex is chosen is given by α P [i] ∼ ki +a where ki is the in-degree of vertex i in the current time step (more precisely the number of adjacent edges of i which were not initiated by i itself) and α and a are parameters given by the power and zero.pref zero. The number of edges initiated in a time step is given by the m. psumtree-multiple also uses a partial prefix-sum tree. Then we add one vertex in each time step and the new vertex initiates some edges to old vertices. If a graph.6) used if power was one and zero. Logical. with replacement. it normalized automatically. this algorithm can handle any power and zero.appeal directed algorithm 25 Numeric vector. the first element is ignored. The graph should have at least one vertex. We start with a single vertex and no edges in the first time step. If out. The ‘attractiveness’ of the vertices with no adjacent edges. See details below.seq argument is omitted or NULL. Before the 0. if true the total degree is used for calculating the citation probability. etc.game out.dist is given and not NULL then it is used as a discrete distribution to generate the number of edges in each time step.appeal are equal one. not the ones in the start. This argument is only used if the out. start.dist should contain non-negative numbers and at east one element should be positive.dist and out. It only works if power and zero.appeal was one as well. the second is the probability that one edge is added. or zero.seq is not given or null and out. Then the required number of cited vertices are drawn from the bag. then it should contain the out degrees of the new vertices only.appeal arguments. Whether to create a directed graph.

cutoff. nobigint = TRUE. weights = NULL. Usage betweenness(graph.game generates a directed graph by default. weights = NULL. vids = V(graph).estimate(graph.-L. weights = NULL) betweenness. See Also random. e=E(graph).com> References Barabasi.+ out-) degree of the vertex.gabor@gmail. directed = TRUE. directed = TRUE.barabasi. weights = NULL) .26 betweenness barabasi. e=E(graph).graph.betweenness.game Examples g <. directed = TRUE.estimate(graph. cutoff. 1999. and Albert R. unless the out. Note that even if an undirected graph is generated ki denotes the number of adjacent edges not initiated by the vertex itself and not the total (in. normalized = FALSE) edge.distribution(g) ) betweenness Vertex and edge betweenness centrality Description The vertex and edge betweenness are (roughly) defined by the number of geodesics (shortest paths) going through a vertex or an edge.betweenness(graph. nobigint = TRUE) edge. Author(s) Gabor Csardi <csardi.pref argument is set to TRUE. Value A graph object. set directed to FALSE to generate an undirected graph. v=V(graph). A. Emergence of scaling in random networks Science.game(1 degree. 286 509– 512. directed = TRUE.

this can be run for larger graphs. Logical scalar. The maximum path length to consider when calculating the betweenness.i=v. For calculating the betweenness a similar algorithm to the one proposed by Brandes (see References) is used. whether to use big integers during the calculation.estimate is similar. If zero or negative then there is no such limit. If TRUE (the default). If the graph has a weight edge attribute. but for edges. i=j betweenness calculates vertex betweenness. Details The vertex betweenness of vertex v is defined by givj /gij i=j. where B n is the normalized. then big integers are not used. vids cutoff The vertices for which the vertex betweenness estimation will be calculated.j =v The edge betweenness of edge e is defined by giej/gij . If TRUE. If cutoff is zero or negative then the function calculates the exact betweenness scores.betweenness Arguments graph v e directed weights nobigint The graph to analyze. Logical scalar.betweenness. as the running time is not quadratic (if cutoff is small). then the results are normalized according to Bn = n2 2B − 3n + 2 normalized . . B the raw betweenness. edge. edge.betweenness.estimate only considers paths of length cutoff or smaller. The edges for which the edge betweenness will be calculated. whether to normalize the betweenness scores. then this is used by default. betweenness. The vertices for which the vertex betweenness will be calculated. and n is the number of vertices in the graph. Optional positive weight vector for calculating weighted betweenness. whether directed paths should be considered while determining the shortest paths.betweenness calculates edge. 27 Logical. This is only required for lattice-like graphs that have very many shortest paths between a pair of vertices.

See Also closeness.28 Value biconnected. 3/1 ) betweenness(g) edge. It is treated as an undirected graph. 1. Centrality in Social Networks I: Conceptual Clarification. even if it is directed.estimate the estimated edge betweenness score for all edges.estimate returns the estimated betweenness scores for vertices in vids.random. L.betweenness.components A numeric vector with the betweenness score for each vertex in v for betweenness.betweenness. Author(s) Gabor Csardi <csardi.betweenness(g) biconnected.betweenness might give false values for graphs with multiple edges.graph.com> References Freeman.components(graph) Arguments graph The input graph. A Faster Algorithm for Betweenness Centrality. . 2001. both in a numeric vector. degree Examples g <. 215-239.components Biconnected components Description Finding the biconnected components of a graph Usage biconnected. betweenness.gabor@gmail.game(1 . (1979). edge. Ulrik Brandes. Social Networks. Note edge. Journal of Mathematical Sociology 25(2):163-177. A numeric vector with the edge betweenness score for each edge in e for edge.C.

Each vector is a set of edge ids giving the edges in a biconnected component. Note that this is not true for vertices: the same vertex can be part of many biconnected components. clusters. A list of numeric vectors.connected. articulation_points The articulation points of the graph.biconnected. A biconnected component of a graph is a maximal biconnected subgraph of it.bipartite. The components themselves.mapping Decide whether a graph is bipartite Description This function decides whether the vertices of a network can be mapped to two vertex types in a way that no vertices of the same type are connected. See articulation. Value A named list with three components: no tree_edges Numeric scalar.graph.points.points. which(clu==2))) bc <.edges(g.clusters(g)$membership g <.union( graph. The biconnected components of a graph can be given by the partition of its edges: every edge is a member of exactly one biconnected component.add. vertex.com> See Also articulation. graph. It gives all edges in the components. an integer giving the number of biconnected components in the graph. a list of numeric vectors.full(5). the vertices of the components. Author(s) Gabor Csardi <csardi.gabor@gmail. components A list of numeric vectors.disjoint. . These edges define a spanning tree of the component.components(g) component_edges bipartite.full(5) ) clu <. c(which(clu==1).mapping Details 29 A graph is biconnected if the removal of any single vertex (and its adjacent edges) does not disconnect it.connectivity Examples g <. is.

add. Note that the mapping is not necessarily unique.ring(1 ) bipartite. so it is fine g <. The existence of such a mapping is equivalent of having no circuits of odd length in the graph. then an empty vector. FALSE otherwise.30 Usage bipartite.com> Examples ## A ring has just one loop.mapping(graph) Arguments graph Details The input graph.g. Value A named list with two elements: res type A logical scalar. if the graph has at least two components.graph. too g2 <. This function simply checks whether a graph could be bipartite.mapping(g) ## A star is fine. c(1.star(1 ) bipartite.mapping(g3) . It tries to find a mapping that gives a possible division of the vertices into two classes.mapping A bipartite graph in igraph has a ‘type’ vertex attribute giving the two vertex types.ring(1 ) g3 <. bipartite. Author(s) Gabor Csardi <csardi. TRUE if the can be bipartite.mapping(g2) ## A graph containing a triangle is not fine g3 <.3)) bipartite. e.graph. A possibly vertex type mapping. then the vertices in the separate components can be mapped independently. A graph with loop edges cannot bipartite.gabor@gmail. such that no two vertices of the same class are connected by an edge.graph. If no such mapping exists.edges(g3. a logical vector.

By default vertex type FALSE is the first and TRUE is the second. E. without calculating the projections themselves.size(graph. This argument can be used to specify the order of the projections in the resulting list. Author(s) Gabor Csardi <csardi.projection.projections keeps vertex attributes.projection Project a bipartite graph Description A bipartite graph is projected into two one-mode networks Usage bipartite. See details above. then igraph keeps the multiplicity of the edges as an edge attribute. probe1 Details Bipartite graphs have a type vertex attribute in igraph. such that A-X-B is also in the graph). If given.gabor@gmail. An optional vertex type vector to use instead of the ‘type’ vertex attribute.com> . multiplicity = TRUE.projections calculates the actual projections. You can use the probe1 argument to specify the order of the projections in the result.projection (graph. then it is considered as a vertex id (or a symbolic vertex name). if there is an A-C-B and also an A-D-B triple in the bipartite graph (but no more X. this is boolean and FALSE for the vertices of the first kind and TRUE for vertices of the second kind. the projection containing this vertex will be the first one in the result list. This is useful to check how much memory the projections would need if you have a large bipartite graph. It can be directed.bipartite. types = NULL. probe1 = NULL) Arguments graph types multiplicity The input graph. but edge directions are ignored during the computation.projection. You must supply this argument if the graph has no ‘type’ vertex attribute. then the multiplicity of the A-B edge in the projection will be 2.size calculates the number of vertices and edges in the two projections of the bipartite graphs. Value A list of two undirected graphs. bipartite. bipartite.g. types = NULL) bipartite.projection 31 bipartite. If TRUE. bipartite.

boolean indicating whether or not the diagonal should be treated as valid data.projection(g2) print(proj2[[1]]. sparse=TRUE) Arguments graph nodes loops exponent rescale tol sparse the input graph. exponent (decay rate) for the Bonacich power centrality score. loops is FALSE by default. tol=1e-7.full. graph. centrality scores are rescaled such that they sum to 1. "Dan". "Skiing". The decay rate for power contributions is specified by exponent (1 by default). e=TRUE) bonpow bonpow Find Bonacich Power Centrality Scores of Network Positions Description bonpow takes a graph (dat) and returns the Boncich power centralities of positions (selected by nodes). Usage bonpow(graph. length(M).bipartite(1 .matrix( .5) proj <. exponent=1. "Cecil".isomorphic(proj[[1]].c("Alice". loops=FALSE.full(5)) ## The projection keeps the vertex attributes M <. replace=TRUE) M g2 <. "Bob".bipartite. rescale=FALSE. Set this true if and only if the data can contain loops. all vertices are included. g=TRUE. By default.bipartite.isomorphic(proj[[2]].c("Party".full(1 )) graph. The ‘Matrix’ package is required for sparse matrix support . nc=3) rownames(M) <.incidence(M) g2$name <. nodes=V(graph). graph. g=TRUE. e=TRUE) print(proj2[[2]]. tolerance for near-singularities during matrix inversion (see solve) Logical scalar.graph. nr=5."Event network" proj2 <. vertex sequence indicating which vertices are to be included in the calculation.projection(g) graph. can be negative if true.32 Examples ## Projection of a full bipartite graph is a full graph g <. whether to use sparse matrices for the calculation.graph. "Badminton") M[] <. "Ethel") colnames(M) <.sample( :1.

113-120. If your theory motivates use of this measure. The magnitude of β controls the influence of distant actors on ego’s centrality score. containing the centrality scores. higher magnitudes imply slower decay. One interesting feature of this measure is its relative instability to changes in exponent magnitude (particularly in the negative case). Author(s) Carter T. Value A vector. with larger magnitudes indicating slower rates of decay. Warning Singular adjacency matrices cause no end of headaches for this algorithm. (High rates.com> References Bonacich. (1972). respectively. 1170-1182. β gives positive and negative weight to even and odd walks. bonpow will not symmetrize your data before extracting eigenvectors. “Factoring and Weighting Approaches to Status Scores and Clique Identification. β ) = α k=0 β k Ak+1 1 which converges so long as |β | < 1/λA1 . 92. imply a greater sensitivity to edge effects. hence. the Bonacich power measure corresponds to the notion that the power of a vertex is recursively defined by the sum of the power of its alters. P. thus.) When β → 1/λA1 (the reciprocal of the largest eigenvalue of A). β ) = α (I − β A) A1.gabor@gmail. the routine may fail in certain cases. 2. Bonacich. for other values of β . and is set here (following Bonacich (1987)) such that the sum of squared scores is equal to the number of vertices.” American Journal of Sociology.edu>.” Journal of Mathematical Sociology. as can be seen from the series expansion ∞ CBP (α. copied) from the SNA package. ported to igraph by Gabor Csardi <csardi.) Interpretively. this is to within a constant multiple of the familiar eigenvector centrality score. (The coefficient α acts as a scaling parameter. The magnitude of the exponent indicates the tendency of the effect to decay across long walks. This will be fixed when I get a better algorithm. (1987). P. In particular. −1 .bonpow Details 33 Bonacich’s power centrality measure is defined by CBP (α. This allows 1 to be used as a reference value for the “middle” of the centrality range. the behavior of the measure is quite different. Note This function was ported (ie. The nature of the recursion involved is then controlled by the power exponent: positive values imply that vertices become more powerful as their alters become more powerful (as occurs in cooperative relations). you should be very careful to choose a decay parameter on a non-ad hoc basis. “Power and Centrality: A Family of Measures. where β is an attenuation parameter (set here by exponent) and A is the graph adjacency matrix. while negative values imply that vertices become more powerful only as their alters become weaker (as occurs in competitive or antagonistic relations). don’t send this routine asymmetric matrices unless you really mean to do so. Butts <buttsc@uci.

sh="fm") Arguments graph sh The input graph.f.4.4.f <.4.5)].d <.1)) { print(round(bonpow(g.11. exp=e)[c(1. 2)) } for (e in seq(.permutation # Generate some test data from Bonacich.3.5. 2)) } canonical.3.graph( c(1.graph( c(1. exp=e)[c(1.1..4. by= .c.3.4. exp=e)[c(1.5).9.1 ). 2)) } for (e in seq(.3.3. 2)) } for (e in seq(.13).centrality Examples canonical.9.c <.2.8.6. dir=FALSE) g..12.2.2.1.34 See Also evcent and alpha.2.4.5.1 .4.7.6.3.4. dir=FALSE) # Compute Bonpow scores for (e in seq(.2.4.4.3. dir=FALSE) g.7).3.1..3.1.2.1)) { print(round(bonpow(g..2.e.4.7. 1987: g.4)].2.5.permutation Canonical permutation of a graph Description The canonical permutation brings every isomorphic graphs into the same (labeled) graph.5)].3. exp=e)[c(1.4.1.2..1.1)) { print(round(bonpow(g. by= ..5.4.2.4. by= .5)].2.graph( c(1. Type of the heuristics to use for the BLISS algorithm.4. dir=FALSE) g. treated as undirected.4. ..1.d.2. by= .permutation(graph.e <.3.1)) { print(round(bonpow(g. Usage canonical.graph( c(1..2.5.8. See details for possible values.2.2.6.

Proceedings of the Ninth Workshop on Algorithm Engineering and Experiments and the Fourth Workshop on Analytic Algorithms and Combinatorics. References Tommi Junttila and Petteri Kaski: Engineering an Efficient Canonical Labeling Tool for Large and Sparse Graphs.fi/Software/bliss/index. the second element for vertex 1. and approximate otherwise. nof_leaf_nodes The number of leaf nodes in the search tree. The possible values for the sh argument are: f First non-singleton cell.com> for the igraph and R interfaces. flm Largest maximally non-trivially connected non-singleton cell. Value A list with the following members: labeling The canonical parmutation which takes the input graph into canonical form. nof_canupdates Number of canrep updates.gabor@gmail. the first element is the new label of vertex 0. All isomorphic graphs have the same canonical form. Gabor Csardi <csardi.permutation computes a permutation which brings the graph into canonical form. as defined by the BLISS algorithm. Some information about the BLISS computation. etc. fm First maximally non-trivially connectec non-singleton cell. as a string. Author(s) Tommi Junttila for BLISS. A named list with the following members: nof_nodes The number of nodes in the search tree. group_size The size of the automorphism group of the input graph. nof_bad_nodes Number of bad nodes. max_level Maximum level. fl First largest non-singleton cell. This number is exact if igraph was compiled with the GMP library.canonical. This and more information is available at http: //www. A numeric vector.tcs. See the paper in references for details about these. See the paper below for the details about BLISS. fsm Smallest maximally non-trivially connected non-singleton cell. fs First smallest non-singleton cell.permutation Details 35 canonical.html.hut. 2007. info .

permute. nodes = . Examples ## Calculate the canonical form of a random graph g1 <.2]).el2[ order(el2[. "all".degree. directed = TRUE. normalized = TRUE) centralization. Usage centralize.vertices(g1.vertices(g2.degree (graph. type="gnm") cp1 <.tmax (graph = NULL.scores (scores. "out". normalized = TRUE) centralization. normalized = TRUE) centralization.arpack.closeness (graph.canonical. scale = TRUE. "out".1]. normalized = TRUE) centralization.permutation(g1) cf1 <. graph. cp2$labeling) ## Check that they are the same el1 <. "in". mode = c("all".renyi. el1[.canonical.tmax (graph = NULL.edgelist(cf1) el2 <. "in".vertices(g1. options = igraph.edgelist(cf2) el1 <.default. nobigint = TRUE. ] all(el1 == el2) centralization Centralization of a graph.permute. ] el2 <.tmax Description Centralization is a method for creating a graph level centralization measure from the centrality scores of the vertices.vertices to apply a permutation to a graph. directed = FALSE. nodes = .isomorphic for deciding graph isomorphism. directed = TRUE) . "in". loops = TRUE. 2 . "total").get.get.permutation(g2) cf2 <.betweenness (graph. mode = c("out".evcent (graph.closeness. "total").1]. sample(vcount(g1))) cp2 <.el1[ order(el1[.36 See Also centralization permute. normalized = TRUE) centralization. "total"). cp1$labeling) ## Do the same with a random permutation of it g2 <. el2[. possibly based on canonical labels. loops = FALSE) centralization.permute.2]). mode = c("all".game(1 .max.erdos. theoretical.

The input graph. out-star or undirected star. Logical scalar. The graph-level centrality score can be normalized by dividing by the maximum theoretical score for a graph with the same number of vertices. directed = TRUE) centralization. This is ignored if the graph is given. This argument is passed to the betweenness function. For the “tmax” functions it can be NULL. directedness.tmax (graph = NULL.g. see the details below. This is the same as the mode argument of degree and closeness. . For degree. nodes = . The number of vertices. Logical scalar. theoretical. The formula for this is C (G) = v Logical scalar. Whether to rescale the eigenvector centrality scores. whether to use big integers for the betweenness calculation. This is only used if the normalized argument is set to TRUE. scale = TRUE) Arguments 37 scores The vertex level centrality scores. Whether to normalize the graph level centrality score by dividing the supplied theoretical maximum.centralization centralization. closeness and betweenness the most centralized structure is some version of the star graph. e. the options for the ARPACK eigensolver. whether we consider loop edges. etc. nodes = . logical scalar. The graph level centrality score of the most centralized graph with the same number of vertices as the graph under study.evcent. This is passed to evcent. whether to consider loops edges when calculating the degree. using the same parameters. centralize.scores using the general centralization formula to calculate a graph-level score from vertex-level scores.tmax (graph = NULL. normalized graph mode loops directed nobigint scale nodes options Details Centralization is a general method for calculating a graph-level centrality score based on node-level centrality measure. whether to use directed shortest paths for calculating betweenness.max Real scalar.betweenness. For eigenvector centrality the most centralized structure is the graph with a single edge (and potentially many isolates). in-star. w where cv is the centrality of vertex v . directed = FALSE. such that the maximum score is one. (max cw − cv ).

degree. centralization.closeness.betweenness a named list with the following components: res The node-level centrality scores. (1979).tmax and centralization. K.tmax. The other way to call these functions is to omit the graph argument. centralization.betweenness.tmax.tmax and centralization. centralization.tmax. the number of vertices and directedness is taken from this graph.g.tmax return the theoretical maximum scores. In the first mode. the theoretical maximum centralization score for a graph with the same number of vertices.betweenness calculate both the vertex-level and the graph-level indices. E.degree.closeness. For centralization. S.evcent. but explicitly specify the rest of the arguments. Cambridge University Press. a graph is given and the maximum score is calculated based on that. centralization. then the result was divided by this number. (1994). They operate in two modes.38 centralization centralization.tmax a real scalar. centralization The graph level centrality index.closeness and centralization. Social Networks 1.betweenness.scores a real scalar.degree.. ARPACK options.tmax.C. Centrality in Social Networks I: Conceptual Clarification. centralization.evcent a named list with the following components: vector value options The node-level centrality scores. L.closeness. Value For centralize. and Faust. Social Network Analysis: Methods and Applications. centralization.com> References Freeman. theoretical_max The maximum theoretical graph level centralization score for a graph with the given number of vertices. . centralization The graph level centrality index. Author(s) Gabor Csardi <csardi.degree.evcent. see the return value of evcent for details. For centralization. centralization. centralization. 215–239.gabor@gmail. theoretical_max The same as above. Wasserman. For centralization. using the same parameters. If the normalized argument was TRUE. The corresponding eigenvalue.

ie. multiple edges and loops are ignored. directed graphs will be considered as undirected ones.1).evcent(g1)$centralization 39 cliques The functions find cliques. Usage cliques(graph.cliques(graph. obeying the size limitations given in the min and max arguments. the largest or all the maximal cliques in an undirected graph.closeness(g. m=4) centralization. largest.evcent(g )$centralization centralization.star(1 . The size of the largest clique can also be calculated. n=1 .cliques finds all largest cliques in the input graph. Details cliques find all complete subgraphs in the input graph. NULL means no limit. The largest cliques are always maximal.cliques(graph) maximal. . dir=FALSE ) g1 <.evcent(g. mode="undirected") centralization. it is the same as 0. min=NULL.game(1 . lower limit on the size of the cliques to find.graph( c(2. complete subgraphs in a graph Description These functions find all. NULL means no limit.graph.cliques Examples # A BA graph is quite centralized g <. maximal.degree(g)$centralization centralization.number(graph) Arguments graph min max The input graph. ie. A clique is largest if there is no other clique including more vertices. Numeric constant. directed=FALSE)$centralization # The most centralized graph according to eigenvector centrality g <. but a maximal clique is not neccessarily the largest. upper limit on the size of the cliques to find. A clique in maximal if it cannot be extended to a larger clique. Numeric constant.cliques finds all maximal cliques in the input graph. max=NULL) largest.ba. mode="all")$centralization centralization. max=NULL) clique. min=NULL.

Usage closeness(graph. "in".sets Examples # this usually contains cliques of size six g <.game(1 . vids=V(graph). "total"). closeness The current implementation of these functions searches for maximal independent vertex sets (see independent.vertex. Each list element is a clique. "in".number calculates the size of the largest clique(s). largest.vertex.gabor@gmail.com> for the R interface and the manual page. weights = NULL) .number returns an integer constant. Author(s) Tamas Nepusz <ntamas@gmail.3) clique.number return a list containing numeric vectors of vertex ids.renyi. . normalized = FALSE) closeness.erdos. 3) maximal.cliques(g) # To have a bit less maximal cliques. "all". . mode = c("out". cutoff.sets) in the complementer graph. Value cliques. "all".game(1 .40 clique. about 1 g <.renyi. mode = c("out". vids=V(graph).cliques(g) -2 usually closeness Closeness centrality of vertices Description Cloness centrality measures how many steps is required to access every other vertex from a given vertex.com> and Gabor Csardi <csardi.estimate(graph. "total").erdos. clique.cliques and clique.number(g) cliques(g. min=6) largest. weights = NULL. See Also independent.

1. Value Numeric vector with the closeness values of all the vertices in v. Author(s) Gabor Csardi <csardi. normalized cutoff weights Details The closeness centrality of a vertex is defined by the inverse of the average length of the shortest paths to/from all the other vertices in the graph: 1 i=v dv i If there is no (directed) path between vertex v and i then the total number of vertices is used in the formula instead of the path length. then this is used by default. The vertices for which closeness will be calculated. 215-239.C.closeness Arguments graph vids mode The graph to analyze. defined the types of the paths used for measuring the distance in directed graphs. all uses undirected paths. 41 Character string. where n is the number of vertices in the graph. L. this can be run for larger graphs. Logical scalar. See Also betweenness. Optional positive weight vector for calculating weighted closeness. The maximum path length to consider when calculating the betweenness. “out” measures paths from a vertex.gabor@gmail. whether to calculate the normalized closeness. Social Networks. closeness. (1979). If zero or negative then there is no such limit.estimate only considers paths of length cutoff or smaller. as the running time is not quadratic (if cutoff is small). Normalization is performed by multiplying the raw closeness by n − 1. Centrality in Social Networks I: Conceptual Clarification. “in” measures the paths to a vertex.com> References Freeman. degree . This argument is ignored for undirected graphs. If cutoff is zero or negative then the function calculates the exact closeness scores. If the graph has a weight edge attribute.

mode=c("weak".connected(graph.distribution creates a histogram for the maximal connected component sizes. If TRUE the relative frequencies will be multiplied by the cluster sizes.42 Examples g <. cumulative = FALSE.. . right now only mode makes sense. either “weak” or “strong”. For directed graphs “weak” implies weakly. . mode="in") closeness(g2. mode=c("weak". The strongly connected components are implemented by two consecutive depth-first searches.ring(1 ) g2 <.clusters does almost the same as clusters but returns only the number of clusters found instead of returning the actual clusters. mode="out") closeness(g2.) Arguments graph mode The graph to analyze.. Character string.clusters(graph. Details is. cumulative mul. mode=c("weak".star(1 ) closeness(g) closeness(g2.connected decides whether the graph is weakly or strongly connected.. The weakly connected components are found by a simple breadth-first search. Logical.size = FALSE. mul. mode="all") clusters clusters Connected components of a graph Description Calculate the maximal (weakly or strongly) connected components of a graph Usage is. Logical. "strong")) no. cluster. no.graph. "strong")) cluster..graph. "strong")) clusters(graph. clusters finds the maximal (weakly or strongly) connected components of a graph. It is ignored for undirected graphs. if TRUE the cumulative distirubution (relative frequency) is calculated.size . Additional attributes to pass to cluster.distribution(graph. “strong” strongly connected components to search.

renyi. bibcoupling calculates this. The bibliographic coupling of two vertices is the number of other vertices they both cite.clusters an integer constant is returned. Note that (for currently unknown reasons) the first element of the vector is the number of clusters of size zero. numeric vector giving the sizes of the clusters. For cluster.gabor@gmail. 43 For no. .cocitation Value For is. Author(s) Gabor Csardi <csardi. For clusters a named list with three components: membership csize no numeric vector giving the cluster id to which each vertex belongs.distribution a numeric vector with the relative frequencies. so this is always zero. v=V(graph)) Arguments graph v The graph object to analyze Vertex sequence or numeric vector.connected a logical constant. cocitation siply counts how many types two vertices are cocited. The length of the vector is the size of the largest component plus one. Usage cocitation(graph.erdos. numeric constant. 1/2 ) clusters(g) cocitation Cocitation coupling Description Two vertices are cocited if there is another vertex citing both of them. v=V(graph)) bibcoupling(graph.com> See Also subcomponent Examples g <.game(2 . the vertex ids for which the cocitation or bibliographic coupling values we want to calculate. The default is all vertices. the number of clusters.

project. Usage cohesive.) exportPajek(blocks.. root=1).blocks(graph... Calculating the cocitation or bibliographic coupling for only one vertex costs the same amount of computation as for all vertices.com> Examples g <.blocks cocitation calculates the cocitation counts for the vertices in the v argument and all vertices in the graph. This might change in the future. ..file = TRUE) maxcohesion(blocks) ## S3 method for class ’cohesiveBlocks’ print(x. bibcoupling calculates the bibliographic coupling for vertices in v and all vertices in the graph. file. graph.j) contains the cocitation or bibliographic coupling for vertices v[i] and j. .blocks Calculate Cohesive Blocks Description Calculates cohesive blocks for objects of class igraph.ring(1 ) cocitation(g) bibcoupling(g) cohesive.tilford(hierarchy(blocks). .) .44 Details cohesive.. layout=layout. labels = TRUE) blocks(blocks) blockGraphs(blocks. graph) cohesion(blocks) hierarchy(blocks) parent(blocks) plotHierarchy(blocks. Author(s) Gabor Csardi <csardi.gabor@gmail.. Element (i. Value A numeric matrix with length(v) lines and vcount(graph) columns.graph.) ## S3 method for class ’cohesiveBlocks’ summary(object.reingold.

Additional arguments.igraph. integer numbers referring to the current palette. (But it can contain the path to the files. whether to add the vertex labels to the result object. The graph whose cohesive blocks are supplied in the x argument. ‘#FF9900FF’).object file Defines the file (or connection) the Pajek file is written to. (Symbolic color names (e.file y colbar col mark. etc..g. It must be undirected and simple.blocks function. (See is.file argument is TRUE. By default all cohesive blocks are marked. plotHierarchy and plot pass them to plot.. a subset of its vertices S ⊂ V (G) . created with the cohesive. By default the given colbar is used and vertices with the same maximal cohesion will have the same color.) . or to create separated files for each item. then it can be a filename (with extension). or in general any king of connection object.groups = blocks(x)[-1]. Details Cohesive blocking is a method of determining hierarchical subsets of graph vertices based on their structural cohesion (or vertex connectivity). print and summary ignore them. A vector of vertex colors.) Arguments graph 45 For cohesive. project.simple.. whether to create a single Pajek project file containing all the data. Its length should be at least m + 1. col = colbar[maxcohesion(x)+1]. Logical scalar. in any of the usual formats.blocks a graph object of class igraph.x. . labels blocks. Logical scalar. A cohesiveBlocks object.blocks ## S3 method for class ’cohesiveBlocks’ length(x) ## S3 method for class ’cohesiveBlocks’ plot(x. y. The layout of a plot. For a given graph G. the vertex colors can also be directly specified via the col argument. A list of vertex sets to mark on the plot by circling them.g. where m is the maximum cohesion in the graph. If the project..igraph. See details below. By default the Reingold-Tilford layout generator is used.groups layout .) For blockGraphs and exportPajek the same graph must be supplied whose cohesive block structure is given in the blocks argument. Color bar for the vertex colors. These labels can be then used when reporting and plotting the cohesive blocks.) See also details below. colbar = rainbow(max(cohesion(x))+1). If the project. except the one corresponding to the all vertices. mark. without extension.cohesive. ‘red’. it is simply passed on to plot. RGB colors (e. then several files are created and file must be a character scalar containing the base name of the files. a file object. see the possible formats there.file argument is FALSE. The file/connection will be opened if it wasn’t already. ‘blue’. Alternatively.

its internal structure should not be accessed directly. then the file argument must be a character scalar and it is used as the base name for the generated files.. for the root vertex it gives 0. maximally l-cohesive subsets are recursively identified with l > k . The function cohesive.... They are returned in a list of numeric vectors. then the following information is written to the file (or connection) given in the file argument: (1) the input graph. maxcohesion returns the maximal cohesion of each vertex.oo ’... functions.... etc. The various (graph.46 cohesive... If project. i. ooo .. plotHierarchy plots the hierarchy tree of the cohesive blocks on the active graphics device... starting with one.. whith the entire graph G at its root. It returns a cohesiveBlocks object. The block hierarchy can be queried using the hierarchy function..plot.file argument.. The function blocks returns the actual blocks stored in the cohesiveBlocks object.. but through the functions listed here.B-4 c 5. n 7 ooooooo. The exportPajek function can be used to export the graph and its cohesive blocks in Pajek format.. depending on its project....o.. .graph for details.. parent gives the parent vertex of each block. each containing vertex ids. by calling igraph. The function cohesion returns a numeric vector.. The function length can be used on cohesiveBlocks objects and it gives the number of blocks. n 4 . It returns an igraph graph. (2) the hierarchy graph.e. o. together with its attributes..net’ for the hierarchy graph. n 1 .net’ for the original graph.B-2 c 2. The generic function print is also defined on cohesiveBlocks objects and it is invoked automatically if the name of the cohesiveBlocks object is typed in.B-5 c 3.oooooo.file is FALSE.oo . see write. .net’ for each cohesive block. The function blockGraphs is similar. If project. The generic function summary works on cohesiveBlocks objects and it prints a one line summary to the terminal.. (2) ‘basename_hierarchy. vertex and edge) attributes are kept in the subgraph.. given a k -cohesive set of vertices.o.. .. the cohesion of the most cohesive block of the vertex..B-3 c 2..o. but returns the blocks as (induced) subgraphs of the input graph... o. in the block hierarchy.blocks implements cohesive blocking.. cohesiveBlocks should be handled as an opaque class. ’. the cohesion of the different blocks. The order of the blocks is the same as for the blocks and blockGraphs functions.file is TRUE... It produces an output like this: Cohesive block structure: B-1 c 1.oo . ’... its vertex ids are ordered according the order of the blocks in the blocks and blockGraphs..e. Cohesive blocking is a process through which. (3) ‘basename_block_x. It can either export a single Pajek project file with all the information. Thus a hiearchy of vertex subsets is found. then the following files are created: (1) ‘basename. If file is ‘basename’. i. cohesion. and (3) one binary partition for each cohesive block... n 14 oooooooo.blocks is said to be maximally k -cohesive if there is no superset of S with vertex connectivity greater than or equal to k . or a set of files. where ‘x’ is the number of the block. n 23 ’.

the number of blocks.blocks returns a cohesiveBlocks object. 8-9:11:14. a dot means that it is not.com> wrote the first version in R. Then cohesion of the block and the number of vertices in the block are shown. 14-15. blockGraphs returns a list of igraph graphs. Value cohesive. 21-22:23. Feb 2003. 1 -12:13. 7-8:11:14:19. The generic function plot plots the graph.cohesive. 19-2 :22:23.cohesion Examples ## The graph from the Moody-White paper mw <. hierarchy returns an igraph graph. R.blocks(mw) . 2 -21. 6-7. plot and exportPajek return NULL. ordered by vertex ids. 68(1):103–127.formula(1-2:3:4:5:6. 4-5:6:7. showing one or more cohesive blocks in it. 15-16. 22-23) mwBlocks <. print and summary return the cohesiveBlocks object itself.com> for the current implementation.cohesive. 17-18:19:2 . giving the cohesion of its most cohesive block. 2-3:4:5:7.blocks 47 The left part shows the block structure. Moody and D. in the block hierarchy. The last part is only printed if the display is wide enough and shows the vertices in the blocks.gabor@gmail. Structural cohesion and embeddedness: A hierarchical concept of social groups. 11-12:14. cohesion returns a numeric vector. 3-4:6:7. and the vertices are shown in groups of ten. plotHierarchy. 5-6:7:21. the representation of the cohesive block hierarchy. even if its cohesion is zero. parent returns a numeric vector giving the parent block of each cohesive block.graph. White. corresponding to the cohesive blocks. blocks returns a list of numeric vectors. See Also graph.mcmahan@gmail. the cohesion of each block. maxcohesion returns a numeric vector with one entry for each vertex. invisibly. The first block always corresponds to the whole graph. American Sociological Review. 13-16. invisibly. 9-1 . Author(s) Gabor Csardi <csardi. in this case for five blocks. Peter McMahan <peter. 18-2 :21. length returns a numeric scalar. ‘o’ means that the vertex is included. 12-16. containing vertex ids. References J. The block at the root of the hierarchy has no parent and is returned for it.

Carol:Pat:Pam:Jennie:Bill.paj") ## End(Not run) # Plot the results if (interactive()) { plot(mwBlocks. mark. Pam:Brazey:Carol:Pat . Pauline . For example simplify maps multiple edges to single edges."orange") ) } Combining attributes Combining attributes How igraph functions handle attributes when the graph changes Description Many times. margin=. colbar=c(NA.blocks(camp) campBlocks if (interactive()) { plot(campBlocks.border=1.size2=8. camp. Holly . Gery ."cyan". when the structure of a graph is modified.Pauline:Michael:Lee:Holly.formula(Harry:Steve:Don:Bert . vertex. vertex. ..cohesive.Michael:Bill:Jennie.graph. file="/tmp/mwBlocks. vertices/edges map of the original graph map to vertices/edges in the newly created (modified) graph.shape="rectangle". vertex.Bill:Jennie:Ann:Lee:John.Steve:Bert:Gery:John. Jennie .Michael:Jennie:Pauline.Pam:Brazey:Carol:Pat.Gery:Russ:Michael) campBlocks <.2. mw.Pat:Steve:Russ:John. Bill . mw) } ## The science camp network camp <.size=24. Russ .label=V(camp)$name.Bill:Jennie:Ann. Ann . NA.Harry:Steve:Don:Bert. John . vertex.Holly:Michael:Lee:Ann:Pauline. Lee . igraph provides a flexible mechanism to specify what to do with the vertex/edge attributes in these cases.48 # Inspect block membership and cohesion mwBlocks blocks(mwBlocks) cohesion(mwBlocks) # Save results in a Pajek file ## Not run: exportPajek(mwBlocks. Michael .

Combining attributes Details

49

The functions that support the combination of attributes have one or two extra arguments called vertex.attr.comb and/or edge.attr.comb that specify how to perform the mapping of the attributes. E.g. contract.vertices contracts many vertices into a single one, the attributes of the vertices can be combined and stores as the vertex attributes of the new graph. The specification of the combination of (vertex or edge) attributes can be given as 1. a character scalar, 2. a function object or 3. a list of character scalars and/or function objects. If it is a character scalar, then it refers to one of the predefined combinations, see their list below. If it is a function, then the given function is expected to perform the combination. It will be called once for each new vertex/edge in the graph, with a single argument: the attribute values of the vertices that map to that single vertex. The third option, a list can be used to specify different combination methods for different attributes. A named entry of the list corresponds to the attribute with the same name. An unnamed entry (i.e. if the name is the empty string) of the list specifies the default combination method. I.e. list(weight="sum", "ignore") specifies that the weight of the new edge should be sum of the weights of the corresponding edges in the old graph; and that the rest of the attributes should be ignored (=dropped). Predefined combination functions The following combination behaviors are predefined: ‘ignore’ The attribute is ignored and dropped. ‘sum’ The sum of the attributes is calculated. This does not work for character attributes and works for complex attributes only if they have a sum generic defined. (E.g. it works for sparse matrices from the Matrix package, because they have a sum method.) ‘prod’ The product of the attributes is calculated. This does not work for character attributes and works for complex attributes only if they have a prod function defined. ‘min’ The minimum of the attributes is calculated and returned. For character and complex attributes the standard R min function is used. ‘max’ The maximum of the attributes is calculated and returned. For character and complex attributes the standard R max function is used. ‘random’ Chooses one of the supplied attribute values, uniformly randomly. For character and complex attributes this is implemented by calling sample. ‘first’ Always chooses the first attribute value. It is implemented by calling the head function. ‘last’ Always chooses the last attribute value. It is implemented by calling the tail function. ‘mean’ The mean of the attributes is calculated and returned. For character and complex attributes this simply calls the mean function. ‘median’ The median of the attributes is selected. Calls the R median function for all attribute types. ‘concat’ Concatenate the attributes, using the c function. This results almost always a complex attribute.

50 Specifying combination methods for all graphs

Combining attributes

The are two standard igraph parameters that define the default behavior when combining vertices and edges: vertex.attr.comb specifies how to combine vertices by default, edge.attr.comb does the same for edges. E.g. if you want to drop all vertex attributes when combining vertices, you can specify igraph.options(vertex.attr.comb="ignore") As another example, if – when combining edges – you want to keep the mean weight of the edges, concatenate their names into a single character scalar, and drop everything else, then use igraph.options(edge.attr.comb=list(weight="mean", name=toString, "ignore") Simple and complex attributes An attribute is simple if (for all vertices/edges) it can be specified as an atomic vector. Character and numeric attributes are always simple. E.g. a vertex attribute that is a numeric vector of arbitrary length for each vertex, is a complex attribute. Combination of attributes might turn a complex attribute into a single one, and the opposite is possible, too. E.g. when contatenating attribute values to form the new attribute value, the result will be typically a complex attribute. See also examples below. Author(s) Gabor Csardi <csardi.gabor@gmail.com> See Also attributes on how to use graph/vertex/edges attributes in general. igraph.options on igraph parameters. Examples
g <- graph( c(1,2, 1,2, 1,2, 2,3, 3,4) ) E(g)$weight <- 1:5 ## print attribute values with the graph igraph.options(print.graph.attributes=TRUE) igraph.options(print.vertex.attributes=TRUE) igraph.options(print.edge.attributes=TRUE) ## new attribute is the sum of the old ones simplify(g, edge.attr.comb="sum") ## collect attributes into a string simplify(g, edge.attr.comb=toString)

communities
## concatenate them into a vector, this creates a complex ## attribute simplify(g, edge.attr.comb="concat") E(g)$name <- letters[seq_len(ecount(g))] ## both attributes are collected into strings simplify(g, edge.attr.comb=toString) ## harmonic average of weights, names are dropped simplify(g, edge.attr.comb=list(weight=function(x) length(x)/sum(1/x), name="ignore"))

51

communities

Functions to deal with the result of network community detection

Description igraph community detection functions return their results as an object from the communities class. This manual page describes the operations of this class. Usage ## S3 method for class ’communities’ print(x, ...) ## S3 method for class ’communities’ length(x) sizes(communities) membership(communities) ## S3 method for class ’communities’ modularity(x, ...) algorithm(communities) crossing(communities, graph) is.hierarchical(communities, full = FALSE) merges(communities) cutat(communities, no, steps) ## S3 method for class ’communities’ as.dendrogram(object, hang=-1, use.modularity=FALSE, ...) ## S3 method for class ’communities’ as.hclust(x, hang = -1, use.modularity = FALSE, ...) ## S3 method for class ’communities’ asPhylo(x, use.modularity=FALSE, ...) showtrace(communities)

52

communities

code.length(communities) ## S3 method for class ’communities’ plot(x, y, colbar=rainbow(length(x)), col=colbar[membership(x)], mark.groups=communities(x), edge.color=c("black", "red")[crossing(x,y)+1], ...) Arguments communities,x,object A communities object, the result of an igraph community detection function. graph full An igraph graph object, corresponding to communities. Logical scalar, if TRUE, then is.hierarchical only returns TRUE for fully hierarchical algorithms. The ‘leading eigenvector’ algorithm is hierarchical, it gives a hierarchy of groups, but not a full dendrogram with all vertices, so it is not fully hierarchical. An igraph graph object, corresponding to the communities in x. Integer scalar, the desired number of communities. If too low or two high, then an error message is given. Exactly one of no and steps must be supplied. The number of merge operations to perform to produce the communities. Exactly one of no and steps must be supplied. A vector of colors, in any format that is accepted by the regular R plotting methods. E.g. it may be an integer vector, a character vector of color names, a character vector of RGB colors. This vector gives the color bar for the vertices. The length of the vector should be the same as the number of communities. A vector of colors, in any format that is accepted by the regular R plotting methods. This vector gives the colors of the vertices explicitly. A list of numeric vectors. The communities can be highlighted using colored polygons. The groups for which the polygons are drawn are given here. The default is to use the groups given by the communities. Supply NULL here if you do not want to highlight any groups. The colors of the edges. By default the edges within communities are colored green and other edges are red. Numeric scalar indicating how the height of leaves should be computed from the heights of their parents; see plot.hclust.

y no steps colbar

col mark.groups

edge.color hang

use.modularity Logical scalar, whether to use the modularity values to define the height of the branches. ... Additional arguments. plot.communities passes these to plot.igraph. The other functions silently ignore them.

communities Details

53

Community structure detection algorithms try to find dense subgraphs in directed or undirected graphs, by optimizing some criteria, and usually using heuristics. igraph implements a number of commmunity detection methods (see them below), all of which return an object of the class communities. Because the community structure detection algorithms are different, communities objects do not always have the same structure. Nevertheless, they have some common operations, these are documented here. The print generic function is defined for communities, it prints a short summary. The length generic function call be called on communities and returns the number of communities. The sizes function returns the community sizes, in the order of their ids. membership gives the division of the vertices, into communities. It returns a numeric vector, one value for each vertex, the id of its community. Community ids start from one. Note that some algorithms calculate the complete (or incomplete) hierarchical structure of the communities, and not just a single partitioning. For these algorithms typically the membership for the highest modularity value is returned, but see also the manual pages of the individual algorithms. modularity gives the modularity score of the partitioning. (See modularity.igraph for details. For algorithms that do not result a single partitioning, the highest modularity value is returned. algorithm gives the name of the algorithm that was used to calculate the community structure. crossing returns a logical vector, with one value for each edge, ordered according to the edge ids. The value is TRUE iff the edge connects two different communities, according to the (best) membership vector, as returned by membership(). is.hierarchical checks whether a hierarchical algorithm was used to find the community structure. Some functions only make sense for hierarchical methods (e.g. merges, cutat and as.dendrogram). merges returns the merge matrix for hierarchical methods. An error message is given, if a nonhierarchical method was used to find the community structure. You can check this by calling is.hierarchical on the communities object. cutat cuts the merge tree of a hierarchical community finding method, at the desired place and returns a membership vector. The desired place can be expressed as the desired number of communities or as the number of merge steps to make. The function gives an error message, if called with a non-hierarchical method. as.dendrogram converts a hierarchical community structure to a dendrogram object. It only works for hierarchical methods, and gives an error message to others. See dendrogram for details. as.hclust is similar to as.dendrogram, but converts a hierarchical community structure to a hclust object. asPhylo converts a hierarchical community structure to a phylo object, you will need the ape package for this.

showtrace works (currently) only for communities found by the leading eigenvector method (leading.eigenvector.commun and returns a character vector that gives the steps performed by the algorithm while finding the communities. code.length is defined for the InfoMAP method (infomap.community and returns the code length of the partition. It is possibly to call the plot function on communities objects. This will plot the graph (and uses plot.igraph internally), with the communities shown. By default it colores the vertices according

merges returns a two-column numeric matrix.betweenness.propagation. Value print returns the communities object itself.community. membership returns a numeric vector.community.community. please see that and also igraph. spinglass. Author(s) Gabor Csardi <csardi.graph. and also marks the vertex groups corresponding to the communities.hierarchical returns a logical scalar.gabor@gmail.community. karate) . crossing returns a logical vector. See compare. code. invisibly.walktrap.dendrogram returns a dendrogram object.community. sizes returns a numeric vector. one number for each vertex in the graph that was the input of the community detection. length returns an integer scalar.community. leading. showtrace returns a character vector. It passes additional arguments to plot. label. they all return a communities object: edge. is.com> See Also See dendPlot for plotting community structure dendrograms. as. plot for communities objects returns NULL.community(karate) modularity(wc) membership(wc) plot(wc.length returns a numeric scalar for communities found with the InfoMAP method and NULL for other methods. The different methods for finding communities.eigenvector. invisibly. cutat returns a numeric vector. walktrap.famous("Zachary") wc <.communities for comparing two community structures on the same graph.community.igraph. fastgreedy.54 communities to their communities.plotting on how to change the plot. the membership vector of the vertices. modularity returns a numeric scalar. multilevel. algorithm returns a character scalar. Examples karate <. optimal.community.

spinglass. steps.edges(g.add.to.betweenness. edge. The membership vector.graph.membership(g. The number of steps. see e. Logical scalar.gabor@gmail. a typical result of community structure detection algorithms and creates a membership vector by performing a given number of merges in the merge matrix.community. A numeric vector giving the sizes of the communities. c(1.com> See Also walktrap.community(g) community. whether to include the membership vector in the result. . merges to be performed. The merge matrix.6.membership(graph.to.membership Common functions supporting community detection algorithms Description community. wtc$merges.community.community.full(5) %du% graph. 6. Examples g <.to. whether to include the sizes of the communities in the result. merges. walktrap. membership=TRUE.to.full(5) g <. 11)) wtc <. 1. fastgreedy. steps=12) The graph to which the merge matrix belongs.membership 55 community. ie.membership takes a merge matrix. Logical scalar. Usage community.11.community for various community detection methods.community.to. csize=TRUE) Arguments graph merges steps membership csize Value A named list with two members: membership csize Author(s) Gabor Csardi <csardi.walktrap.community for the exact format.full(5) %du% graph.g.

Learning Theory and Kernel Machines: 16th Annual Conference on Computational Learning Theory and 7th Kernel Workshop.join". ISBN: 978-3-540-40720-1. method = c("vi". "split. comm2 method Value A real number. "rand".). in the same format as for the previous argument.join". DC.communities compare.com> References Meila M: Comparing clusterings by the variation of information. Author(s) Tamas Nepusz <ntamas@gmail. the comparison method to use. The membership vector should contain the community id of each vertex.56 compare.rand")) Arguments comm1 A communities object containing a community structure.rand’ is the adjusted Rand index by Hubert and Arabie (1985). comm2. ‘split. Lecture Notes in Computer Science. the membership vector of the second community structure.join’ is the split-join distance of can Dongen (2000).communities Compares community structures using various metrics Description This function assesses the distance between two community structures. ‘nmi’ is the normalized mutual information measure proposed by Danon et al. USA. Warmuth MK (eds. the numbering of the communities starts with one. "split. In: Scholkopf B. or a numeric vector. "nmi". 2777. "adjusted. Character scalar. Washington. comm2. COLT/Kernel 2003. Possible values: ‘vi’ is the variation of information (VI) metric of Meila (2003). "rand". Usage ## S3 method for class ’communities’ compare(comm1. A communities object containing a community structure. 2003. ‘adjusted.rand")) ## S3 method for class ’numeric’ compare(comm1. (2005). "nmi". vol. . Springer. method = c("vi". the membership vector of the first community structure. or a numeric vector. ‘rand’ is the Rand index of Rand (1971). "adjusted.

Usage subcomponent(graph. membership(le)) components In. Diaz-Guilera A. 1985. Amsterdam. May 2000. Arenas A: Comparing community structure identification.community for various community detection methods. 1971.spinglass.famous("Zachary") sg <. either “in”. "in")) Arguments graph v mode The graph to analyze. See Also walktrap.community.leading. National Research Institute for Mathematics and Computer Science in the Netherlands. or the opposite: all vertices from which a given vertex is reachable via a directed path. Examples g <. If “all” returns the union of these.community. method="rand") compare(membership(sg). Character string.community(g) compare(sg. "out". Journal of Classification 2:193-218. Details A breadh-first search is conducted starting from vertex v. .or out. edge.betweenness. 2005. le.community(g) le <. Duch J. “out” or “all”.components 57 Danon L. If “out” all vertices reachable from v are returned. The vertex to start the search from.graph. J Am Stat Assoc 66(336):846850. If “in” all vertices from which v is reachable are listed.component of a vertex Description Finds all vertices reachable from a given vertex.eigenvector. van Dongen S: Performance criteria for graph clustering and Markov cluster experiments. Rand WM: Objective criteria for the evaluation of clustering methods. spinglass. v. mode = c("all".community. Technical Report INS-R0012. It is ignored for undirected graphs. Hubert L and Arabie P: Comparing partitions. fastgreedy. J Stat Mech P09008.

erdos.58 Value Numeric vector. of vertex i’s ego network Vi . The vertices for which the constraint will be calculated. If this is NULL and there is a weight edge attribute this is used. The weights of the edges. Ci . Usage constraint(graph.gabor@gmail.e. Author(s) Gabor Csardi <csardi. constraint is undefined. 1. the ids of the vertices in the same component as v. . Burt’s measure of constraint. more redundant) contacts. Ci = (pij + piq pqj )2 j ∈Vi \{i} q ∈Vi \{i. or mutually stronger related (i. the input graph. If there is no such edge attribute all edges will have the same weight. For isolated vertices. "in") subcomponent(g. nodes=V(graph).renyi.j } for a graph of order (ie. weights=NULL) Arguments graph nodes weights A graph object. number of vertices) N .com> See Also clusters Examples g <. k∈Vi \{i} (aik + aki ) aij are elements of A and the latter being the graph adjacency matrix. Details Burt’s constraint is higher if ego has less. 1. constraint calculates Burt’s constraint for each vertex. where proportional tie strengths are defined as aij + aji pij = . "all") ) constraint constraint Burt’s constraint Description Given a graph. Defaults to all vertices. 1/2 subcomponent(g. 1.game(1 . "out") subcomponent(g. is defined for directed and valued graphs.

contract.vertices Value A numeric vector of constraint scores Author(s) Jeroen Bruggeman <j.p.bruggeman@uva.nl> and Gabor Csardi <csardi.gabor@gmail.com> References

59

Burt, R.S. (2004). Structural holes and good ideas. American Journal of Sociology 110, 349-399. Examples
g <- erdos.renyi.game(2 , 5/2 ) constraint(g)

contract.vertices

Contract several vertices into a single one

Description This function creates a new graph, by merging several vertices into one. The vertices in the new graph correspond to sets of vertices in the input graph. Usage contract.vertices(graph, mapping, vertex.attr.comb=getIgraphOpt("vertex.attr.comb")) Arguments graph mapping The input graph, it can be directed or undirected.

A numeric vector that specifies the mapping. Its elements correspond to the vertices, and for each element the id in the new graph is given. vertex.attr.comb Specifies how to combine the vertex attributes in the new graph. Please see attribute.combination for details. Details The attributes of the graph are kept. Graph and edge attributes are unchanged, vertex attributes are combined, according to the vertex.attr.comb parameter. Value A new graph object.

60 Author(s) Gabor Csardi <csardi.gabor@gmail.com> Examples
g <- graph.ring(1 ) g$name <- "Ring" V(g)$name <- letters[1:vcount(g)] E(g)$weight <- runif(ecount(g)) g2 <- contract.vertices(g, rep(1:5, each=2), vertex.attr.comb=toString) ## graph and edge attributes are kept, vertex attributes are ## combined using the ’toString’ function. print(g2, g=TRUE, v=TRUE, e=TRUE)

conversion

conversion

Convert a graph to an adjacency matrix or an edge list

Description Sometimes it is useful to have a standard representation of a graph, like an adjacency matrix or an edge list. Usage get.adjacency(graph, type=c("both", "upper", "lower"), attr=NULL, edges=FALSE, names=TRUE, sparse=getIgraphOpt("sparsematrices")) get.edgelist(graph, names=TRUE) Arguments graph type The graph to convert. Gives how to create the adjacency matrix for undirected graphs. It is ignored for directed graphs. Possible values: upper: the upper right triangle of the matrix is used, lower: the lower left triangle of the matrix is used. both: the whole matrix is used, a symmetric matrix is returned. Either NULL or a character string giving an edge attribute name. If NULL a traditional adjacency matrix is returned. If not NULL then the values of the given edge attribute are included in the adjacency matrix. If the graph has multiple edges, the edge attribute of an arbitrarily chosen edge (for the multiple edges) is included. This argument is ignored if edges is TRUE. Note that this works only for certain attribute types. If the sparse argumen is TRUE, then the attribute must be either logical or numeric. If the sparse

attr

conversion

61 argument is FALSE, then character is also allowed. The reason for the difference is that the Matrix package does not support character sparse matrices yet.

edges names

Logical scalar, whether to return the edge ids in the matrix. For non-existant edges zero is returned. Logical constant. For graph.adjacenct it gives whether to assign row and column names to the matrix. These are only assigned if the name vertex attribute is present in the graph. for get.edgelist it gives whether to return a character matrix containing vertex names (ie. the name vertex attribute) if they exist or numeric vertex ids.

sparse

Logical scalar, whether to create a sparse matrix. The ‘Matrix’ package must be installed for creating sparse matrices.

Details get.adjacency returns the adjacency matrix of a graph, a regular R matrix if sparse is FALSE, or a sparse matrix, as defined in the ‘Matrix’ package, if sparse if TRUE. get.edgelist returns the list of edges in a graph. Value A vcount(graph) by vcount(graph) (usually) numeric matrix for get.adjacency. (This can be huge!) Note that a non-numeric matrix might be returned if attr is a non-numeric edge attribute. A ecount(graph) by 2 numeric matrix for get.edgelist. Author(s) Gabor Csardi <csardi.gabor@gmail.com> See Also graph.adjacency, read.graph Examples
g <- erdos.renyi.game(1 , 2/1 ) get.edgelist(g) get.adjacency(g) V(g)$name <- letters[1:vcount(g)] get.adjacency(g) E(g)$weight <- runif(ecount(g)) get.adjacency(g, attr="weight")

62

conversion between igraph and graphNEL graphs

conversion between igraph and graphNEL graphs Convert igraph graphs to graphNEL objects or back

Description The graphNEL class is defined in the graph package, it is another way to represent graphs. These functions are provided to convert between the igraph and the graphNEL objects. Usage igraph.from.graphNEL(graphNEL, name = TRUE, weight = TRUE, unlist.attrs = TRUE) igraph.to.graphNEL(graph) Arguments graphNEL name weight unlist.attrs The graphNEL graph. Logical scalar, whether to add graphNEL vertex names as an igraph vertex attribute called ‘name’. Logical scalar, whether to add graphNEL edge weights as an igraph edge attribute called ‘weight’. (graphNEL graphs are always weighted.) Logical scalar. graphNEL attribute query functions return the values of the attributes in R lists, if this argument is TRUE (the default) these will be converted to atomic vectors, whenever possible, before adding them to the igraph graph. An igraph graph object.

graph Details

igraph.from.graphNEL takes a graphNEL graph and converts it to an igraph graph. It handles all graph/vertex/edge attributes. If the graphNEL graph has a vertex attribute called ‘name’ it will be used as igraph vertex attribute ‘name’ and the graphNEL vertex names will be ignored. Because graphNEL graphs poorly support multiple edges, the edge attributes of the multiple edges are lost: they are all replaced by the attributes of the first of the multiple edges. igraph.to.graphNEL converts and igraph graph to a graphNEL graph. It converts all graph/vertex/edge attributes. If the igraph graph has a vertex attribute ‘name’, then it will be used to assign vertex names in the graphNEL graph. Otherwise igraph vertex ids will be used for this purpose. Value igraph.from.graphNEL returns an igraph graph object. igraph.to.graphNEL returns a graphNEL graph object. Author(s) Gabor Csardi <csardi.gabor@gmail.com>

convex.hull See Also get.adjacency, graph.adjacency, get.adjlist and graph.adjlist. Examples
## Undirected g <- graph.ring(1 ) V(g)$name <- letters[1:1 ] GNEL <- igraph.to.graphNEL(g) g2 <- igraph.from.graphNEL(GNEL) g2 ## Directed g3 <- graph.star(1 , mode="in") V(g3)$name <- letters[1:1 ] GNEL2 <- igraph.to.graphNEL(g3) g4 <- igraph.from.graphNEL(GNEL2) g4

63

convex.hull

Convex hull of a set of vertices

Description Calculate the convex hull of a set of points, i.e. the covering polygon that has the smallest area. Usage convex.hull(data) Arguments data Value A named list with components: resverts rescoords Author(s) Tamas Nepusz <ntamas@gmail.com> References Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0262032937. Pages 949955 of section 33.3: Finding the convex hull. The indices of the input vertices that constritute the convex hull. The coordinates of the corners of the convex hull. The data points, a numeric matrix with two columns.

Supply NA here if you don’t want to limit the number of components. clusters to calculate the connected components of a graph. The first max.vertices = ) Arguments graph mode max. max.64 Examples M <.renyi. mode = c("weak".game(1 . min. wither weak for weakly connected components or strong for strongly connected components. The minimum number of vertices a component should contain in order to place it in the result list. Examples # the diameter of each component in a random graph g <. Eg.vertices Value A list of graph objects. Usage decompose.erdos. min.graph(g.gabor@gmail. min.graph Decompose a graph into components Description Creates a separate graph for each component of a graph.connected to decide whether a graph is connected.cbind( runif(1 convex.graph(graph. supply 2 here to ignore isolate vertices. Character constant giving the type of the components. "strong"). see the next parameter).comps components will be returned (which hold at least min. 1/1 ) comps <.vertices vertices.graph decompose. runif(1 ) ) decompose. The maximum number of components to return.vertices=2) sapply(comps.comps The original graph.hull(M) ). Author(s) Gabor Csardi <csardi.com> See Also is.comps = NA. the others will be ignored. diameter) .decompose.

. loops = TRUE. “all” is a synonym of “total”. "out". For degree. Usage degree(graph. "total"). etc. For undirected graphs this argument is ignored. eg.game(1 degree. whether to normalize the degree. “in” for in-degree or “total” for the sum of the two. Additional arguments to pass to degree. Author(s) Gabor Csardi <csardi. The first element is the relative frequency zero degree vertices. whether the loop edges are also counted. 1 /1 ) . cumulative = FALSE. Logical. the second vertices with degree one. the number of its adjacent edges. where n is the number of vertices in the graph.. v=V(graph). Character string. Logical.renyi.) Arguments graph v mode The graph to analyze.distribution(g2) . .graph. Logical scalar. "in". mode is useful but also v and loops make sense..ring(1 ) degree(g) g2 <.com> Examples g <. mode = c("all".distribution a numeric vector of the same length as the maximum degree plus one..distribution(graph. The ids of vertices of which the degree will be calculated. normalized = FALSE) degree. Value For degree a numeric vector of the same length as argument v.degree 65 degree Degree and degree distribution of the vertices Description The degree of a vertex is its most basic structural property. “out” for out-degree. If TRUE then the result is divided by n − 1.erdos. loops normalized cumulative .gabor@gmail. whether the cumulative degree distribution is to be calculated.

deg method .game degree.. This generator always generates undirected. . The “vl” method is a more sophisticated generator. Character.sequence..game(out. the method for generating the graph.sequence. but tries to avoid multiple and loop edges and restarts the generation from scratch if it gets stuck. Additional arguments.66 degree.multiple” method is similar to “simple”. This is exactly what degree. For directed graphs its sum should be the same as the sum of in.deg = NULL. The “simple. method = c("simple". It is not guaranteed to sample uniformly from the space of all possible graphs with the given sequence.game Generate random graphs with a given degree sequence Description It is often useful to create a graph with given vertex degrees. See http://www-rp. the sequence of degrees (for undirected graphs) or out-degrees (for directed graphs). For directed graph. The “vl” samples from the undirected..game does.no. but then the degree sequence is distorted and there is nothing to ensure that the graphs are sampled uniformly. This method is not adequate if one needs to generate simple graphs with a given degree sequence. connected simple graphs.sequence. By default this is NULL and an undirected graph is created. Right now the “simple”. The algorithm and the implementation was done by Fabien Viger and Matthieu Latapy. "simple. This way loop edges and also multiple edges may be generated. but it is relatively fast and it will eventually succeed if the provided degree sequence is graphical. in.multiple” and “vl” methods are implemented.deg. Usage degree.fr/~latapy/FV/generation. For undirected graphs its sum should be even.no. Details The “simple” method connects the out-stubs of the edges (undirected graphs) or the out-stubs and in-stubs (directed graphs) together.lip6. the in-degree sequence.html for details. Finally a Monte-Carlo algorithm is used to randomize the graph. these are used as graph attributes. connected simple graphs unformly. it is an error to pass the in. Then some rewiring is done to make the graph connected. but there is no upper bound on the number of iterations.deg. "vl".sequence. in.deg argument to it.) Arguments out. . “simple.multiple").no. The algorithm relies on first creating an initial (possibly unconnected) simple undirected graph with the given degree sequence (if this is possible at all).deg Numeric vector.. The multiple and loop edges can be deleted.

sample(1:1 . barabasi.gabor@gmail. method="vl") all(degree(g4) == degs) ## Power-law degree distribution ## Note.1 degree(g3) is.game.sequence.game(degs.sequence. 1 . that we correct the degree sequence if its sum is odd degs <. mode="in") ## The vl generator g3 <. mode="out") degree(g2.dendPlot Value The new graph object. Author(s) Gabor Csardi <csardi.sample(1:1 . prob=(1:1 )^-2) if (sum(degs) %% 2 != ) { degs[1] <.sequence.degree. simplify to get rid of the multiple and/or loops edges. that we correct the degree sequence if its sum is odd degs <. 1 . .game(1:1 .com> See Also erdos. method="vl") ## Exponential degree distribution ## Note. replace=TRUE.degs[1] + 1 } g5 <.5*(1:1 ))) if (sum(degs) %% 2 != ) { degs[1] <.game(degs.sequence.renyi.game(rep(2.degree.degree.game(rep(2.degs[1] + 1 } g4 <.degree.simple(g3) # always TRUE 67 ).degree. method="vl") all(degree(g5) == degs) dendPlot Plot dendrograms Description This is generic function that can plot various objects as dendrograms. prob=exp(.1 )) degree(g) is. Examples ## The simple generator g <. 1 :1) degree(g2. replace=TRUE. but can be FALSE g2 <.simple(g) # sometimes TRUE.sequence..game.

graph. whether to use the modularity values to define the height of the branches.hclust from the stats package.. use. • phylo Use plot.type"). Details dendPlot supports three different plotting functions.communities Currently the function is defined for communities (see dendPlot.68 Details dendPlot.hclust is used. • hclust Use plot. mode = getIgraphOpt("dend...gabor@gmail. An object containing the community structure of a graph. Which dendrogram plotting function to use. that is choosen. As plot. .communities Community structure dendrogram plots Description Plot a hierarchical community structure as a dendrogram.plot.phylo is the most sophisticated. See communities for details.com> Examples karate <.plot. By default the plotting function is taken from the dend.famous("Zachary") fc <.communities) and igraphHRG (see dendPlot. and it has for possible values: • auto Choose automatically between the plotting functions. Author(s) Gabor Csardi <csardi. Additional arguments to supply to the dendrogram plotting function. See details below.type igraph option.community(karate) dendPlot(fc) dendPlot..phylo from the ape package.fastgreedy.. selected via the mode argument. use.igraphHRG) objects. . Otherwise plot. whenever the ape package is available.modularity = FALSE) Arguments x mode .modularity Logical scalar. Usage ## S3 method for class ’communities’ dendPlot(x.

the number of groups to mark on the dendrogram.. sub = "". • colbar The colors of the rectanges that mark the vertex groups via the rect argument. plot. end= .dendrogram from the stats package. • ann Whether to annotate the plot.. • edge. Set this to zero if you don’t want to mark any groups. the main argument of plot. • xlab The label on the horizontal axis. When using plot. start= .7.hclust. main = "".color Edge colors. mode="hclust". The dendrogram is cut into exactly rect groups and they are marked via the rect. passed to plot. .length Passed to plot. mode="phylo".. 69 The different plotting functions take different sets of arguments. this corresponds to the hang argument of plot.hclust. then the colbar argument is used.. • main The main title of the plot. we have the following syntax: dendPlot(x.phylo (mode="phylo"). • dots Attitional arguments to pass to plot.hclust (mode="hclust"): dendPlot(x. • sub The sub-title of the plot.hclust.. use. ann = FALSE.phylo.color = NULL. .phylo. • hang Where to put the leaf nodes. ylab = "". • ylab The label on the vertical axis.edge. The syntax for plot.communities • dendrogram Use plot. .hclust. rect = .) The extra arguments are simply passed to as. xlab = "".1).hclust.dendrogram or plot. The syntax for plot. colbar = rainbow(11.edge.hclust. passed to plot.) The extra arguments not documented above: • rect A numeric scalar.. Value Returns whatever the return value was from the plotting function.hclust. plot. . • use.hclust. colbar = rainbow(rect).) The extra arguments not documented above: • colbar Color bar for the edges. • dots Attitional arguments to pass to plot. the ann argument of plot.dendrogram (mode="dendrogram"): dendPlot(x. the sub argument of plot.phylo. 1.dendPlot.hclust command.length = FALSE. hang = . If NULL. edge.dendrogram.

edge.type igraph option. Details dendPlot supports three different plotting functions. See details below. a hierarchical random graph. Otherwise plot. • phylo Use plot.hclust is used. use. and it has for possible values: • auto Choose automatically between the plotting functions. Which dendrogram plotting function to use. edge. • hclust Use plot.famous("Zachary") fc <.phylo (mode="phylo").color = NULL. Additional arguments to supply to the dendrogram plotting function.fastgreedy. mode = getIgraphOpt("dend.) An igraphHRG. By default the plotting function is taken from the dend.fit function.type"). As plot.) Arguments x mode .1). mode="phylo". we have the following syntax: dendPlot(x..7.gabor@gmail. .. colbar = rainbow(11.community(karate) dendPlot(fc) dendPlot.com> Examples karate <. • dendrogram Use plot... Usage ## S3 method for class ’igraphHRG’ dendPlot(x. as returned by the hrg.dendrogram from the stats package.graph.phylo is the most sophisticated. end= .phylo from the ape package. . . start= .70 Author(s) Gabor Csardi <csardi.plot. The different plotting functions take different sets of arguments.hclust from the stats package.igraphHRG dendPlot.igraphHRG HRG dendrogram plot Description Plot a hierarchical random graph as a dendrogram. whenever the ape package is available.length = FALSE.plot. selected via the mode argument.. When using plot. that is choosen..

phylo.hclust.hclust (mode="hclust"): dendPlot(x. • ylab The label on the vertical axis. 71 The syntax for plot.edge. The syntax for plot. hang = .length Passed to plot.hclust.phylo. the main argument of plot.dendrogram or plot.com> Examples g <.gabor@gmail. • colbar The colors of the rectanges that mark the vertex groups via the rect argument.) The extra arguments are simply passed to as. ylab = "". Value Returns whatever the return value was from the plotting function. Set this to zero if you don’t want to mark any groups.igraphHRG The extra arguments not documented above: • • • • colbar Color bar for the edges. 1. main = "". then the colbar argument is used. passed to plot.graph.hclust. dots Attitional arguments to pass to plot.color Edge colors.full(5) + graph. colbar = rainbow(rect). Author(s) Gabor Csardi <csardi. passed to plot. • xlab The label on the horizontal axis.. mode="hclust".full(5) hrg <. • main The main title of the plot.hclust. .hrg. The dendrogram is cut into exactly rect groups and they are marked via the rect. the number of groups to mark on the dendrogram.hclust.dendPlot.) The extra arguments not documented above: • rect A numeric scalar.hclust.. the sub argument of plot. • dots Attitional arguments to pass to plot.hclust command. the ann argument of plot. plot. .dendrogram (mode="dendrogram"): dendPlot(x. ann = FALSE. edge. xlab = "".dendrogram.fit(g) dendPlot(hrg) .hclust. If NULL.hclust. • ann Whether to annotate the plot..phylo. plot. use. rect = .. • hang Where to put the leaf nodes. • sub The sub-title of the plot. sub = "". this corresponds to the hang argument of plot.

points returns two vertex ids. If FALSE. Value A numeric constant for diameter. whether directed or undirected paths are to be considered.com> See Also shortest.72 diameter diameter Diameter of a graph Description The diameter of a graph is the length of the longest geodesic. If the graph has a weight edge attribute. which is always the number of vertices. Logical.paths . the vertices which are connected by the diameter path. directed = TRUE. directed = TRUE. unconnected = TRUE.nodes (graph. a numeric vector for get. then this is used by default. directed = TRUE. weights Details The diameter is calculated by using a breadth-first search like method. This is ignored for undirected graphs. unconnected = TRUE. If there are many shortest paths of the length of the diameter. weights = NULL) farthest. the diameters of the connected components will be calculated and the largest one will be returned. weights = NULL) Arguments graph directed unconnected The graph to analyze. If TRUE. weights = NULL) get.gabor@gmail. Logical. the function will return a number that is one larger the largest possible diameter.diameter returns a path with the actual diameter. unconnected = TRUE.diameter and a numeric vector of length two for farthest. Usage diameter(graph.nodes. Author(s) Gabor Csardi <csardi. Optional positive weight vector for calculating weighted distances.diameter (graph. get. farthest. then it returns the first one found. what to do if the graph is unconnected.

. unconnected=FALSE) ## Weighted diameter set. For details see the reference below.seed(1) g <. Vertex v is the immediate dominator or w. called the dominator tree of the graph. weights=NA) get.graph.edges(g. root. Usage dominator. there is a path from r to v . root mode Details A flowgraph is a directed graph with a distinguished start (or root) vertex r.tree (graph. mode = c("out". and it contains some vertices not reachable from the root vertex. Vertex v dominates vertex w if and only if v is an ancestor of w in the dominator tree.diameter(g) diameter(g.tree Examples g <. "in")) Arguments graph A directed graph.dominator. if v dominates w and every other dominator of w dominates v . This function implements the Lengauer-Tarjan algorithm to construct the dominator tree of a directed graph.ring(1 ) E(g)$weight <.1 )) diameter(g2. If it is not a flowgraph.graph.2. If it is ‘in’. v = idom(w). c(1. The id of the root (or source) vertex. then all directions are considered as opposite to the original one in the input graph. unconnected=TRUE) diameter(g2. must be ‘in’ or ‘out’.1.ring(1 ) g2 <. The edges (idom(w).tree Dominator tree Description Dominator tree of a directed graph. weights=NA) 73 dominator. rooted at r. if every path from r to w contains v . A vertex v dominates another vertex w (not equal to v ). w)|w = r form a directed tree.diameter(g.sample(seq_len(ecount(g))) diameter(g) get. then these vertices will be collected and returned as part of the result. Constant. such that for any vertex v .delete. this will be the root of the tree.

-layout[.igraph. For vertices that are unreachable from the root.74 Value A list with components: dom Drawing graphs A numeric vector giving the immediate dominators for each vertex. C-+F:G. domtree leftout Author(s) Gabor Csardi <csardi.tree(g. H-+E:K. the dominator tree. A-+D.reingold.dominator. A graph object.tilford(dtree$domtree. Examples ## The example from the paper g <. it contains NaN. tkplot and rglplot are discussed in this manual page Details There are currently three different functions in the igraph package which can draw graph in various ways: plot.graph. For the root vertex itself it contains minus one. root="R") layout[. vertex.igraph does simple non-interactive 2D plotting to R devices. 121–141. J-+I. As it used the standard R devices it supports every output format for which R has an output device. Isolate vertices are the ones that are unreachable from the root. Its vertex ids are the as the vertex ids of the input graph.gabor@gmail. I-+K. Actually it is an implementation of the plot generic function.2] if (interactive()) { plot(dtree$domtree. G-+I:J. E-+H. Robert Endre Tarjan: A fast algorithm for finding dominators in a flowgraph. L-+H) dtree <.2] <.com> References Thomas Lengauer.igraph(graph).label=V(dtree$domtree)$name) } Drawing graphs Drawing graphs Description The common bits of the three plotting functions plot. 1979. so you can write plot(graph) instead of plot. A numeric vector containing the vertex ids that are unreachable from the root. B-+A:D:E.formula(R-+A:B:C. K-+I:R. D-+L.layout. layout=layout. root="R") layout <. F-+I. . ACM Transactions on Programming Languages and Systems (TOPLAS) I/1.

edge and graph attributes to the graph.’ prefix needs to be added if they are used as an argument or when setting via igraph. . and you also don’t need to assign vertex/edge attributes to every graph. Some parameters of the plotted graph can be changed interactively after issuing the tkplot command: the position. the color of the vertices can be given via argument vertex. tkplot does interactive 2D plotting using the tcltk package. . whereas edge. color and size of the vertices and the color and width of the edges. in section ’Parameters’.options. general parameters like layout are prefixed with ‘plot’.graph. It is however always true that the parameter can always be a function object in which it will be called with the graph as its single argument to get the “proper” value of the parameter. SVG files.) . so the graph will have the same look after loading it again. PNG and of course you can plot to the screen as well using the default devices. The value of the parameter may be scalar valid for every vertex or a vector with a separate value for each vertex. These attributes have now prefix. Vertex parameters have prefix ‘vertex.’. See plot. vertex size. rglplot is an experimental function to draw graphs in 3D using OpenGL. or the good-looking anti-aliased Cairo device.Drawing graphs 75 The list is quite impressing: PostScript. the color of the vertices is taken from the color vertex attribute and the color of the edges from the color edge attribute. Different types are valid for different parameters.’.igraph. edge parameters are prefixed with ‘edge. vertex color. parameters for edges have prefix ‘edge. The first method is to supply named arguments to the plotting commands: plot. The second way is to assign vertex. PDF files. (If the function returns another function object that will not be called again. this is discussed in detail in the next section. or as an integer vector with the color numbers from the current palette. If a parameter is not given in the command line. XFig files.color sets the color of the edges. See tkplot for details. JPG. (Shorter vectors are recycled. and the corresponding vertex/edge/graph attribute is also missing then the general igraph parameters handled by igraph. The layout of the graph is given by the layout graph attribute. note that the ‘vertex.’. layout gives the layout of the graphs. It can only handle graphs of moderate size. Please also check the examples below. Parameters for vertices start with prefix ‘vertex. its default valued is used. How to specify graphical parameters There are three ways to give values to the parameters described below.igraph for some more information. We give these three ways here in the order of their precedence. attributes are saved with the graph is you save it with save or in GraphML format with write. etc. If the value of a parameter is not specified by any of the three ways described here. Different parameters can have different type. tkplot or rglplot.) Setting vertex and edge attributes are handy if you want to assign a given ‘look’ to a graph. vertex colors can be given as a character vector with color names. Eg. as given in the source code. ie. See rglplot for some more information. These parameters are useful if you want all or most of your graphs to have the same look.options are also checked. Then you don’t need to set these at every plotting. ) The list of parameters Vertex parameters first. eg. (Always assuming that the corresponding command argument is not present.’.color. and global parameters have no prefix. a thousend vertices is probably already too many.

shapes for details about vertex shapes and vertex. they interpret this parameter different ways. If this parameter is the name of an exixting Tk font. Helvetica or Courier fonts are used. The default value is ‘serif’. The default is 15.cex parameters are also passed to tkfont. It does not need to be an integer number. sans.font and label. See dev.pie for using pie charts as vertices. “vrectangle”. If it is one of the base families (serif. . label The vertex labels. color The fill color of the vertex. By default it is “black”.shape.create and hope the user knows what she is doing. The label. supply NA as the color name. Note that tkplot ignores the fourth byte (alpha channel) in the RGB color specification. “pie” (see vertex. By default vertices are drawn as circles.76 Drawing graphs size The size of the vertex.cex parameters are ignored complerely. See igraph. however. size2 The “other” size of the vertex. “crectangle”. All strings starting with ‘#’ are assumed to be RGB color specifications. shape The shape of the vertex. there are guaranteed to exist on all systems.vertex. For the ‘symbol’ base family we used the symbol font is available. label. whereas size gives the width. in the latter case each vertex sizes may differ. “rectangle”. a numeric scalar or vector. frame.family The font family to be used for vertex labels. ‘sphere’. the same formats are allowed as for the fill color. If it is numeric then the current palette is used.create in this case. If you don’t want vertices to have a frame. The “sphere” vertex shape plots vertices as 3D ray-traced spheres. On some devices raster transparency is not supported and the spheres do not have a transparent background. If you don’t want (some) vertices to have any color. supply NA as the color name. For the various rectangle shapes this gives the height of the vertices. For plot.shape. They will be converted to character. If it is a character vector then it may either contain named colors or RGB specified colors with three or four bytes. although vertex label are plotted (if given). “csquare”. If the parameter is not a name of the base families and it is also not a named Tk font then we pass it to tkfont. For tkplot some conversion is performed. It is ignored by shapes for which the size can be specified with a single number. understood by both plot. rglplot does not support fonts at all right now.capabilities and the ‘rasterImage’ capability to check that your device is supported. Specify NA to omit vertex labels.pie).font and label. for some vertex shapes. This is big enough to place short labels on vertices. currently “circle”. It is possible to mix named color and RGB colors. “none” does not draw the vertices at all. The basic notation is.igraph command.igraph this parameter is simply passed to text as argument family.igraph and tkplot. otherwise the first font which has ‘symbol’ in its name. “square”. The default value is “SkyBlue2”. see palette. This vertex sizes are scaled in order have about the same size of vertices for a given value for all three plotting commands. mono) then Times.color The color of the frame of the vertices. The default vertex labels are the vertex ids. The default value is 15. it ignores this parameter completely. This produces a raster image and it is only supported with some graphics devices. and “none” are supported. in the given color and size. then that font is used and the label. As different plotting commands can used different fonts. and only by the plot.

For rglplot it is ignored. This argument is currently only used by plot.options. By default this parameter is darkgrey. It is interpreted as a multiplication factor of some devicedependent base font size. The default value is 1. For plot. label.’ prefix when used as arguments or set by igraph. see the color vertex parameter for the possible values. and ‘pi’ means to the left. The base font is thus 12 for tkplot. if this is taken from an edge attribute then only the attribute of the first edge is used for all arrows. Edge parameters require to add the ‘edge. 4 is bold and italic and 5 specifies the symbol font. width The width of the edges.igraph this parameter is simply passed to text. For tkplot it is multiplied by 12 and then used as the size argument for tkfont.create. This will likely change in the future. The default value is 1. The default value is black. zero means ‘to the right’. This will likely change in the future.degree It defines the position of the vertex labels.cex The font size for vertex labels. The default value is 1. It is interpreted as an angle in radian. If it is 0 then the label is centered on the vertex.dist The distance of the label from the center of the vertex. up is -pi/2 and down is pi/2. . ie.width The width of the arrows. Otherwise it is ignored. For plot. The default value is -pi/4. 3 is italic. The default value is 1. label. if the label. Currently this is a constant. If a vector is submitted then only the first element is used. arrow. label. if this is taken from an edge attribute then only the attribute of the first edge is used for all arrows.size The size of the arrows. so it is the same for every edge. ie. The default value is 1.igraph it is simply passed to text as argument cex. It is interpreted the same way as the the font graphical parameter: 1 is plain text. For rglplot it is ignored.color The color of the labels.Drawing graphs 77 label. label. arrow. If a vector is submitted then only the first element is used. If it is 1 then the label is displayed beside the vertex. 2 is bold face.family parameter is not the name of a Tk font then this parameter is used to set whether the newly created font should be italic and/or boldface.font The font within the font family to use for the vertex labels. so it is the same for every edge. The edge parameters: color The color of the edges.igraph. Currently this is a constant. see the color vertex parameter discussed earlier for the possible values. relative to the center of the vertices. The default value is 0. which gives the same width as before this option appeared in igraph. For tkplot.

This can be a logical or a numeric vector or scalar. This function makes sure that multiple edges are curved and are all visible. label. a solid line. the other possible values are: 2 (“dashed”). 5 (“longdash”). label. because as of version 0. this parameter can be a vector or a scalar value. ie. curved Specifies whether to draw curved edges.color The color of the edge labels. . If this parameter is given by the user (in either of the three ways) then it specifies which edges will have forward. an arrow will be drawn for each edge. and for directed graphs. See the corresponding vertex parameter discussed earlier for details. Almost the same format is accepted as for the standard graphics par.family Font family of the edge labels. see the color vertex parameters on how to specify colors. zero curvature means straight edges. Hint: this parameter can be used as a ‘cheap’ solution for drawing “mixed” graphs: graphs in which some edges are directed some are not. If it is a character vector then “<” and “<-” specify backward. If it is integer then 0 means no arrows. or no arrows at all. loop. or both.mode This parameter can be used to specify for which edges should arrows be drawn. As usual.5. It can be an integer or character type. negative values means the edge bends clockwise. tkplot also accepts standard Tk line type strings. See the label. label. no arrows will be drawn for undirected graphs. perhaps you should use “-” or “–” to specify no arrows. label. according to its direction. then please create a directed graph. This parameter is ignored for loop edges. This argument is ignored for rglplot. The default value is type 1. By default the vector specifying the curvatire is calculated via a call to the autocurve. 4 (“dotdash”). it is the expected behavior. 6 (“twodash”). 1 means backward arrows. FALSE means curvature zero. label The edge labels. “>” and “->” forward arrows and “<>” and “<->” stands for both arrows.cex The font size for the edge labels. By default. arrow. backward arrows.4 the vertex pairs in the edge lists can be swapped in undirected graphs. solid lines will be drawn. Then it is interpreted for each edge separately. They will be converted to character. or not. This is not very surprising. This parameter is currently ignored by rglplot.edges function. If you want do this. The default value is FALSE. Specify NA to omit edge labels. 1 and “solid” are for solid lines. A numeric value specifies the curvature of the edge. 2 is for forward arrows and 3 for both. TRUE means curvature 0. The default value is 0. see the corresponding vertex parameter for details.angle Gives the angle in radian for plotting loop edges. instead of type ‘0’ type ‘1’. 0 and “blank” mean no edges.dist vertex parameter to see how this is interpreted. All other values mean no arrows. First the vector is replicated to have the same length as the number of edges in the graph. 3 (“dotted”).78 Drawing graphs lty The line type for the edges. Edge labels are omitted by default. See the vertex parameter with the same name for the details. positive values the opposite. it does not however support “blank” lines.font The font for the edge labels.

over. rglplot does not support this parameter.5 are meaningful.angle is enough in 2D. asp A numeric constant. and it can also have third column. It specifies how the vertices will be placed on the plot. a function returning with 2D random placement.random. all default parameters. specifying its coordinates. This is only used in 3D.angle2 Gives the second angle in radian for plotting loop edges.1]) interval. Author(s) Gabor Csardi <csardi. If it is shorter than four then it is recycled. Its default value is 0.1](x[-1. If it is a numeric matrix. whether to rescale the coordinates to the [-1. This parameter is not implemented for tkplot.Drawing graphs 79 loop. For the 2D plots the third column is ignored. It is ignored by tkplot and rglplot. Defaults to TRUE. except the layout . this function will be called with the graph as the single parameter to determine the actual coordinates. Supply 0 here if you don’t want to give an aspect ratio. rescale Logical constant. for the x and y coordinates.igraph. If a two column matrix is given for the 3D plotting function rglplot then the third column is assumed to be 1 for each vertex. The function should return a matrix with two or three columns. it gives the asp parameter for plot. The default value is layout. rglplot.1]x[-1. at the left and right of the plot. the aspect ratio. it is a numeric vector of length four. Defaults to 1. Other parameters: layout Either a function or a numeric matrix. igraph. margin The amount of empty space below. this will be the z coordinate for 3D plots and it is ignored for 2D plots. whether to plot a frame around the graph. Defaults to FALSE.gabor@gmail. that will make the plot zoom in to a part of the graph. ie. If layout is a function. then the matrix has to have one line for each vertex. The matrix should have at least two columns. the layout will be rescaled. It is ignored by tkplot and rglplot.options Examples ## Not run: # plotting a simple ring graph. Usually values between 0 and 0. as it can zoom in and out the graph in a more flexible way. tkplot. frame Boolean.com> See Also plot. but negative values are also possible. loop. The default value is 0.

tree(5 .com$membership+1 g <. edge. The relationship between each pair of vertices is measured.full(5) g <.full(5) %du% graph. vertex.tree(2 .game(1 .label.5.label=NA) tkplot(graph.graph.color="red". layout=layout.fruchterman. vertex.reingold.layout=layout.ring(1 ) g$layout <.reingold.label=NA) # plot communities in a graph g <.label.dist=1. layout. vertex. vertex.size=5. layout=layout. .kawai(g)) plot(g.census dyad.fruchterman.5) # plot a random graph.spinglass. vertex.barabasi.census(graph) Arguments graph The input graph.size=4.arrow. mode="undirected").kamada.community(g. .renyi. vertex.size=1 .tilford) plot(graph.clusters(g)$membership colbar <. A warning is given if it is not directed. "layout". different color for each component g <.color="green") ## End(Not run) dyad. fix layout igraph. 2)) plot(graph.circle plot(g) tkplot(g) rglplot(g) # plotting a random graph. c( .options(plot. It can be in three states: mutual.5) # draw a bunch of trees.rainbow(max(comps)+1) V(g)$color <. set the parameters in the command arguments g <.80 g <.graph.erdos.full(5) %du% graph. vertex. vertex.game(1 ) plot(g. 2.5. 5.1 .reingold.graph.tree(5 . vertex.attribute(g.census Dyad census of a graph Description Classify dyads in a directed graphs.size=3. vertex. spins=5) V(g)$color <.1 )) com <. 1/1 ) comps <. Usage dyad. asymmetric or non-existent.add.set.layout.colbar[comps+1] plot(g.dist= . 3).edges(g.size= .

The vertices for which the eccentricity is calculated. "total")) Arguments graph vids mode The input graph. "total")) radius(graph. Cambridge: Cambridge University Press. This argument is ignored for undirected graphs. gives whether the shortest paths to or from the given vertices should be calculated for directed graphs. If all. but with triples. "in". then the corresponding undirected graph will be used. The number of pairs with non-mutual connections. Social Network Analysis: Methods and Applications. "out". 1970. K. American Journal of Sociology. mode=c("all". S. and Leinhardt. If out then the shortest paths from the vertex. and Faust. if in then to it will be considered. edge directions will be ignored.census for the same classification. A Method for Detecting Structure in Sociometric Data. vids=V(graph).census(g) ) eccentricity Eccentricity and radius Description The eccentricity of a vertex is its shortest path distance from the farthest other node in the graph.com> References The number of pairs with mutual connections. 492–513. the default. P. 81 Holland.gabor@gmail. 1994. S. Wasserman. "out". mode=c("all". it can be directed or undirected. The smallest eccentricity in a graph is called its radius Usage eccentricity(graph.game(1 dyad. See Also triad. Examples g <. The number of pairs with no connection between them. .ba.eccentricity Value A named numeric vector with three elements: mut asym null Author(s) Gabor Csardi <csardi.W. 76. Character constant.. "in".

82 Details edge. containing the eccentricity score of each given vertex.community Community structure detection based on edge betweenness Description Many networks consist of modules which are densely connected themselves but sparsely connected to other modules. Value eccentricity returns a numeric vector. This implementation ignores vertex pairs that are in different components.betweenness = TRUE. to (or from) all vertices in the graph. See Also shortest. membership = TRUE) .betweenness.paths for general shortest path calculations. 35. Usage edge. bridges = TRUE. 1994.community The eccentricity of a vertex is calculated by measuring the shortest distance from (or to) the vertex. F.com> References Harary.star(1 . mode="undirected") eccentricity(g) radius(g) edge. modularity = TRUE. Graph Theory. Isolate vertices have eccentricity zero. Reading. Examples g <.gabor@gmail. weights = E(graph)$weight.graph. and taking the maximum. MA: Addison-Wesley. Author(s) Gabor Csardi <csardi. edge. radius returns a numeric scalar.betweenness. directed = TRUE. p.betweenness. merges = TRUE.community (graph.

individual vertices. The leafs of the tree are the individual vertices and the root of the tree represents the whole graph.betweenness. then recalculating edge betweenness of the edges and again removing the one with the highest score. whether to calculate the maximum modularity score.community returns a communities object.betweenness for details.betweenness. Supply NULL to omit edge weights. 83 The edge weights. the number of vertices in the graph. Logical constant.edge. There is one line for each merge (i. edge. Logical constant. removing the edge with the highest edge betweenness score. ie. Logical constant. This argument is called merges. etc. Value edge. It is ignored for undirected graphs. The idea of the edge betweenness based community structure detection is that it is likely that edges connecting separate modules have high edge betweenness as all the shortest paths from one module to another must traverse through them. if it is present. called a dendrogram of the graph. split) in matrix.community Arguments graph weights directed The graph to analyze. belong to singleton communities. edge. the second merge creates community N + 2. edge.betweeness. whether to return a list the edge removals which actually splitted a component of the graph. a rooted tree. whether to return the edge betweenness of the edges at the time of their removal. See the return value down here. bridges modularity membership Details The edge betweenness score of an edge measures the number of shortest paths through it. whether to calculate directed edge betweenness for directed graphs. the first line of the matrix creates community N + 1. etc. Before the first merge we have N communities numbered from one to N .betweenness. even if the community structure algorithm itself is divisive and not agglomerative: it builds the tree from top to bottom. please see the communities manual page for details. The first merge. whether to calculate the membership vector corresponding to the highest possible modularity score. the first line is the first merge (last split).community returns various information collected throught the run of the algorithm. . Community ids smaller than or equal to N . see edge. whether to return the merge matrix representing the hierarchical community structure of the network.e. So if we gradually remove the edge with the highest edge betweenness score we will get a hierarchical map.community performs this algorithm by calculating the edge betweenness of the graph.betweenness Logical constant. merges Logical constant. The communities are identified by integer number starting from one. Logical constant. By default the ‘weight’ edge attribute is used. considering all possibly community structures along the edge-betweenness based edge removals.

gabor@gmail. target=NULL. Usage edge. checks=TRUE) edge. this is recently also called group adhesion. The id of the target vertex.full(1 ) %du% graph. c(1.community(g) eb edge. for edge. Description The edge connectivity of a graph or two vertices.connectivity M Newman and M Girvan: Finding and evaluating community structure in networks. leading.edges(g. Physical Review E 69.eigenvector.84 Author(s) Gabor Csardi <csardi. for edge. Examples g <.community(g) g <. walktrap.barabasi.full(1 ) g <.connectivity Edge connectivity.11)) eb <.graph.connectivity(graph. checks=TRUE) Arguments graph source target The input graph.connectivity it can be NULL.community.m=2) eb <.betweenness. source.connectivity it can be NULL. target) graph.adhesion(graph.edge.betweenness for the definition and calculation of the edge betweenness. see details below.edge. The id of the source vertex.community for other community detection methods.game(1 .com> References edge. see details below. . fastgreedy. See communities for extracting the results of the community detection.community.betweenness.disjoint. source=NULL. 026113 (2004) See Also edge.add.paths(graph.

more precisely the most general is edge. They were suggested by Peter McMahan.maxflow.connectivity calculates this quantity if both the source and target arguments are given (and not NULL).com> References Douglas R. vertex. The three functions documented on this page calculate similar properties. as they can be done quickly compared to the connectivity calculation itself.cohesion Examples g <. Value A scalar real value. edge. Author(s) Gabor Csardi <csardi.barabasi. 1 . A set of edge disjoint paths between two vertices is a set of paths between them containing no common edges. The adhesion of a graph is the minimum number of edges needed to remove to obtain a graph which is not strongly connected. TODO: citation See Also graph.connectivity(g2.game(1 .connectivity(g.paths(g2. This is the same as the edge connectivity of the graph. vertex.edge. 1) edge. they are both NULL). Details The edge connectivity of a pair of vertices (source and target) is the minimum number of edges needed to remove to eliminate all (directed) paths from source to target.connectivity checks 85 Logical constant. 1 . It is a good idea to perform these checks. the others are included only for having more descriptive function names. 1 . m=1) g2 <. graph.game(1 . If the graph is not (strongly) connected then the connectivity is obviously zero. Otherwise if the minimum degree is one then the edge connectivity is also one. thanks Peter.barabasi. edge.connectivity. 1) .disjoint. m=5) edge.connectivity calculates this quantity if neither the source nor the target arguments are given (ie. 1) edge.connectivity. The edge connectivity of a graph is the minimum of the edge connectivity of every (ordered) pair of vertices in the graph. Whether to check that the graph is connected and also the degree of the vertices.paths. White and Frank Harary: The cohesiveness of blocks in social networks: node connectivity and conditional density.gabor@gmail.disjoint. The maximum number of edge disjoint paths between two vertices is the same as their edge connectivity.

Logical. The type of the random graph to create. . or the number of edges in the graph (for G(n. subcomponent(g. 1)) graph.induced.p) graphs. "gnm").or.p) graph) or gnm (G(n. whether the graph will be directed.m.) Arguments n p. either gnp (G(n.or. In G(n. loops = FALSE. ignored. defaults to FALSE. 5/5 ) g <.renyi. random. Value A graph object. type=c("gnp".directed(g) g <. the graph has ‘n’ vertices and for each edge the probability that it is present in the graph is ‘p’.subgraph(g. Author(s) Gabor Csardi <csardi. Logical.. p.m) graph).adhesion(g) erdos... defaults to FALSE.p) graph). whether to add loop edges.game is an alias to this function. Details In G(n.86 g <.game erdos. directed = FALSE.renyi.. .m) graphs. Additional arguments.erdos.renyi. and the ‘m’ edges are chosen uniformly randomly from the set of all possible edges.renyi.game(n.com> The number of vertices in the graph. Either the probability for drawing an edge between two arbitrary vertices (G(n. This set includes loop edges as well if the loops parameter is TRUE.game(5 .as. the graph has ‘n’ vertices and ‘m’ edges.graph. every possible edge is created with the same constant probability. Usage erdos.m type directed loops .m) graphs).game Generate random graphs according to the Erdos-Renyi model Description This model is very simple.gabor@gmail.

This argument can be used to give edge weights for calculating the weighted eigenvector centrality of vertices. 290–297 (1959). Logical scalar.renyi.. weights = NULL. A. even if the graph has a weights edge attribute. Note that if there are negative edge weights and the direction of the edges is considered. If this is NA. then no edge weights are used (even if the graph has a weight edge attribute. whether to scale the result to have a maximum score of one. If no scaling is used then the result vector has unit length in the Euclidean norm. Publicationes Mathematicae 6. and Renyi.erdos. scale = TRUE. whether to consider direction of the edges in directed graphs. options . Logical scalar.game(1 degree.arpack.evcent References Erdos. On random graphs. A numerical vector or NULL. A named list.game Examples g <. See Also barabasi. If weights is a numerical vector then it used. In this case only the real part is reported. It is ignored for undirected graphs.default) Arguments graph directed scale weights Graph to be analyzed. See arpack for details. then the eigenvector might be complex. 1/1 ) 87 evcent Find Eigenvector Centrality Scores of Network Positions Description evcent takes a graph (graph) and returns the eigenvector centralities of positions v within it Usage evcent (graph. If this is NULL and the graph has a weight edge attribute then that is used. P. options = igraph.distribution(g) . to override some ARPACK options. directed = FALSE.

WARNING evcent will not symmetrize your data before extracting eigenvectors.) From igraph version 0. Butts <buttsc@uci. in turn.graph. 1170-1182. i. A named list. see arpack for more about ARPACK in igraph. these scores may. The eigenvalue corresponding to the calculated eigenvector. don’t send this routine asymmetric matrices unless you really mean to do so. Power and Centrality: A Family of Measures. In general. be interpreted as arising from a reciprocal process in which the centrality of each actor is proportional to the sum of the centralities of those actors to whom he or she is connected. directed=FALSE) #Compute eigenvector centrality scores evcent(g) . American Journal of Sociology. Examples #Generate some test data g <. information about the underlying ARPACK computation. See arpack for the details.gabor@gmail. This is also intelligible from an algebraic point of view. in turn. with the first eigenvector being closely related to the best rank-1 approximation of the adjacency matrix (a relationship which is easy to see in the special case of a diagonalizable symmetric real matrix via the SLS − 1 decomposition).e. (The perceptive may realize that this implies that the largest values will be obtained by individuals in large cliques (or high-density substructures). P.88 Details evcent Eigenvector centrality scores correspond to the values of the first eigenvector of the graph adjacency matrix. the centrality scores. 92.5 this function uses ARPACK for the underlying computation. Value A named list with components: vector value options A vector containing the centrality scores. (1987). vertices with high eigenvector centralities are those which are connected to many other vertices which are.edu> for the manual page References Bonacich. connected to many others (and so on).com> and Carter T. Author(s) Gabor Csardi <csardi.ring(1 .

C Moore: Finding community structure in very large networks.community Community structure via greedy optimization of modularity Description This function tries to find dense subgraph. http://www. weights=E(graph)$weight) Arguments graph merges modularity membership The input graph Logical scalar. Author(s) Tamas Nepusz <ntamas@gmail.community(graph. If not NULL. then all edges are considered to have the same weight. please see the communities manual page for details. If it is not present. then a numeric vector of edge weights. References A Clauset.community returns a communities object. see A Clauset. Usage fastgreedy. whether to calculate the membership vector corresponding to the maximum modularity score. By default the ‘weight’ edge attribute is used as weights. Logical scalar. http://www. considering all possible community structures along the merges.com> for the R interface.community 89 fastgreedy.org/abs/cond-mat/0408187 for the details.org/abs/condmat/0408187 . Logical scalar. also called communities in graphs via directly optimizing a modularity score. weights Details This function implements the fast greedy modularity optimization algorithm for finding community structure. whether to return a vector containing the modularity after each merge. MEJ Newman.com> and Gabor Csardi <csardi.fastgreedy. Value fastgreedy. membership=TRUE.arxiv.arxiv. merges=TRUE. MEJ Newman. modularity=TRUE.gabor@gmail. The length must match the number of edges in the graph. C Moore: Finding community structure in very large networks. whether to return the merge matrix.

fire. Usage forest. observed in real networks: • Heavy-tailed in-degree distribution. according to a power-law rule. • Communities.11.game See also walktrap.full(5) g <.6.eigenvector. which resembles of how the forest fire spreads by igniting trees close by.community. The number of ambassador vertices.90 See Also communities for extracting the results.add. The forward burning probability.full(5) %du% graph.community and edge.full(5) %du% graph. • Heavy-tailed out-degree distribution. The network is densifying in time. leading. 11)) fc <.fire.fastgreedy. 6. The diameter of the network decreases in time. directed = TRUE) Arguments nodes fw. • Shrinking diameter. c(1.prob.community. The backward burning probability is calculated as bw.fire. forest.community for other methods. fw.factor ambs directed Details The forest fire model intends to reproduce the following network characteristics.betweenness. bw. whether to create a directed graph. • Densification power-law.game (nodes.prob. The backward burning ratio.factor = 1. Examples g <. . see details below. Logical scalar.game Forest Fire Network Model Description This is a growing network model. The number of vertices in the graph. 1.graph.edges(g.factor*fw. ambs = 1.community(g) membership(fc) sizes(fc) forest.prob bw. spinglass.

One vertex is added at a time. from those which are not yet cited by the new vertex.forest.prob.com> References Jure Leskovec.game(1 . for each cited vertex v we do the following procedure: 1. Jon Kleinberg and Christos Faloutsos. possibly directed if the directed argument is TRUE. dd1.cmu.37) dd1 <. shrinking diameters and possible explanations.) The new vertex cites x outgoing neighbors and y incoming neighbors of v .factor. bw. dd2. If there are less than x or y such vertices available then we cite all of them. our implementation is based on this. The same procedure is applied to all the newly cited vertices.gabor@gmail.37. x and y . log="xy") points(seq(along=dd2)-1. 2. We generate two random number.game for the basic preferential attachment model.game 91 The network is generated in the following way. Value A simple graph.prob= .degree. fw. KDD ’05: Proceeding of the eleventh ACM SIGKDD international conference on Knowledge discovery in data mining. Author(s) Gabor Csardi <csardi. Note The version of the model in the published paper is incorrect in the sense that it cannot generate the kind of graphs the authors claim. that are geometrically distributed with means p/(1 − p) and rp(1 − rp). pch=2) } .fire.factor= .cs. Graphs over time: densification laws.degree.pdf.forest.edu/ ~jure/pubs/powergrowth-tkdd. mode="out") if (interactive()) { plot(seq(along=dd1)-1. 177–187. This vertex connects to (cites) ambs vertices already present in the network. col=2. chosen uniformly random. Now. mode="in") dd2 <.distribution(g. Examples g <.32/ . See Also barabasi.distribution(g. r is bw. 2005. (p is fw.fire. A corrected version is available from http://www.

This argument is ignored for undirected graphs. which include the ids of adjacent edgs (according to the mode argument) of all vertices. Author(s) Gabor Csardi <csardi. "total")) get. either for adjacent edges or for neighboring vertices Usage get.gabor@gmail.com> See Also get. "in". mode = c("all". "total")) Arguments graph mode The input graph.adjedgelist(g) .92 get. mode = c("all". get.adjlist(graph.ring(1 ) get.edgelist.adjedgelist returns a list of numeric vectors. Details get.adjedgelist(graph. it gives what kind of adjacent edges/vertices to include in the lists. which include the ids of neighbor vertices (according to the mode argument) of all vertices. Value A list of numeric vectors.adjlist Adjacency lists Description Create adjacency lists from a graph. "out".adjlist get.adjlist(g) get. "out".adjlist returns a list of numeric vectors.adjacency Examples g <. ‘out’ is for outgoing edges/vertices. get. Character scalar. ‘all’ is for both.graph. ‘in’ is for incoming edges/vertices. "in".

get. i. the first and second are used for the first edge. This argument is ignored for undirected graphs. whether to consider edge directions in directed graphs. whether to handle multiple edges properly. vp. via their incident vertices.edge. the third and fourth for the second. edges are also numbered from one. directed = TRUE. This function handles multigraph (graphs with multiple edges) and can consider or ignore the edge directions in directed graphs. then the edge ids of multiple edges are correctly reported. If FALSE. If TRUE. and a pair of vertices are given twice (or more). up to the number of edges. etc.gabor@gmail.ids 93 get. Usage get. This function allows finding the edges of the graph. given as vertex ids or symbolic vertex names. then zero is reported. then always the same edge id is reported back for them. starting from one. Logical scalar. Logical scalar. (If the error argument is FALSE.edge. directed error multi Details igraph vertex ids are natural numbers. Value A numeric vector of edge ids. then no error is reported. multi = FALSE) Arguments graph vp The input graph. one for each pair of input vertices.ids Find the edge ids based on the incident vertices of the edges Description Find the edges in an igraph graph that have the specified end points.) Author(s) Gabor Csardi <csardi.com> .edge. and zero is returned for the non-existant edge(s).ids(graph. Similarly.e. If there is no edge in the input graph for a given pair of vertices. up to the number of vertices in the graph. error = FALSE. If FALSE. Logical scalar. whether to report an error if an edge is not found in the graph. They are interpreted pairwise. The indicent vertices.

The incidence matrix is an n times m matrix. if it is TRUE then a sparse matrix is created. If not NULL then the values of the given edge attribute are included in the incidence matrix. 4. Logical scalar. attr=NULL. If the graph has multiple edges.edge. 5. n and m are the number of vertices of the two kinds. You must supply this argument if the graph has no type vertex attribute.graph. c(1. the edge attribute of an arbitrarily chosen edge (for the multiple edges) is included. An optional vertex type vector to use instead of the type vertex attribute. you will need the Matrix package for this. if TRUE and the vertices in the graph are named (i. c(2. names=TRUE. Otherwise the ids of the vertices are used as row and column names. sparse=FALSE) Arguments graph types attr The input graph.4.ids(g.5)) E(g)[ei] ## non-existant edge get. . Value A sparse or dense matrix.e.incidence(graph.edge.ids(g. Either NULL or a character string giving an edge attribute name.get. If NULL. 1. then vertex names will be added to the result as row and column names. then a traditional incidence matrix is returned. types=NULL.4)) get.incidence Incidence matrix of a bipartite graph Description This function can return a sparse or dense incidence matrix of a bipartite network.94 Examples g <.2.ring(1 ) ei <. Logical scalar. the graph has a vertex attribute called name). names sparse Details Bipartite graphs have a type vertex attribute in igraph.1.incidence get. Usage get. this is boolean and FALSE for the vertices of the first kind and TRUE for vertices of the second kind. The direction of the edges is ignored in directed graphs.

where it is assumed that D is non-singular. otherwise it is the columns. Examples g <. ). .stochastic Author(s) Gabor Csardi <csardi. . i M1 i . i Mni ) .gabor@gmail. whether to return a sparse matrix.graph.stochastic Stochastic matrix of a graph Description Retrieves the stochastic matrix of a graph of class igraph. . Let us define D = diag( The (row) stochastic matrix is defined as W = D−1 M. The Matrix package is needed for sparse matrices. Value A regular R matrix or a matrix of class Matrix if a sparse argument was TRUE. Usage get.incidence for the opposite operation. Logical scalar. column.com> See Also graph.1.2.4) ) get.wise = FALSE. Column stochastic matrices are defined in a symmetric way. If FALSE. .wise sparse The input graph.3.3. then the rows of the stochastic matrix sum up to one.stochastic(graph. c(1.1. Must be of class igraph.incidence(g) 95 get.get. .bipartite( c( . . sparse = getIgraphOpt("sparsematrices")) Arguments graph column. Details Let M be an n×n adjacency matrix with real non-negative entries.2.

This implementation is based on Alon Itai and Michael Rodeh: Finding a minimum circuit in a graph Proceedings of the ninth annual ACM symposium on Theory of computing. thanks Keith. The input graph. Logical scalar.gabor@gmail. directed = FALSE) W <. then zero is returned.game(n = 1 ^5.stochastic(g. whether to return the shortest circle itself. directed graphs are treated as undirected graphs.96 Author(s) Gabor Csardi <csardi. It may be directed.barabasi. . acyclic). 1977.com> See Also get.adjacency Examples ## g is a large sparse graph g <. Loop edges and multiple edges are ignored. If the graph is a forest (ie. Usage girth(graph. circle=TRUE) Arguments graph circle Details The current implementation works for undirected graphs only. The first implementation of this function was done by Keith Briggs. due to numerical errors max(abs(rowSums(W))-1) girth girth Girth of a graph Description The girth of a graph is the length of the shortest circle in it. sparse=TRUE) ## a dense matrix here would probably not fit in the memory class(W) ## may not be exactly 1. power = 2. but the algorithm searches for undirected circles anyway.get. 1-10.

graph.color2) graph.isomorphic.isomorphic. Usage graph.graph. sh2="fm") graph.game(1 . vertex.ring(1 ) girth(g) # What about a random graph? g <. 3) girth(g) # The worst case running time is for a ring g <.color2. edge. Numeric vector with the vertex ids in the shortest circle. graph2.vf2(graph1.count.color1. graph2) graph.renyi.tree(1 . vertex. graph2.isomorphic. graph2.color1.color1.gabor@gmail. edge. graph2. vertex. 97 Alon Itai and Michael Rodeh: Finding a minimum circuit in a graph Proceedings of the ninth annual ACM symposium on Theory of computing.get. 1977 Examples # No circle in a tree g <.vf2(graph1.erdos. the girth of the graph. or 0 if the graph is acyclic. vertex.isomorphisms.color1. 1/1 girth(g) ) graph-isomorphism Graph Isomorphism Description These functions deal with graph isomorphism.isomorphic(graph1. sh1="fm". edge.vf2(graph1.isomorphisms. 1-10. graph2) graph.color2) graph.com> References Integer constant.bliss(graph1.34(graph1.graph-isomorphism Value A named list with two components: girth circle Author(s) Gabor Csardi <csardi. edge.color2. .

subisomorphic. See the sh argument of canonical.color1.color1. If they are not given.color2) graph.vf2(graph1.vf2(graph1. edge. then supply NULL for both of these arguments.edge. See also examples below. edge. then it will be used. edge.vf2(graph1. Currently it does the following: .color1. Character constant. the heuristics to use in the BLISS algorithm. See the sh argument of canonical. graph2. If they are not given. The input graphs must be both directed or both undirected.isoclass(graph) graph. number. vertex. graph-isomorphism graph1. the heuristics to use in the BLISS algorithm.isomorphic decides whether two graphs are isomorphic.color2. graph2. edge.color2. This function is a higher level interface to the other graph isomorphism decision functions.color1. edge.subisomorphisms.isocreate(size.color1. for graph1. vertex. Numeric vector. but the graph has a “color” vertex attribute.subisomorphisms. The number of the isomorphism class of the graph to be created. but the graph has a “color” edge attribute. edge.subgraph(graph. vertex. edge.color1. vertex. size number directed sh1 sh2 vids A numeric integer giving the number of vertices in the graph to create. the vertex ids of vertices to form the induced subgraph for determining the isomorphism class. vertex. Character constant.color1. If you want to ignore these attributes.permutation for possible values. for graph2. vids) graph. then it will be used. vertex. Whether to create a directed graph. If you want to ignore these attributes.color1.color1.color2) graph.color2) graph. graph2. then supply NULL for both of these arguments.color1.color2 Optional integer vectors giving the colors of the vertices for colored (sub)graph isomorphism. edge.color2.color2) graph. directed=TRUE) Arguments graph A graph object.count.graph2 Graph objects vertex. vertex.isoclass.color2.permutation for possible values.vertex. Details graph.98 vertex.get. Only three or four are suppported right now.color2 Optional integer vectors giving the colors of the edges for edge-colored (sub)graph isomorphism. edge.

isocreate create a graph from the given isomorphic class. a non-negative integer number. . by Cordella.bliss uses the BLISS algorithm by Junttila and Kaski.isomorphic. and it works for undirected graphs. igraph. an mapping from graph1 to graph2 if iso is TRUE.isomorphic. are isomorphic. an mapping from graph2 to graph1 if iso is TRUE. (To count automorphisms you can supply the same graph twice. graph. TRUE if the input graphs are isomorphic. both of which contains only 3 or 4 vertices.bliss is called. then igraph. graph.get. If the two graphs do not agree in the number of vertices and the number of edges then FALSE is returned. It uses the VF2 algorithm.subisomorphisms.) It uses the VF2 algorithm.34 return a logical scalar.vf2 is called.isomorphic.subgraph calculates the isomorphism class of a subgraph of the input graph. 4. whether the two graphs are isomorphic.vf2 counts the different isomorphic mappings between graph1 and graph2. graph. Currently it can handle only graphs with 3 or 4 vertices. finally the canonical forms are compared. graph.vf2 calculates all isomorphic mappings between graph1 and graph2.isomorphic.isomorphic. graph.34 decides whether two graphs.vertices function is called to transfer them into canonical form. it implements the VF2 algorithm. A numeric vector.automorphisms.34 is called.vf2 counts the different isomorphic mappings between graph2 and the subgraphs of graph1. graph. then igraph.isomorphic. A numeric vector.isomorphisms.vf2 decides whether graph2 is isomorphic to some subgraph of graph1. graph. It works based on a precalculated and stored table.vf2 decides whethe two graphs are isomorphic.isoclass.isoclass returns the isomorphism class of a graph.vf2 calculates all isomorphic mappings between graph2 and the subgraphs of graph1. an empty numeric vector otherwise.get. graph. Otherwise igraph. It uses the VF2 algorithm. graph. Graphs (with the same number of vertices) having the same isomorphism class are isomorphic and isomorphic graphs always have the same isomorphism class.count. FALSE otherwise. Value graph.isomorphisms. For both graphs the canonical. 3. Currently it only works for subgraphs with 3 or 4 vertices. Foggia et al. an empty numeric vector otherwise.subisomorphic. but it is better to call graph. graph. igraph.graph-isomorphism 99 1.subisomorphisms. It uses the VF2 algorithm. Currently it can handle only graphs with 3 or 4 vertices. 2.isomorphic and graph. Otherwise if the graphs are directed.count. It uses the VF2 algorithm.isomorphic.permutation and then the permute. Otherwise if the graphs have 3 or 4 vertices..bliss returns a named list with elements: iso map12 map21 A logical scalar.isomorphic. see references.

vf2 returns a names list with three elements: iso map12 map21 A logical scalar. whether the two graphs are isomorphic. graph. 2007. 2001. an mapping from graph2 to graph1 if iso is TRUE.isomorphic. the number of isomorphic mappings between the two input graphs. Every numeric vector is a permutation which takes graph2 into graph1.permutation for details. -1 denotes the vertices which are not part of the mapping. graph. graph.subisomorphic. Numeric vector.get. see the return value of canonical.vf2 returns a numeric scalar. graph.vf2 returns a list of numeric vectors.com> References Tommi Junttila and Petteri Kaski: Engineering an Efficient Canonical Labeling Tool for Large and Sparse Graphs. graph.isomorphisms. Some information about the canonical form calculation for graph2.isocreate returns a graph object.subgraph and graph.vf2 returns a numeric scalar. Otherwise a mapping from a subgraph of graph1 to graph2. an integer. empty if iso is FALSE.subgraph return a non-negative integer number. C Sansone. A named list.100 info1 info2 graph-isomorphism Some information about the canonical form calculation for graph1.subisomorphisms. graph. an empty numeric vector otherwise. A named list. an integer. Otherwise a mapping from graph2 into graph1.isoclass.count. P Foggia.vf2 returns a list of numeric vectors.isocreate are considered experimental and might be reorganized/rewritten later.isoclass.gabor@gmail. see the return value of canonical. an mapping from graph1 to graph2 if iso is TRUE.count.isoclass. graph. 149–159. and M Vento: An improved algorithm for matching large graphs.isomorphisms. TRUE if a subgraph of graph1 is isomorphic to graph2.vf2 returns a named list with three elements: iso map12 map21 Logical scalar. Author(s) Gabor Csardi <csardi. LP Cordella. empty if iso is FALSE. each numeric vector is an isomorphic mapping from graph2 to a subgraph of graph1. Note Functions graph. Numeric vector. of the 3rd IAPR TC-15 Workshop on Graphbased Representations in Pattern Recognition.permutation for details. an empty numeric vector otherwise. graph. A numeric vector. Proc.subisomorphisms. Proceedings of the Ninth Workshop on Algorithm Engineering and Experiments and the Fourth Workshop on Analytic Algorithms and Combinatorics.isoclass and graph. graph. A numeric vector.get. .

isomorphisms. g2) graph. g2) graph.isomorphic.ring(1 ) graph. m=2. vertex.isoclass(g2) graph.vf2(g1. sample(vcount(g1))) # should be TRUE graph.barabasi. length=vcount(g1)) V(g2)$color <. g2.color2=NULL) V(g1)$color <. vertex.ring(1 ) g2 <.graph.vf2(g1.permute.count.rep(1:2. g2) # create two isomorphic graphs.bliss(g1.isomorphic(g1.isomorphic(g1.isocreate(3.isomorphic.motifs Examples # create some non-isomorphic graphs g1 <.isomorphic.isocreate(3. vertex.isomorphisms.vf2(g2.color1=NULL.graph. g2) graph. These functions search a graph for various motifs. length=vcount(g2)) graph. 1 ) g2 <.color1=NULL.rep(1:2.1 V(g2)$color <.game(3 .isomorphic.vertices(g1. vertex.isomorphic. by # permuting the vertices of the first g1 <.graph. 11) graph. .vf2(g1.2 graph. g2) graph.graph. g2) V(g1)$color <. directed=FALSE) g2 <.vf2(g1.color2=NULL) 101 graph-motifs Graph motifs Description Graph motifs are small connected subgraphs with a well-defined structure.isoclass(g1) graph. g2. g2) # colored graph isomorphism g1 <.count.graph-motifs See Also graph.vf2(g1.

sample. size = 3. The motifs are ordered by their isomorphism classes.102 Usage graph-motifs graph. Its length should be the same as the size of the motif (the size argument). graph. which are not considered to be motifs.motifs. currently 3 and 4 are supported only. cut. The number of vertices to use as a starting point for finding motifs. Author(s) Gabor Csardi <csardi. The size of the motif. size)) graph.com> See Also graph. The order of the motifs is defined by their isomorphism class. 3) graph.motifs. the result will be NA.prob = rep( .motifs.est(g.motifs. cut. Note that for unconnected subgraphs. size). size = 3. If not NULL then it specifies the vertices to use as a starting point for finding motifs.no calculates the total number of motifs of a given size in graph.motifs. By default no cuts are made. the input graph.prob = rep( .motifs.motifs returns a numeric vector.no(graph.motifs. cut. graph.est return a numeric constant. the number of occurences of each motif in the graph.est(graph.isoclass. 3) graph.est estimates the total number of motifs of a given size in a graph based on a sample. size = 3.no and graph. size)) graph. see graph.motifs(graph. 3) .gabor@gmail.prob = rep( .motifs. sample = NULL) Arguments graph size cut. sample.size = vcount(graph)/1 .motifs(g.barabasi.no(g.game(1 ) graph. Value graph.size sample Details graph. graph. Numeric vector giving the probabilities that the search graph is cut at a certain level.isoclass Examples g <. Only used if the sample argument is NULL.prob Graph object.motifs searches a graph for motifs of a given size and returns a numeric vector containing the number of different motifs.

Only edges which are not present in the original graph will be included in the new graph. . Thus first the vertices in the second.big. |V| is the number of vertices in the graph.. Ie.intersection creates the intersection of two or more graphs: only edges present in all graphs will be included.) graph. |V|-1. .. The corresponding operator is %s%.x.compose(g1. .union(.) graph..disjoint. only edges which are included in at least one graph will be part of the new graph.graph.difference(big. |V|-1. graph. ..y Graph objects. g2) graph. whether to generate loop edges.small. loops Details A graph is homogenous binary relation over the set 0. . graph. graphs are relabeled to have completely disjoint graphs.union creates a union of two or more disjoint graphs. loops=FALSE) x %c% y x %du% y x %m% y x %s% y x %u% y Arguments .graph-operators 103 graph-operators Graph operators Description Graph operators handle graphs in terms of set theory.. graph. . .. third. small) graph. g1. Usage graph.. . etc. Then a simple union is created. The functions documented here handle graphs as relations.union creates the union of two or more graphs. Only edges present in the first graph but not in the second will be be included in the new graph.g2.) graph. This function can also be used via the %du% operator. graph. Graph objects or lists of graph objects.disjoint. This function can be also used via the %u% operator. The corresponding operator is %m%.complementer(graph.union(. .difference creates the difference of two graphs. graph.complementer creates the complementer of a graph.intersection(. Logical constant.. A homogenous binary relation is a set of ordered (directed graphs) or unordered (undirected graphs) pairs taken from 0.

disjoint. Author(s) Gabor Csardi <csardi. .compose creates the composition of two graphs.b) edge only if there is a vertex c. The other functions do not handle vertex and edge attributes.com> Examples g1 <. g2) graph. g2) print(dg. such that edge (a.b) is included in the second graph. edge attributes are lost. g2) graph.graph.union(g1. The new graph will contain an (a.gabor@gmail. v=TRUE. e=TRUE) graph-operators-by-name Graph operators based on symbolic vertex names Description Normally igraph operators are based on internal igraph vertex ids.104 graph-operators-by-name graph.star(1 .c) is included in the first graph and (c. g2) graph. the new graph will have no attributes at all.circle V(g2)$name <.complementer(g2) graph. g=TRUE. graph."Ring" V(g1)$name <.round(runif(ecount(g1))*1 ) dg <.intersection(g1.compose(g1. g2) ## graph complementer keeps graph and vertex attributes g2$layout <. g2) graph.layout.complementer keeps graph and vertex attriubutes. mode="undirected") graph.difference(g1.graph.complementer(g2) cg2$layout V(cg2)$name ## graph difference keeps the attributes of the first graph g1$name <. Value A new graph object.difference(g1. graph.graph. vertex and edge) of the first graph. The corresponding operator is %c%.graph.union(g1.difference keeps all attributes (graph.ring(1 ) g2 <. This function works with vertex names instead.LETTERS[1:vcount(g1)] E(g1)$weight <.letters[1:vcount(g2)] cg2 <.

keep. keep.star(11.edge.x. Details These functions treat the graphs as sets of ordered (if they are directed).options(print. even if they do not appear in g2.attributes=TRUE) # Creating a wheel graph g1 <. whether to keep edge attributes of g1.edge.vertex. even if they do not appear in g2. or unordered (if they are undirected) pairs of symbolic vertex names and perform set operations on them.by.graph.x. Value A new graph object.g2 The input graphs. g2. Examples # Print attributes as well igraph.graph-operators-by-name Usage graph.attributes=TRUE.difference.x.name(g1. link{graph.x.union. whether to keep all the vertices of g1.graph.vertex.attributes = FALSE) graph.ring(1 ) V(g1)$name <.attributes = FALSE. keep. they should be both directed or both undirected. print.by.vertex.x. keep.edge. Author(s) Magnus Torfason See Also graph. keep. even if they do not appear in g2.intersection} and link{graph.x.name(g1. keep.difference} for the functions that are based on vertex ids.name(g1.vertex.vertices Logical scalar.attributes Logical scalar. mode="undirected") . whether to keep all vertex attributes of the g1. g2.edge. g2) graph.letters[1:vcount(g1)] g2 <.attributes Logical scalar.vertices = FALSE.attributes = FALSE) Arguments 105 g1.union.attributes = FALSE.intersection. keep. keep.x.x.by.

layout=layout.formula(b-c-d) # Test the functions graph.attributes = TRUE) # Don’t throw away E(g1) attributes graph. "lower". letters[1:vcount(g1)]) g <.by.vertices = FALSE. "upper".attr=c(5.by. add.name() has some extra parameters graph. # Don’t throw away V(g1) attributes keep.x.difference.c("z". "plus").graph.label=V(g)$name) } g # Some more examples g1 <.edge. # Keep all x vertices (only intersect edges) keep.intersection.vertex. keep.name(g1. # Don’t throw away V(g1) attributes keep.7) g2 <. vertex. .x.union.x.adjacency is a flexible function for creating igraph graphs from adjacency matrices.name(g1.graph.intersection. weighted=NULL.5.by.edge.2.colnames=NULL.x.kawai.x.vertex.adjacency # graph.g2.graph.attributes = TRUE.g2.adjacency Create graphs from adjacency matrices Description graph.by.g2) # Vertices are intersected as well graph.vertices = TRUE) # Keep all x vertices (only intersect edges) graph. keep.name() has some extra parameters graph.by. g2) if (interactive()) { plot(g. "undirected".formula(a-b-c) V(g1)$v.intersection.difference.name(g1.3) E(g1)$e.1 this can be a sparse matrix created with the Matrix package.union.x.kamada. add.by. diag=TRUE. mode=c("directed". keep.intersection.g2) # Vertices from x (g1) are used graph.difference.by.attributes = TRUE.attributes = TRUE) # Don’t throw away E(g1) attributes # graph. "min".name(g1.rownames=NA) Arguments adjmatrix A square adjacency matrix.attr=c(1. "max".106 V(g2)$name <.g2.name(g1.g2) # Vertices are unioned as well graph. Usage graph. From igraph version 0.name(g1.by.by.name(g1.adjacency(adjmatrix.

i)) edges between vertex i and j. If it is TRUE then a weighted graph is created and the name of the edge attribute will be weight.colnames’ specify the same vertex attribute. weighted diag add. undirected This is exactly the same as max. whether to include the diagonal of the matrix in the calculation. i. max An undirected graph will be created and max(A(i. upper. If a character constant. By default row names are not added. specifies how igraph should interpret the supplied matrix. depending on the weighted argument.adjacency mode 107 Character scalar. plus undirected graph will be created with A(i. See also details below. If ‘NA’ then they will not be added. If ‘add. This argument specifies whether to create a weighted graph from an adjacency matrix.rownames Details graph. whether to add the column names as vertex attributes. only the lower left triangle (including the diagonal) is used for creating the edges.i)) gives the number of edges. only the upper right triangle (including the diagonal) is used for the number of edges. for convenience. plus. Character scalar.j).i) edges between vertex i and j. See details below. the vertex corresponding to the first row will be vertex 0 in the graph. If this is FALSE then the diagonal is zerod out first. Possible values the same as the previous argument. graph. Note that it is not checked whether the matrix is symmetric. Possible values are: directed. If it is NULL then an unweighted graph is created and the elements of the adjacency matrix gives the number of edges between the vertices. the interpretation depends on that too. If the weighted argument is not NULL then the elements of the matrix give the weights of the edges (if they are not zero). A(j. whether to add the row names as vertex attributes. etc. undirected. min.adjacency creates a graph from an adjacency matrix. min undirected graph will be created with min(A(i. If this argument is NULL then an unweighted graph is created and an element of the adjacency matrix gives the number of edges to create between the two corresponding vertices. if present. The details depend on the value of the mode argument: directed The graph will be directed and a matrix element gives the number of edges between two vertices. upper An undirected graph will be created.colnames add. If it is a character constant then for every non-zero matrix entry an edge is created and the value of the entry is added as an edge attribute named by the weighted argument. then the former is ignored.rownames’ and ‘add.j)+A(j. max. column names are added as vertex attribute ‘name’. The order of the vertices are preserved. Character scalar. Logical scalar. The details depend on the value of the mode argument: . A(j. See also the weighted argument.j). If it is ‘NULL’ (the default) then.e.graph. then it gives the name of the vertex attribute to add. lower.adjacency operates in two main modes. lower An undirected graph will be created.

nc=1 ) g1 <. It is an error if not. weighted=TRUE.tri(adjm)]) == sort(E(g6)$weight)) g7 <. Author(s) Gabor Csardi <csardi.matrix(sample( :1. with some tests nzs <.j). t(adjm))[upper. A(j.formula for other ways to create graphs. mode="max") all(nzs(pmax(adjm. 1 ) adjm[ adjm< .9.j).matrix(runif(1 ). Examples adjm <.adjacency(adjm. t(adjm))[upper.108 graph. lower An undirected graph will be created. min An undirected graph will be created.j)+A(j.adjacency(adjm. weighted=TRUE. A(i. replace=TRUE.adjacency( adjm ) adjm <. max An undirected graph will be created and max(A(i.graph. mode="min") all(nzs(pmin(adjm.adjacency(adjm. mode="upper") all(nzs(adjm[upper. 2. nc=1 ) g2 <. . .graph. undirected First we check that the matrix is symmetric. Value An igraph graph object. prob=c( . . only the lower left triangle (including the diagonal) is used for creating the edges. Then only the upper triangle is used to create a weighted undirected graph.graph. 2.i)) gives the edge weights.i) gives the edge weights.i)) gives the edge weights. 2)). 2.9. only the upper right triangle (including the diagonal) is used (for the edge weights).adjacency directed The graph will be directed and a matrix element gives the edge weights.graph. 1 .adjacency(adjm.graph. mode="undirected") g4 <. A(j. weighted=TRUE. weighted=TRUE.matrix(sample( :5.adjacency(adjm. upper An undirected graph will be created.graph.adjacency((adjm + t(adjm))/2. 1 .5 ] <g3 <. replace=TRUE. 2.function(x) sort(x [x!= ]) adjm <. . weighted=TRUE) E(g2)$weight ## various modes for weighted graphs. plus An undirected graph will be created.graph. . prob=c( .tri(adjm)]) == sort(E(g5)$weight)) g6 <. mode="lower") all(nzs(adjm[lower.1)). . min(A(i.gabor@gmail.com> See Also graph and graph. weighted=TRUE.tri(adjm)]) == sort(E(g4)$weight)) g5 <.tri(adjm)]) == sort(E(g7)$weight)) .

‘fsm’: first smallest maximally non-trivially connected non-singleton cell. ‘fm’: first maximally non-trivially connected non-singleton cell. This number is exact if igraph was compiled with the GMP library. weighted=TRUE. mode="plus". Usage graph.tri(adjm)]) == sort(E(g9)$weight)) ## row/column names rownames(adjm) <. weighted=TRUE. This function calculates the number of automorphism of a graph using the BLISS algorithm.automorphisms 109 g8 <.function(x) { diag(x) <.tri(adjm)]) == sort(E(g8)$weight)) g9 <.adjacency(adjm. sh="fm") Arguments graph sh The input graph. Details An automorphism of a graph is a permutation of its vertices which brings the graph into itself. it is treated as undirected.tcs. See also the BLISS homepage at http://www. . ‘fl’: first largest non-singleton cell. i.function(x) { diag(x) <} all(nzs((d (adjm+t(adjm)))[lower. x } all(nzs((d2(adjm+t(adjm)))[lower. ‘flm’: first largest maximally non-trivially connected non-singleton cell.diag(x)/2. diag=FALSE) d <.adjacency(adjm. Possible values are: ‘f’: first non-singleton cell. nrow(adjm)) colnames(adjm) <.sample(letters.rownames="code") summary(g1 ) graph. mode="plus") d2 <.fi/Software/bliss/index.automorphisms(graph.adjacency(adjm. ‘fs’: first smallest nonsingleton cell.graph. add.html. the number of isomorphisms to itself.hut.e. as a string. Value A named list with the following members: group_size The size of the automorphism group of the input graph.graph. and approximate otherwise. The splitting heuristics for the BLISS algorithm.graph. weighted=TRUE.automorphisms Number of automorphisms Description Calculate the number of automorphisms of a graph.seq(ncol(adjm)) g1 <.graph.

extra = NULL. "in". graph.bfs (graph. permute. dist = FALSE.ring(1 ) graph.automorphisms(g) -9 vertices Maximum level.vertices Examples ## A ring has n*2 automorphisms. neimode = c("out". father = FALSE.graph.it> for BLISS and Gabor Csardi <csardi. nof_bad_nodes Number of bad nodes. order = TRUE. 2007.com> for the igraph glue code and this manual page.bfs Breadth-first search Description Breadth-first search is an algorithm to traverse a graph.110 nof_nodes The number of nodes in the search tree. nof_canupdates Number of canrep updates. "all".permutation. succ = FALSE. "total"). References Tommi Junttila and Petteri Kaski: Engineering an Efficient Canonical Labeling Tool for Large and Sparse Graphs. max_level Author(s) Tommi Juntilla <google@for. unreachable = TRUE. pred = FALSE.frame()) . Proceedings of the Ninth Workshop on Algorithm Engineering and Experiments and the Fourth Workshop on Analytic Algorithms and Combinatorics.gabor@gmail. Usage graph.bfs nof_leaf_nodes The number of leaf nodes in the search tree. See Also canonical. you can "turn" it by ## and each of these graphs can be "flipped" g <. graph. rho = parent. callback = NULL. restricted = NULL. rank = FALSE. We start from a root vertex and spread along every edge “simultaneously”. root.

Character scalar. Numeric vector.bfs Arguments graph root neimode The input graph.graph. This argument is ignored for undirected graphs. For directed graphs specifies the type of edges to follow. in the order in which they were visited by the search. or a vector of vertices (ids or symbolic names). In the latter case. If TRUE. whether to return the successors of the vertices. unreachable restricted order rank father pred succ dist callback extra rho Details The callback function must have the following arguments: graph The input graph is passed to the callback function here. ‘total’ is a synonym for ‘all’. extra The extra argument. the rank of the current vertex. or root vertices to start the search from. the vertex that was just visited. ‘in’ incoming edges. irrespectively of the supplied value. its predecessor. whether to return the father of the vertices. The root vertex. This is called whenever a vertex is visited. ‘dist’. with the following entries: ‘vid’. ‘succ’. Value A named list with the following entries: root neimode order Numeric scalar. ‘rank’. data A named numeric vector. ‘all’ ignores edge directions completely. whether to return the distance from the root of the search tree. If not NULL. Logical scalar. the search is restricted to the given vertices. ‘out’ follows outgoing. Logical scalar. The environment in which the callback function is evaluated. Logical scalar. then additional searches are performed until all vertices are visited. then it must be callback function. Additional argument to supply to the callback function. whether to return the ordering of the vertices. whether to return the rank of the vertices. Logical scalar. its distance from the root of the search tree. its successor. NULL (=no restriction). The neimode argument of the function call. 111 Numeric vector. . ‘pred’. Logical scalar. The root vertex that was used as the starting point of the search. Logical scalar. See details below. The vertex ids. usually of length one. Logical scalar. whether to return the predecessors of the vertices. whether the search should visit the vertices that are unreachable from the given root vertex (or vertices). Note that for undirected graphs this is always ‘all’. See examples below on how to use the callback function.

com> See Also graph. The father of each vertex. i. .e. root=1. or 0 if there was no such vertex. order=TRUE. "out".e.bipartite Numeric vector. rank=TRUE.ring(1 ). Note that order. Numeric vector. graph.ring(1 ) %du% graph. The previously visited vertex for each vertex. root=1. data.112 rank father pred succ dist Numeric vector. or 0 if there was no such vertex. data. root=1.bfs(graph.bipartite Create a bipartite graph Description A bipartite graph has two kinds of vertices and connections are only allowed between different kinds. Numeric vector. Numeric vector.dfs for depth-first search. Author(s) Gabor Csardi <csardi.bfs(graph. succ=TRUE.function(graph. callback=f) graph. The next vertex that was visited after the current one.function(graph.ring(1 ). pred. Examples ## Two rings graph. i. extra) { print(data) FALSE } tmp <. pred=TRUE. extra) { data[’succ’] == -1 } graph. dist=TRUE) ## How to use a callback f <.bfs(graph. The rank for each vertex.ring(1 ) %du% graph. if their calculation is not requested. "out". succ and dist might be NULL if their corresponding argument is FALSE. callback=f) ## How to use a callback to stop the search ## We stop after visiting all vertices in the initial component f <. for each vertex its distance from the root of the search tree.ring(1 ) %du% graph. the vertex it was discovered from. father=TRUE.gabor@gmail. rank.ring(1 ).graph. father.

c(1:1 )) print(g. is. this is boolean and FALSE for the vertices of the first kind and TRUE for vertices of the second kind. is. Whether to create a directed graph. Note that by default undirected graphs are created. graph.bipartite( rep( :1.bipartite returns a logical scalar. The input graph. Author(s) Gabor Csardi <csardi. the same way as for the regular graph function. v=TRUE) . It will be coerced into boolean. Then it creates a graph using the edges vector and finally it adds the types vector as a vertex attribute called type. as this is more common for bipartite graphs. In other words.length=1 ). boolean constant.graph. Value graph.bipartite basically does three things.gabor@gmail.bipartite checks whether the graph is bipartite or not.bipartite Usage graph. edges. A vector giving the edges of the graph. directed=FALSE) is.bipartite returns a bipartite igraph graph.graph.bipartite(graph) Arguments types edges 113 A vector giving the vertex types. First it checks tha edges vector against the vertex types.com> See Also graph to create one-mode networks Examples g <. It just checks whether the graph has a vertex attribute called type. an igraph graph that has a vertex attribute named type. directed graph Details Bipartite graphs have a type vertex attribute in igraph. accoding to the supplied types vector. It is checked that the edges indeed connect vertices of different kind. The length of the vector gives the number of vertices in the graph.bipartite(types.

ring(n. if TRUE a directed graph will be created.full(n. n=max(edges). dim = NULL. Usage graph. The number of vertices in the graph for most functions.tree(n. mode=c("out". w) Arguments edges directed Numeric vector defining the edges. mutual = FALSE. . mode = c("in". lattices. For graph.ring it is FALSE. For igraph. rings. star graphs. "undirected"). graphs from adjacency matrices. circular=TRUE) graph.. trees. Note that for while most constructors the default is TRUE. "in".lattice. directed = FALSE. graphs with the given edges. For graph. For graph. directed = FALSE.empty(n= .constructors graph.star it defines the direction of the edges. For graph this parameter is ignored if there is a bigger vertex id in edges. directed = FALSE. mutual = FALSE.extended. length = NULL.edgelist(el. A vector giving the size of the lattice in each dimension.lattice(dimvector = NULL. etc. the first edge points from the first element to the second. out: the edges point from the center. for graph. "undirected")) graph. directed=TRUE) graph(edges. loops = FALSE) graph. directed=TRUE) graph. while undirected creates an undirected graph. by default the first vertex. This means that for this function it is safe to supply zero here if the vertex with the largest id is not an isolate.atlas this is the number (id) of the graph to create.citation(n.lattice and graph.constructors Various methods for creating graphs Description These method can create various (mostly regular) graphs: empty graphs.star the mode argument should be used for creating an undirected graph. children = 2.114 graph. center = 1) graph. in: the edges point to the center. directed = TRUE) graph. in indicates that they point from the children to their parents.star the center vertex of the graph. For graph. circular = FALSE.) graph.ring(n. nei = 1. "mutual".tree this parameter defines the direction of the edges. Logical. directed=TRUE) graph. mutual: a directed star is created with mutual edges. out indicates that the edges point from the parent to the children.full.star(n.chordal. n mode center dimvector . undirected: the edges are undirected.atlas(n) graph. "out". the second edge from the third to the fourth.. for graph.

If directed=FALSE then the graph is just a full graph. graph.edgelist creates a graph from an edge list. for a fixed number of nodes. for fixed degree sequence. the number of children of a vertex (except for leafs) for graph. graph. Integer constant. Integer constant. a two column matrix. numbered from 0 up to 1252. but not length and dim.full simply creates full graphs.lattice is a flexible function. An object. for fixed numbers of nodes and edges.tree. if TRUE the lattice or ring will be circular.constructors nei mutual circular length dim children loops graph el w . character or numeric.. If it is a numeric matrix then its elements are interpreted as vertex ids.star creates a star graph. In the first form you only supply dimvector. it creates a one dimensional circular lattice. for regular lattices.citation creates a full citation graph. This parameter is not used right now. each row defines one edge.full. 2.ring is actually a special case of graph. If it is a character matrix then it is interpreted as symbolic vertex names and a vertex id will be assigned to each name. Wilson.. . graph. in increasing number of automorphisms. if TRUE directed lattices will be mutually connected. Logical. graph. An edge list. graph. in increasing order of the number of edges. Integer constant.lattice. graph creates a graph with the given edges. It has two forms. The atlas contains all undirected graphs with up to seven vertices. 115 The distance within which (inclusive) the neighbors on the lattice will be connected. 4. This is a directed graph. 3. this creates an empty graph. graph. The graphs are listed: 1.graph. for example 111223 < 112222. See details below. graph. it can create lattices of arbitrary dimensions. Currently ignored. in increasing order of number of nodes. in this every single vertex is connected to the center vertex and nobody else. and also a name vertex attribute will be added. Details All these functions create graphs in a deterministic way. the size of the lattice in each dimension.tree creates regular trees. in increasing order of the degree sequence. graph. In the second form you omit dimvector and supply length and dim. where every i->j edge is present if and only if j<i. If TRUE also loops edges (self edges) are added.atlas creates graphs from the book An Atlas of Graphs by Roland C. Logical. graph. periodic or unperiodic ones. Its argument is a two-column matrix. the dimension of the lattice. A matrix which specifies the extended chordal ring. Read and Robin J. See details below.empty is the simplest one.

Let p denote the number of columns in the ‘W’ matrix.extended.graph. "bar". nr=2)) graph. nc=2.graph( c(1. Usage graph.chordal.5)) g7 <. 1)) el <.graph. See also Kotsis. The coreness of a vertex is k if it belongs to the k-core but not to the (k+1)-core. matrix(c(3.coreness(graph. G: Interconnection Topologies for Parallel Processing Systems. mode="out") g6 <. "foobar").chordal.coreness K-core decomposition of graphs Description The k-core of graph is a maximal subgraph in which each vertex has at least degree k. 1993.2. "in")) .graph. 2) g1 <.full.edgelist(el) g15 <.coreness graph.graph.matrix( c("foo".5.com> See Also graph.2. PARS Mitteilungen 11. graph.graph. each node has the same degree. byrow=TRUE) g13 <.ring(1 ) g9 <.full(5.ring(15.lattice(c(5.citation(1 ) g12 <.4.frame for an easy way to create graphs with many edge/vertex attributes.ring creates an extended chordal ring.7. An extended chordal ring is regular graph.empty() g2 <.formula for a handy way to create small graphs.graph.atlas(sample( :1252.extended.3. 1-6.lattice(length=5.12.graph. dim=3) g8 <.gabor@gmail.data.8. "bar".3. Examples g1 <. directed=FALSE ) g5 <. mode=c("all". The number of extra edges is the number of rows in ‘W’: for each row j an edge i->i+w[ij] is added if i+w[ij] is less than the number of total nodes.116 graph. Author(s) Gabor Csardi <csardi. "out".tree(1 . The extra edges of vertex i are added according to column i mod p in ‘W’. loops=TRUE) g11 <. It can be obtained from a simple ring by adding some extra edges specified by a matrix.11).6).5.graph.adjacency to create graphs from adjacency matrices.graph.graph.graph.star(1 . Value Every function documented here returns a graph object.4. graph.

frame(d. 2002 Seidman S. Author(s) Gabor Csardi <csardi.add.graph.graph. The cores of a graph form layers: the (k+1)-core is always a subgraph of the k-core.data. 269–287.edges(g. "both")) .data. possible values: in: in-cores are computed. all: the corresponding undirected graph is considered. This argument is ignored for undirected graphs.gabor@gmail.3)) graph.data. what=c("edges". Social Networks. See Also degree Examples g <. Value Numeric vector of integer numbers giving the coreness of each vertex. "vertices". B.frame(x. 2. it can be directed or undirected 117 The type of the core in directed graphs.3. Usage graph.coreness(g) graph. 5. out: out-cores are computed. This function calculates the coreness for each vertex.frame Creating igraph graphs from data frames or vice-versa Description This function creates an igraph graph from one or two data frames containing the (symbolic) edge list and edge/vertex attributes.ring(1 ) g <. 1. Character constant.2.frame Arguments graph mode The input graph. (1983) Network structure and minimum degree.data. c(1.com> References Vladimir Batagelj. Matjaz Zaversnik: An O(m) Algorithm for Cores Decomposition of Networks. directed=TRUE. Details The k-core of a graph is the maximal subgraph in which every vertex has at least degree k. vertices=NULL) get.

data. The first column of vertices is assumed to contain symbolic vertex names. whether to return info about vertices.frame NA elements in the first two columns ‘d’ are replaced by the string “NA” before creating the graph. in a list with named entries vertices and edges.csv.) For named graphs. (This also denotes edge direction for directed graphs. Additional columns are considered as edge attributes. and either a data frame or a list of two data frames named edges and vertices for as.frame A data frame containing a symbolic edge list in the first two columns. A data frame with vertex metadata. or NULL. The names of the attributes are taken from the names of the columns. get. depending whether the vertices argument is NULL or not. The default is ‘edges’. This means that all NAs will correspond to a single vertex. It has two modes of operatation. read. Details graph.frame creates igraph graphs from one or two data frames. then the edges of the graph and also the edge attributes are returned. the numeric vertex ids. or both. If vertices is NULL. then vertex attributes are returned. If the what argument is vertices. The edge attributes will be in the other columns.frame. the data frames are exported from some speadsheat software like Excel and are imported into R via read. The edges are listed in the order of their numeric ids. Note For graph. then the first two columns of d are used as a symbolic edge list and additional columns as edge attributes. the vertex names will be included in these columns. whether or not to create a directed graph.data.118 Arguments d directed vertices x what graph.data. because then the column named in the data frame will not be unique.frame. If vertices is not NULL.data.delim or read. See details below. If the what argument is edges (the default). .frame converts the igraph graph into one or more data frames. then both vertex and edge data is returned. named from and to. Logical scalar. then it must be a data frame giving vertex metadata. If vertices is not NULL then the symbolic edge list given in d is checked to contain only vertex names listed in vertices. Character constant. An igraph object. for other graphs. this will be added to the graphs as the ‘name’ vertex attribute. depending on the what argument. It is not a good idea to have an edge attribute named from or to. If the what argument is both.data.table. Vertices are listed in the order of their numeric vertex ids. Value An igraph graph object for graph. Typically. edges.data. The edges will be in the first two columns. Other columns will be added as additional vertex attributes.

"F".33. See details below.frame(g. vertex names (=the first column) cannot be NA.2. v=TRUE) ## The opposite operation get.3)) g <.1). "Alice". directed=TRUE.1. vertices=actors) print(g.bruijn De Bruijn graphs. same.frame(name=c("Alice". "Cecil".frame(from=c("Bob". "Cecil". what="vertices") get.5.. "Alice"). "Cecil". the length of the labels.bruijn 119 NA elements in the first column of ‘vertices’ are also replaced by the string “NA”.data.45.graph. but other vertex attributes can.de.FALSE."M". "David".21).data. "Bob".data. "Alice".34.5. what="edges") graph. "David".. e=TRUE. read. "Esmeralda"). See details below.bruijn(m.frame(relations.4.2. Examples ## A simple example with a couple of actors ## The typical case is that these tables are read in from files.de.dept=c(FALSE.TRUE)..com> See Also graph. Description De Bruijn graphs are labeled graphs representing the overlap of strings.n) Arguments m n Integer scalar. age=c(48.de.FALSE.table to read in tables from files. to=c("Alice". "Bob".data. friendship=c(4. In other words.constructors and graph. the size of the alphabet.graph."M". "David".formula for other ways to create graphs. gender=c("F".data. Integer scalar. "Bob". Author(s) Gabor Csardi <csardi.frame(g. Usage graph. but the rest of ‘vertices’ is not touched.TRUE."F")) relations <. .5. advice=c(4. actors <.5. "Esmeralda").gabor@gmail.FALSE.

.bruijn(2. Usage graph.bruijn(2. Logical constant. so probably you don’t want to supply too big numbers for m and n. whether to allow loop edges in the graph.density A de Bruijn graph represents relationships between strings. Value A graph object.density Graph density Description The density of a graph is the ratio of the number of edges and the number of possible edges. Please note that the graph will have m to the power n vertices and even more edges.2) line.graph. loops=FALSE) Arguments graph loops The input graph. An alphabet of m letters are used and strings of length n are considered.gabor@gmail. A vertex corresponds to every possible string and there is a directed edge from vertex v to vertex w if the string of v can be transformed into the string of w by removing its first letter and appending a letter to it.de. please see another source. line.graph(g) graph. eg.graph Examples # de Bruijn graphs can be created recursively by line graphs as well g <. De Bruijn graphs have some interesting properties.com> See Also graph.1) graph.density(graph. If this is FALSE then we assume that the graph does not contain any loop edges and that loop edges are not meaningful. Wikipedia for details.kautz.de. If this is TRUE then self loops are considered to be possible.120 Details graph. Author(s) Gabor Csardi <csardi.

"all". and Faust.erdos.graph.gabor@gmail.dfs Details 121 Note that this function may return strange results for graph with multiple edges.0) for an empty graph with zero vertices. rho = parent. 2.com> References Wasserman. order.renyi.dfs (graph.out = FALSE. Social Network Analysis: Methods and Applications.3) ) graph. neimode = c("out". density is ill-defined for graphs with multiple edges. "total"). 2.graph( c(1.full(n=1 ) g3 <.density(g. . out. Cambridge: Cambridge University Press.callback = NULL.2.0/0.4) # loop edges g <. extra = NULL. loops=FALSE) graph. "in".density(g. See Also vcount. Examples g1 <. but different graph. Value A real constant. Author(s) Gabor Csardi <csardi.. loops=FALSE) # this is wrong!!! # this is right!!! # this is also right. simplify to get rid of the multiple and/or loop edges.density(simplify(g).game(n=1 . This function returns NaN (=0.dfs Depth-first search Description Depth-first search is an algorithm to traverse a graph. Usage graph. K. root. dist = FALSE. (1994). It starts from a root vertex and tries to go quickly as far from as possible.empty(n=1 ) g2 <. ecount. in.graph. father = FALSE. loops=TRUE) graph.2.graph. unreachable = TRUE.frame()) .callback = NULL. order = TRUE. S.

irrespectively of the supplied value. i. Character scalar. its distance from the root of the search tree. The father of each vertex. Numeric vector.out father dist in. then it must be callback function. father. whether to return the distance from the root of the search tree. .122 Arguments graph root neimode graph. ‘total’ is a synonym for ‘all’. then it must be callback function. extra The extra argument.callback out. Logical scalar.callback extra rho Details The input graph. If not NULL. Note that order. data A named numeric vector. Numeric vector. Additional argument to supply to the callback function. The environment in which the callback function is evaluated.e. for each vertex its distance from the root of the search tree. whether the search should visit the vertices that are unreachable from the given root vertex (or vertices). If not NULL. the vertex ids. This argument is ignored for undirected graphs. Numeric vector. This is called whenever the subtree of a vertex is completed by the algorithm.dfs unreachable order order.out father dist Numeric scalar. Numeric vector. Logical scalar.out. The callback functions must have the following arguments: graph The input graph is passed to the callback function here. whether to return the DFS ordering of the vertices. The single root vertex to start the search from. and dist might be NULL if their corresponding argument is FALSE. Logical scalar. The vertex ids. See details below. ‘all’ ignores edge directions completely. whether to return the ordering based on leaving the subtree of the vertex. if their calculation is not requested. whether to return the father of the vertices. Value A named list with the following entries: root neimode order order. in the order of the completion of their subtree. the vertex that was just visited and ‘dist’. with the following entries: ‘vid’.e. The root vertex that was used as the starting point of the search. For directed graphs specifies the type of edges to follow. then additional searches are performed until all vertices are visited. The neimode argument of the function call. This is called whenever a vertex is visited. If TRUE. the vertex it was discovered from. Logical scalar. Logical scalar. in the order in which they were visited by the search. ‘out’ follows outgoing. See details below. i. order. ‘in’ incoming edges. Note that for undirected graphs this is always ‘all’. See examples below on how to use the callback functions.

com> See Also graph.dfs(graph. Usage graph. data.callback=f.gabor@gmail.in <.dfs(graph.out <. weights = NULL. data. vids = V(graph)) .tree(1 ).function(graph.diversity Author(s) Gabor Csardi <csardi. extra) { data[’vid’] == 1 } tmp <. "out". extra) { cat("out:".graph. root=1. ". TRUE) ## How to use a callback f. data. ". "out".graph. TRUE.function(graph.out) ## Terminate after the first component. TRUE.callback=f.dfs(graph.out) 123 graph. root=1. "\n") FALSE } tmp <. paste(collapse=".bfs for breadth-first search. Examples ## A graph with two separate trees graph. paste(collapse=".function(graph.diversity Graph diversity Description Calculates a measure of diversity for all vertices. out.diversity(graph. in. "\n") FALSE } f.tree(1 ).out <.in. out.graph.callback=f.tree(1 ). extra) { cat("in:". root=1.tree(1 ) %du% graph.tree(1 ) %du% graph. data). data). using a callback f. TRUE.

renyi. 2/2 ) g3 <.renyi. Michael Macy and Rob Claxton: Network Diversity and Economic Development.gabor@gmail. its length is the number of vertices. 5/2 ) E(g1)$weight <.game(2 . Note that this measure is not defined for unweighted graphs.1 E(g2)$weight <. 1029–1031. wij ki l=1 where pij = Vil .diversity NULL.erdos.erdos. graph. then the ‘weight’ attibute is used. wij is the weight of the edge(s) between vertices i and j .runif(ecount(g3)) graph. The vertex ids for which to calculate the measure.game(2 . 2/2 ) g2 <. Edge directions are ignored. Author(s) Gabor Csardi <csardi.diversity(g3) . If NULL. Examples g1 <.game(2 .diversity(g1) graph.124 Arguments graph weights The input graph. 2010.com> References Nathan Eagle. and ki is the (total) degree of vertex i. or the vector of edge weights to use for the computation.diversity(g2) graph. vids Details The diversity of a vertex is defined as the (scaled) Shannon entropy of the weights of its incident edges: H (i) D(i) = log ki and ki H (i) = − j =1 pij log pij .erdos. For vertices with degree less than two the function returns NaN. Science 328.renyi. Value A numeric vector.runif(ecount(g2)) E(g3)$weight <.

Frucht The Frucht Graph is the smallest cubical graph whose automorphism group consists only of the identity element. so this graph is the 6-cage. resembles to the head of a bull if drawn properly. A convex regular polyhedron with 8 vertices and 12 edges. edge transitive and not vertex transitive. resembles to a schematic diamond if drawn properly.graph. Dodecahedron Another Platonic solid with 20 vertices and 30 edges. and chromatic number 4. It is named after German mathematician Herbert Grötzsch. Character constant giving the name of the graph.famous Creating named graphs Description There are some famous. The graph is cubic. It has 12 vertices and 18 edges. 5 vertices. Folkman The semisymmetric graph with minimum number of vertices. It is case insensitive. Heawood The Heawood graph is an undirected graph with 14 vertices and 21 edges. A semisymmetric graph is regular. Franklin This is a graph whose embedding to the Klein bottle can be colored with six colors. 5 edges. 20 and 40 edges.famous(name) Arguments name Details graph. and its existence demonstrates that the assumption of planarity is necessary in Grötzsch’s theorem that every triangle-free planar graph is 3-colorable. According to the Grunbaum conjecture there exists an m-regular. . it is a counterexample to the neccessity of the Heawood conjecture on a Klein bottle. Coxeter A non-Hamiltonian cubic symmetric graph with 28 vertices and 42 edges.famous 125 graph. Dodecahedral.famous knows the following graphs: Bull The bull graph. Cubical The Platonic graph of the cube. and all cycles in the graph have six or more edges. 20 edges. It has 24 edges. Diamond A graph with 4 vertices and 5 edges. Grotzsch The Grötzsch graph is a triangle-free graph with 11 vertices. Every smaller cubic graph has shorter cycles. It has 12 vertices and 18 edges. the smallest cubic graph of girth 6. These can be created with this function Usage graph. Chvatal This is the smallest triangle-free graph that is both 4-chromatic and 4-regular. named graphs. sometimes counterexamples to some conjecture or unique graphs with given features. m-chromatic graph with n vertices for every m>1 and n>2. The Chvatal graph is an example for m=4 and n=12.

342-369. Value A graph object. Cognition. This graph is a counterexample. on 34 vertices and 52 edges. Tutte Tait’s Hamiltonian graph conjecture states that every 3-connected 3-regular planar graph is Hamiltonian. McGee The McGee graph is the unique 3-regular 7-cage graph. it is non-hamiltonian but removing any single vertex from it makes it Hamiltonian. that is. 1990. Smallestcyclicgroup A smallest nontrivial graph whose automorphism group is cyclic. An information flow model for conflict and fission in small groups. D. It has 19 vertices and 38 edges. a 4-regular graph of girth 5. Admin. House The house graph is a 5-vertex. A matching in a graph is a set of pairwise non-adjacent edges. A hypotracable graph does not contain a Hamiltonian path but after removing any single vertex from it the remainder always contains a Hamiltonian path. Tetrahedral. it has 30 vertices and 45 edges. 5 vertices and 8 edges. It is the unique such graph on 11 nodes. Zachary. 35. Walther An identity graph with 25 vertices and 31 edges. Nonline A graph whose connected components are the 9 graphs whose presence as a vertexinduced subgraph in a graph makes a nonline graph. A perfect matching is a matching which covers all vertices of the graph.famous Herschel The Herschel graph is the smallest nonhamiltonian polyhedral graph. basicly a triangle of the top of a square. A graph containing a Hamiltonian path is called tracable. the trivial one. no two edges share a common vertex. Levi The graph is a 4-arc transitive cubic graph. Icosahedron A Platonic solid with 12 vertices and 30 edges. It has 46 vertices and 69 edges. the schematic draw of a house if drawn properly. Thomassen The smallest hypotraceable graph. Octahedral. 452-473 (1977). Tetrahedron Platonic solid with 4 vertices and 6 edges. Journal of Anthropological Research 33. An identity graph has a single graph automorphism. It has 9 vertices and 15 edges. it has 24 vertices and 36 edges. Uniquely3colorable Returns a 12-vertex. Octahedron Platonic solid with 6 vertices and 12 edges. It has 50 vertices and 72 edges. It is the smallest hypohamiltonian graph. W. Icosahedral. HouseX The same as the house graph with an X in the square. 6-edge graph. See W. ie. Quart. Sci. Krackhardt\_Kite A social network with 10 vertices and 18 edges.126 graph.5)-cage graph. Assessing the Political Landscape: Structure. . and Power in Organizations. and has 18 edges. Petersen A 3-regular graph with 10 vertices and 15 edges. Meredith The Meredith graph is a quartic graph on 70 nodes and 140 edges that is a counterexample to the conjecture that every 4-regular 4-connected graph is Hamiltonian. Krackhardt. Robertson The unique (4. Noperfectmatching A connected graph with 16 vertices and 27 edges containing no perfect matching. triangle-free graph with chromatic number 3 that is uniquely 3-colorable. ie. Zachary Social network of friendships between 34 members of a karate club at a US university in the 1970s.

Logical scalar.formula(. The expressions consist of vertex names and edge operators. see also the other functions on the its manual page for creating special graphs. loop and multiple edges are removed.list(graph.formula() .. graph. An edge operator is a sequence of ‘-’ and ‘+’ characters. graph. graph.. simplify The formulae giving the structure of the graph. Let us see some simple examples. The edges can be arbitrarily long.. it works for both directed and undirected graphs. By default the graph is simplified. whereas a single ‘+’ character implies a directed graph.famous("Icosahedron")) graph.famous("Tetrahedron").com> See Also 127 graph can create arbitrary graphs.. see details below. You need to supply one or more R expressions giving the structure of the graph. Without arguments the function creates an empty graph: graph. graph.gabor@gmail. ie.formula is very handy for creating small graphs quickly. Details graph.famous("Cubical"). you may use as many ‘-’ characters to “draw” them as you like.famous("Dodecahedron"). simplify = TRUE) Arguments . Examples solids <. Usage graph..graph.famous("Octahedron").formula Creating (small) graphs via a simple interface Description This function is useful if you want to create a small (named) graph quickly. whether to call simplify on the created graph. If all edge operators consist of only ‘-’ characters then the graph will be undirected.formula Author(s) Gabor Csardi <csardi. the former is for the edges and the latter is used for arrow heads.

formula( A:B:C:D -. even ‘+’ and ‘-’ characters. . ‘++’ and ‘+-----+’ have exactly the same meaning.formula(A-B) graph.formula( A +. If the vertex names include spaces or other special characters then you need to quote them: graph. separate them with commas.128 A simple undirected graph with two vertices called ‘A’ and ‘B’ and one edge only: graph. If an edge operator connects two vertex sets then every edge from the first set will be connected to every edge in the second set.A:B:C:D ) In directed graphs.formula( A--B.B -.formula( A +-+ B +---+ C ++ D + E) Note again that the length of the edge operators is arbitrary. including loop edges: graph. C--D. You can also give isolate vertices.C ) Thus in the third example no edge is created between vertices B and C.B -+ C ) graph.formula Remember that the length of the edges does not matter. See more examples below. graph. ‘+’.formula( A -+ B -+ C ) graph. Mutual edges can be also created with a simple edge operator: graph. this creates the same graph: graph. edges will be created only if the edge operator includes a arrow head (‘+’) at the end of the edge: graph. I. K ) The ‘:’ operator can be used to define vertex sets.formula( A-----B ) If you have many disconnected components in the graph. The following form creates a full graph.formula( A +. G--H."a silly" -+ "graph here" ) You can include any character in the vertex names this way.formula( "this is" +. E--F. so we could have written the following. J.

full.formula( Alice +-+ Bob --+ Cecil +-.bipartite Value A new graph object.gabor@gmail. n2.bipartite (n1. Daniel-Cecil-Eugene. "*" -. Cecil:Daniel-Eugene:Gordon ) g2 # A directed graph g3 <. "in")) .formula( Alice +---------+ Bob ) g5 # Special vertex names g6 <."-".com> See Also graph for more general graph creation methods.formula( Alice-Bob-Cecil-Alice.formula( Alice-Bob:Cecil:Daniel. mode = c("all".graph.Daniel. This function creates a bipartite graph in which every possible edge is present."%/%" ) g6 129 graph.graph."/". "out".formula( Alice -. Eugene --+ Gordon:Helen ) g3 # A graph with isolate vertices g4 <. "%%" -.graph. Examples # A simple undirected graph g <. Author(s) Gabor Csardi <csardi.graph.full.formula( "+" -. Helen ) g4 V(g4)$name # "Arrows" can be arbitrarily long g5 <. ":" notation g2 <.graph.Daniel. Cecil-Gordon ) g # Another undirected graph.graph.full.Bob -. directed = FALSE.bipartite Create a full bipartite graph Description Bipartite graphs are also called two-mode by some. Usage graph. Cecil:Gordon.graph.

this is boolean and FALSE for the vertices of the first kind and TRUE for vertices of the second kind.bipartite(2. 3.hu/graphdb/gzip". with the ‘type’ vertex attribute set. 3) g2 <. The number of vertices of the second kind. Description This function downloads a graph from a database created for the evaluation of graph isomorphism testing algothitms. 3.full. prefix = "iso". Value An igraph graph. dir=TRUE) g3 <.full. Logical scalar. If this is ‘out’ then all vertices of the first kind are connected to the others. graph. type = "r 1". mode="all") graph.graphdb (url = NULL.rmki.130 Arguments n1 n2 directed mode The number of vertices of the first kind. ‘all’ creates mutual edges.graph.x Details Bipartite graphs have a ‘type’ vertex attribute in igraph. This argument is ignored for undirected graphs.graph.bipartite(2.bipartite(2. dir=TRUE. dir=TRUE. which = .graphdb Load a graph from the graph database for testing graph isomorphism.graphdb Scalar giving the kind of edges to create for directed graphs.kfki. ‘in’ specifies the opposite direction. nodes = NULL. Usage graph. base = "http://cneurocvs.full.graph.gabor@gmail. whether the graphs is directed.com> See Also graph. 3.bipartite(2. directed = TRUE) .graph. Author(s) Gabor Csardi <csardi. compressed = TRUE. mode="in") g4 <. pair = "A".full.full for creating one-mode full graphs Examples g <.

gz’ suffix is added to the filename. See the documentation for the graph database at http://amalfi. M. See details below. Pattern Recognition Letters. Sansone.com> References M. The number of vertices in the graph.vf2 . si6. Possible values: A and B. r 5. Logical constant. then the filename is assembled from the base. De Santo. Issue 8 (May 2003) See Also read. mcs1 . r 2. See details below. b 3m. 131 Gives the prefix. m4Dr4. This argument specifies which one to read. Specifies which graph of the pair to read. It has two modes of operation: If the url argument is specified then it should the complete path to a local or remote graph database file. Gives the number of the graph to read. If url is NULL. mcs5 .html for the actual format of a graph database file and other information. Foggia.graph. m3Dr6. whether to create a directed graph.it/graph/db/doc/ graphdbat. If url is NULL then a ‘.graph. i2. pair and which arguments. if TRUE than the file is expected to be compressed by gzip. See details below. nodes. and this is the default. Author(s) Gabor Csardi <csardi. m2Dr4.graphdb reads a graph from the graph database from an FTP or HTTP server or from a local copy.unina. m3Dr2. In this case we simply call read. graph. Value A new graph object. r 1. m4D. Possible values: r 1. b 3.isomorphic.dis. Possible values: iso. Gives the graph type identifier. m2Dr2. The base address of the database. nodes pair which base compressed directed Details graph. type. prefix. mcs3 . m3Dr4. b 6. C. Vento: A large database of graphs and its use for benchmarking graph isomorphism algorithms. m2Dr6 m3D.gabor@gmail. For every graph type there are a number of actual graphs in the database. b 9m. Volume 24. mcs9 . Logical constant. P.graphdb Arguments url prefix type If not NULL it is a complete URL with the file to import. b 9. m4Dr6. si4. m2D. m4Dr2.graph with the proper arguments to read the file. b 6m. mcs7 .

pair="B". If it is NULL then an unweighted graph is created and the multiple argument is used to determine the edges of the graph. then these are added as the ‘name’ vertex attribute. pair="A". directed = FALSE. "out". g2) g3 <. A character constant. Usage graph. Logical scalar. nodes=2 . then no vertex attributes (other than type) will be added. nodes=2 . multiple weighted add. which=1 . If this argument is NA. If you want a different vertex attribute for this.graphdb(prefix="iso". See details below. If this argument is NULL (the default) and the incidence matrix has both row and column names. then mutual edges are created. graph. If ‘all’ or ‘total’.graph. mode = c("all". ignored for undirected graphs. If it is a character constant then for every non-zero matrix entry an edge is created and the value of the entry is added as an edge attribute named by the weighted argument.names = NULL) Arguments incidence directed mode The input incidence matrix. then edges go from vertices of the first kind (corresponding to rows in the incidence matrix) to vertices of the second kind (columns in the incidence matrix).graph.graph.rmki. NA or NULL.incidence ## Not run: g <.graphdb(prefix="iso". compressed=TRUE) graph.incidence can add the row and column names of the incidence matrix as vertex attributes. This argument specifies whether to create a weighted graph from the incidence matrix.incidence(incidence. If ‘in’. add.names . then the opposite direction is used. "total"). weighted = NULL. defines the direction of the edges in directed graphs. specifies how to interpret the matrix elements. type="r 1". compressed=TRUE) g2 <.incidence Create graphs from an incidence matrix Description graph.A 9. type="r 1".gz") graph.vf2(g.hu/graphdb/gzip/iso/bvg/b 6m/iso_b 6m_m2 ## End(Not run) . Logical scalar.kfki.isomorphic. "in". then give the name of the attributes as a character string.132 Examples graph. It can also be a sparse matrix from the Matrix package. If it is TRUE then a weighted graph is created and the name of the edge attribute will be ‘weight’. whether to create a directed graph. If ‘out’. A character constant. multiple = FALSE. which=1 .incidence creates a bipartite igraph graph from an incidence matrix.graphdb(url="http://cneurocvs.

graph. 15.kautz Kautz graphs Description Kautz graphs are labeled graphs representing the overlap of strings.incidence can operate in two modes.com> See Also graph. the size of the alphabet. In other words.n) Arguments m n Integer scalar. If it is FALSE then a single edge is created for every non-zero element in the incidence matrix.letters[1:5] rownames(inc) <. an igraph graph that has a vertex attribute type. 5) colnames(inc) <. If multiple is TRUE. Usage graph. Integer scalar.incidence(inc) graph. See details below. graph. Value A bipartite igraph graph. the length of the labels. then the matrix elements are rounded up to the closest non-negative integer to get the number of edges to create between a pair of vertices.bipartite for another way to create bipartite graphs Examples inc <. See details below. Author(s) Gabor Csardi <csardi. 3.gabor@gmail.kautz Details 133 Bipartite graphs have a ‘type’ vertex attribute in igraph.kautz(m. repl=TRUE). .matrix(sample( :1.LETTERS[1:3] graph. this is boolean and FALSE for the vertices of the first kind and TRUE for vertices of the second kind. depending on the multiple argument.

line.kautz(2. Weight vector.de.2) graph. then vertex strength (see graph.knn A Kautz graph is a labeled graph. The vertices for which the calculation is performed. vertices are labeled by strings of length n+1 above an alphabet with m+1 letters.graph Examples line. If this argument is given. weights=NULL) Arguments graph vids The input graph. see eg. Value A graph object. weights .1)) graph.graph(graph. vids=V(graph). There is a directed edge from a vertex v to another vertex w if it is possible to transform the string of v into the string of w by removing the first letter and appending a letter to it. See Also graph. Author(s) Gabor Csardi <csardi. but it will be treated as undirected.gabor@gmail.knn(graph. the direction of the edges is ignored.knn Average nearest neighbor degree Description Calculate the average nearest neighbor degree of the given vertices and the same quantity in the function of vertex degree Usage graph. But note that knnk is still given in the function of the normal vertex degree. Kautz graphs have some interesting properties. that if not all vertices are given here. then both ‘knn’ and ‘knnk’ will be calculated based on the given vertices only.bruijn. i. then this is used by default.kautz(2.134 Details graph. Wikipedia for details. It can be directed. If the graph has a weight edge attribute.e.strength) is used instead of vertex degree. Normally it includes all vertices. with the restriction that every two consecutive letters in the string must be different.com>. Note. the first version in R was written by Vincent Matossian.

random.com> References Alain Barrat.star(1 ) graph. A numeric vector. the same is true for ‘knnk’ if a given degree never appears in the network.seq(ecount(g5)) graph. Acad. Proc. Natl.knn(g) g2 <.knn(g4) .graph. USA 101.ring(1 ) graph.gabor@gmail. The first element is the average nearest neighbor degree of vertices with degree one.graph. Romualdo Pastor-Satorras. Alessandro Vespignani: The architecture of complex weighted networks.knn Details 135 Note that for zero degree vertices the answer in ‘knn’ is NaN (zero divided by zero). try to plot ’knnk’ g3 <.ba.star(1 ) E(g5)$weight <.graph. its length is the maximum (total) vertex degree in the graph.knn(g3) # A random graph g4 <. Value A list with two members: knn knnk A numeric vector giving the average nearest neighbor degree for all vertices in vids. m=5) graph.graph.graph.game(1 graph. etc.game(1 . Author(s) Gabor Csardi <csardi. 3747 (2004) Examples # Some trivial ones g <. p=5/1 ) # A weighted graph g5 <. Marc Barthelemy.knn(g5) . Sci.knn(g2) # A scale-free one.

(i. The Matrix package is required for sparse matrices. If this is NULL and the graph has an edge attribute called weight. Logical scalar. I. An optional vector giving edge weights for weighted Laplacian matrix.laplacian Graph Laplacian Description The Laplacian of a graph. sparse=getIgraphOpt("sparsematrices")) Arguments graph normalized weights The input graph. -1/sqrt(d[i] d[j]) if i!=j and there is an edge between vertices i and j and 0 otherwise. Usage graph. The weighted degree of a vertex is the sum of the weights of its adjacent edges.laplacian graph. Value A numeric matrix. Set this to NA if you want the unweighted Laplacian on a graph that has a weight edge attribute.com> . A normalized version of the Laplacian Matrix is similar: element (i. and 0 otherwise.gabor@gmail.136 graph.j) is d[i]. -w if i!=j and there is an edge between vertices i and j with weight w. The weighted version of the Laplacian simply works with the weighted degree instead of the plain degree.j) is 1 if i==j. See definitions below. the degree of vertex i if if i==j.laplacian(graph. then it will be used automatically.e. whether to return the result as a sparse matrix.j) is d[i]. Whether to calculate the normalized Laplacian. Author(s) Gabor Csardi <csardi. weights=NULL. the weighted degree of vertex i if if i==j. -1 if i!=j and there is an edge between vertices i and j and 0 otherwise. normalized=FALSE. sparse Details The Laplacian Matrix of a graph is a symmetric matrix having the same number of rows and columns as the number of vertices in the graph and element (i.

the number of vertices in the graph.lcf Creating a graph from LCF notation Description LCF is short for Lederberg-Coxeter-Frucht. sparse=FALSE) 137 graph.graph.famous("Franklin") graph.graph. Author(s) Gabor Csardi <csardi. 6) g2 <. it is a concise notation for 3-regular Hamiltonian graphs.lcf(12. c(5. g2) Integer. repeats) Arguments n shifts repeats Value A graph object.com/LCFNotation.html for details. a list of shifts giving additional edges to a cycle backbone and another integer giving how many times the shifts should be performed. Examples # This is the Franklin graph: g1 <.-5). Integer vector.laplacian(g) graph. the number of vertices in the graph.ring(1 ) graph. how many times to repeat the shifts.com> See Also graph can create arbitrary graphs. shifts.lcf Examples g <.graph. norm=TRUE.lcf(n. norm=TRUE) graph.graph. See http://mathworld.gabor@gmail. It constists of three parameters. . Usage graph.wolfram.laplacian(g.vf2(g1. the shifts. Integer constant.laplacian(g. see also the other functions on the its manual page for creating special graphs.isomorphic.

A matching is a maximum matching if there exists no other .matching checks a matching vector and verifies whether its length matches the number of vertices in the given graph.138 graph. The size (or cardinality) of a matching is the number of edges. this argument is ignored. This is required to avoid the accumulation of numerical errors. For bipartite graphs. eps = .matching calculates a maximum matching in a bipartite graph. Vertex types. types = NULL.maximal. types = NULL) is.matching(graph. i. A potential matching. matching.maximal. it also verifies whether the matched vertices are in different parts of the graph. its values are between zero (inclusive) and the number of vertices (inclusive). Details is. For vertices without a pair. and matched vertices must be connected by an edge in the graph. is. then the edge attribute is used automatically. supply NA here. Usage is. A small real number used in equality tests in the weighted bipartite matching algorithm. A matching in a bipartite graph is a partial assignment of vertices of the first kind to vertices of the second kind such that each vertex of the first kind is matched to at most one vertex of the second kind and vice versa.matching(graph. If you are running the algorithm with no weights. By default they are taken from the ‘type’ vertex attribute. Potential edge weights. weights = NULL.Machine$double. such that 1 + x = 1 holds. they have no common incident vertices. A matching is maximal if and only if there exists no unmatched vertex in a graph such that one of its neighbors is also unmatched.bipartite. types = NULL) maximum. and whether there exists a corresponding edge in the graph for every matched vertex pair. if present.matching Graph matching Description A matching in a graph means the selection of a set of edges that are pairwise non-adjacenct.e. By default it is set to the smallest x. An integer vector that gives the pair in the matching for each vertex. maximum.matching(graph. A matching is maximal if it is not a proper subset of any other matching. It might be directed. Two real numbers are considered equal in the algorithm if their difference is smaller than eps. matching. if the graph is bipartite.bipartite.matching checks whether a matching is maximal. but edge directions will be ignored.eps) Arguments graph types matching weights eps The input graph. If the graph has an edge attribute called ‘weight’.matching graph. and this argument is NULL.

graph. length=vcount(g2)) str(g2. matching The matching itself. Author(s) Tamas Nepusz <ntamas@gmail. or vertex names if the graph was named.TRUE).matching(g2) # maximal matching # non-maximal matching # not a matching . "d". i. "c".bipartite. m1) is. a maximum matching is a matching whose edges have the largest possible total weight among all possible matchings. m2) is.matching returns a list with components: matching_size matching_weight The weights of the matching.c("b". m1) is.maximal.com> Examples g <.graph. "f". The size of the matching.matching(g.c(FALSE. m3) is.formula( a-b-c-d-e-f-g ) V(g2)$type <. Maximum matchings in bipartite graphs are found by the push-relabel algorithm with greedy initialization and a global relabeling after every n/2 steps where n is the number of vertices in the graph. For weighted graphs. NA) m3 <. Value is. "a". "d". "e") m2 <.matching(g.matching(g. NA) is. if the graph was weighted.bipartite. Numeric vertex id.rep(c(FALSE.e.c("b".maximal. v=TRUE) maximum. NA. NA.maximal. "c".matching 139 matching with larger cardinality. "c". Non-matched vertices are denoted by NA.matching(g.matching return a logical scalar. "c". v=TRUE) maximum.graph.matching(g.maximal.matching(g) g2 <. m3) V(g)$type <. m2) is. the number of edges connecting the matched vertices. maximum. "d".c("b".formula( a-b-c-d-e-f ) m1 <.matching and is. "a".bipartite.TRUE) str(g. For unweighted graphs this is the same as the size of the matching.matching(g.

the only difference is that graph. source.mincut can be invoked without giving the source and target arguments and then minimum of all possible minimum cuts is calculated. (Which is to make the graph not strongly connected in the directed case. source=NULL. . The value of the flow is the incoming flow of the target vertex. target=NULL. Usage graph.) The maximum flow between two vertices in a graph is the same as the minimum st-cut. capacity=NULL.only = TRUE) Arguments graph source target capacity value.only The input graph.maxflow calculates the maximum flow between two vertices in a weighted (ie. so graph. The minimum st-cut between source and target is the minimum total weight of edges needed to remove to eliminate all paths from source to target. A flow from source to target is an assignment of non-negative real numbers to the edges of the graph. The minimum cut of a graph is the minimum total weight of the edges needed to remove to separate the graph into (at least) two components. if FALSE the edges in the cut and a the two (or more) partitions are also returned.mincut calculates the minimum st-cut between two vertices in a graph (if the source and target arguments are given) or the minimum cut of the graph (if both source and target are NULL).maxflow and graph. satisfying two properties: (1) for each edge the flow (ie. The maximum flow is the flow of maximum value. capacity=NULL) graph. Vector giving the capacity of the edges.maxflow(graph. if TRUE only the minumum cut value is returned.maxflow graph. If this is NULL (the default) then the capacity edge attribute is used. valued) graph. value.maxflow Maximum flow in a network Description In a graph where each edge has a given flow capacity the maximal flow between two vertices is calculated. except the source and the target the incoming flow is the same as the outgoing flow. target. Logical scalar. graph.mincut essentially calculate the same quantity. The id of the target vertex (sometimes also called sink). the assigned number) is not more than the capacity of the edge (the capacity parameter or edge attribute).140 graph. The id of the source vertex. Details graph.mincut(graph. (2) for every vertex.

Tarjan: A New Approach to the Maximum Flow Problem Journal of the ACM 35:921-940.graph.maxflow 141 For undirected graphs the Stoer-Wagner algorithm (see reference below) is used to calculate the minimum cut. the value of the minimum cut. Positive values mean that the flow goes from the smaller vertex id to the bigger one. the vertices in the second partition of the minimum cut corresponding to the maximum flow. partition2 Author(s) Gabor Csardi <csardi.maxflow a named list with components: value flow A numeric scalar. this means that the flow goes from the bigger vertex id to the smaller one. since for these the flow direction is not predetermined by the edge direction. as the graph may fall apart into more than two components. Stoer and F. cut partition1 partition2 For graph. A numeric vector. V. except if value. as the graph may fall apart into more than two components. 1988.connectivity. See Also shortest.paths. Note that these vertices might be actually in different components (after the cut edges are removed). 44 585-591.connectivity . the flow itself. Note that these vertices might be actually in different components (after the cut edges are removed). A numeric vector of vertex ids. Goldberg and R. A numeric vector of edge ids.mincut a numeric constant. Value For graph. The vertices in the first partition after the cut edges are removed. For undirected graphs this entry is bit trickier.only=FALSE. Wagner: A simple min-cut algorithm. Journal of the ACM. In this case a named list with components: value cut partition1 Numeric scalar.com> References A. A numeric vector of vertex ids. edge.gabor@gmail. the vertices in the first partition of the minimum cut corresponding to the maximum flow. The vertices in the second partition after the cut edges are removed. the cut value. one entry for each edge. the minimum cut corresponding to the maximum flow. the value of the maximum flow. the edges in the cut. Numeric vector. 1997. For these graphs the elements of the this vector can be negative. M. E. vertex.

1 . weights = NULL) Arguments graph vids mode loops weights The input graph. "capacity") g1 <.1).6.graph( c(1. capacity=rep(1.data. "total"). Weight vector.gabor@gmail. then this is used by default. target=V(g1)["2"]) g <.6. 4. The vertices for which the strength will be calculated. value.3).5. Character string.graph.mincut(g.5.3. loops = TRUE. source=V(g1)["1"].frame(E)) graph.ring(1 ) graph.6.only=FALSE) graph.2. “in” for in-degree or “all” for the sum of the two.c("from". then a warning is given and degree is called. If the graph does not have a weight edge attribute and this argument is NULL.1. vids = V(graph). capacity=rep(1. 2) graph.2.2. "to".mincut(g2. Logical.frame(as.4.c(3.3. whether the loop edges are also counted.1.only=FALSE.mincut(g. c(1. “out” for out-degree.strength graph.com> .strength Strength or weighted vertex degree Description Summing up the edge weights of the adjacent edges for each vertex.2. c(3. "out".vcount(g))) graph.2. Value A numeric vector giving the strength of the vertices.4.2).graph. c(4. 1.5. c(5.3.3. For undirected graphs this argument is ignored.maxflow(g1.strength (graph. "in".vcount(g))) g2 <. Author(s) Gabor Csardi <csardi.2). mode = c("all". If the graph has a weight edge attribute.data. c(6. value.142 Examples E <.1 )) colnames(E) <.rbind( c(1.1) ) E(g2)$capacity <.1). Usage graph.4.

Marc Barthelemy. to. .strength(g) graph... j. ... edges=FALSE.) vertices(. to.structure Method for structural manipulation of graphs Description These are the methods for simple manipulation of graphs: adding and deleting edges and vertices. from.graph. from...e2 vertex(.star(1 ) E(g)$weight <. Sci..strength(g. drop=TRUE. mode="in") # No weights.. mode="out") graph.graph.ring(1 ) graph. 3747 (2004) See Also degree for the unweighted version..) edge(...seq(ecount(g)) graph..strength(g. Usage ## S3 method for class ’igraph’ x[i. Proc..graph. a warning is given g <.. Examples g <..strength(g) graph. sparse=getIgraphOpt("sparsematrices").weighted(x)) "weight" else NULL] ## S3 method for class ’igraph’ x[[i. j.) .value ## S3 method for class ’igraph’ e1 + e2 ## S3 method for class ’igraph’ e1 .. directed=TRUE. Romualdo Pastor-Satorras. Natl. j. edges=FALSE.. .structure References 143 Alain Barrat. Acad. attr=if (is. USA 101.weighted(x)) "weight" else NULL] <.) edges(. exact=TRUE]] ## S3 replacement method for class ’igraph’ x[i. attr=if (is. Alessandro Vespignani: The architecture of complex weighted networks.

edges and add. It is ignored for undirected graphs.) See details below. Vector sequence.... For the indexing operators: if not NULL.. or updated to the given value. then the specified edges will be added.vertices these additional parameters will be added as edge/vertex attributes. then it should be the name of an edge attribute. the vertices to remove. Numeric constant.. by and large. attr=list()) delete. Vertex ids or names or logical vectors. edges. These arguments are ignored. whether to consider edge directions in directed graphs. then the from argument must be present as well. then the specified edges will be deleted.. . The single bracket indexes the (possibly weighted) .vertices(graph. If TRUE or a non-zero numeric value. .. nv. A logical or numeric scalar or NULL. it can be used to query/set a sequence of edges.edges and add. vertices. If FALSE.. Logical scalar. NULL or zero. A numeric or character vector giving vertex ids or names. The first way is using the ‘[’ and ‘[[’ indexing operators on the graph object. Logical scalar. whether to return edge ids. edges) delete. This argument cannot be present together with any of the i and j arguments and if it is present. three ways to manipulate the structure of a graph in igraph. edges and path see details below. graph.structure These are currently ignored for the indexing operators. A numeric or character vector giving vertex ids or names. the number of vertices to add. Together with the from argument. This argument cannot be present together with any of the i and j arguments and if it is present. For add..edges(graph. whether to use sparse matrix.e1 i.exact value e2 attr nv v Details There are. See details below. Note that these arguments have to be named. it can be used to query/set a sequence of edges.. For vertex. This attribute is queried. v) Arguments x. Together with the to argument. The graph to work on.graph. (Only if they don’t yet exist.144 path(. This will be concatenated to the other supplied attributes.vertices: additional edge/vertex attributes to add. from to sparse directed edges drop. very much like the graph was an adjacency matrix ([) or an adjacency list ([). then the to argument must be present as well. Logical scalar. See details below.vertices(graph. For add. See details below.) add.j . attr=list()) add. edge.edges(graph.

and is usually the best if the user also wants to add attributes. 5. zero otherwise.5)] <. The from and to arguments can be used to check the existence of many edges. add. The indexing operators The one-bracket (‘[’) and two-brackets (‘[[’) indexing operators allow relatively straightforward query and update operations on graphs. add.1 graph[from=1:3. Extract the (sparse) adjacency matrix of the graph. or part of it: graph[] graph[1:3. graph[1.1 graph[1:3. The addition (‘+’) and division (‘-’) operators can also be used to add and remove vertices and edges. 2] <. Value For the indexing operators see the description above. to=c(2. 4. to=c(2. but queries the adjacencly list of the graph. For non-esistent edges zero weights are returned. both from and to must be present and they must have the same length. Querying edge ids instead of the existance of edges or edge attributes. w] A numeric scalar is returned. In addition.structure 145 adjacency matrix of the graph.3. together with the new vertices/edges. 2. The details on how to use the indexing operators are discussed below. Check whether there is an edge between two vertices (v and w) in the graph: graph[v. delete. by giving the attr argument. it contains ones for existing edges edges and zeros for non-existing ones. They must contain vertex ids or names. Other edge attributes can be queried as well.graph.edges can also be used to manipulate the structure. 2.5:6] graph[c(1. the other two return part of it. the four functions. The double bracket operator is similar. 6. one if the edge exists. Here is what you can do with it: 1.vertices and delete. In this case.3. Adding one or more edges to a graph. Please see the details below. E.5)] .1] <. For this the element(s) of the imaginary adjacency matrix must be set to a non-zero numeric value (or TRUE): graph[1. or zero if there is no such edge.TRUE .] The first variants returns the full adjacency matrix. The one bracket operator works on the (imaginary) adjacency matrix of the graph. the [ operator returns the edge weights.5). 3.g. edges=TRUE] returns the id of the edge between vertices 1 and 2.vertices.edges. For weighted graphs. This form is sometimes more readable. of the same length as from and to.3. Example: graph[from=1:3. A numeric vector is returned. The other functions return a new graph.

Adding weighted edges to a graph.TRUE . 8. to=w] <. edges=TRUE]] gives the edge ids of all the edges that exist from vertices v to vertices w. no multiple edges are created. then the attr="weight" setting is implicit. graph[[v. by specifying FALSE or NULL as the replacement value: graph[v.structure This does not affect edges that are already present in the graph. and G <. w] <. If the graph is already weighted. so it does not have to be ‘weight’: graph[1. E.g. attr="weight"]<. then only its weigths or other attribute are updated.5)] <. 7. if the edges argument is set to TRUE: graph[[1:3. if both indices are used. Deleting edges. . and one does not need to give it explicitly. w] <.]] graph[[.g. Both the ‘[’ and ‘[[’ operators allow logical indices and negative indices as well. to=c(2.) 2. graph[degree(graph)== .3.FALSE removes the edge from vertex v to vertex w. 1:3. i.1] <. Querying the adjacent vertices for one or more vertices: graph[[1:3.146 graph.graph. As this can be used to delete edges between two sets of vertices. edges=TRUE]] graph[[. either pairwise: graph[from=v.empty(1 ) G[-1. 1] <. (For undirected graphs they are equivalent. The attr argument contains the name of the edge attribute to set.4) If an edge is already present in the network. E.c(1. Querying the edge ids between two sets or vertices.e. edges=TRUE]] 3.1:3]] The first form gives the successors. Querying the incident edges for one or more vertices. 2.-1.5 graph[from=1:3.FALSE if v and w are vectors of edge ids or names.FALSE or not: graph[v. w.1 adds an edge from every isolate vertex to vertex one. the second the predessors or the 1:3 vertices. The double bracket operator indexes the (imaginary) adjacency list of the graph. This can used for the following operations: 1. The replacement syntax allow the deletion of edges. with the usual R semantics.

The unnamed arguments of edges are concatenated and used as vertex ids of the end points of the new edges. The new edges and possibly their attributes can be specified as the arguments of the edges function. • If it is an object created with the vertex or vertices function. • If it is a numeric scalar. then the disjoint union of the two graphs is calculated.empty() + vertices(letters[1:1 ]) + vertices("foo". "bar".g + edge("a". then new vertices are added to the graph. "foobar2". the indexing operators support vertex names. "foobar2") g <. color="red") vertex("foo". edge is just an alias to edges and it is provided for readability. The edges and possibly their attributes are specified as the arguments to the path function. The user should use it if a single edge is added to the graph.graph. weight=1:2) See more examples below. The unnamed arguments of vertices are concatenated and used as the ‘name’ vertex attribute (i. "bar2". • If it is an object created with the edge or edges function. color="red". .graph. "bar". This form is appropriate when one wants to add some vertex attributes as well. vertex names). then new edges that form a path are added.e.structure creates a star graph. and it is provided for readability. The plus operator for adding vertices and edges The plus operator can be used to add vertices or edges to graph. shape="rectangle") See more examples below. vertex is just an alias to vertices. "foo". "b") g <. • If it is another igraph graph object.disjoint. "foobar") vertices("bar2". Examples: g g g g <<<<g g g g + + + + vertex(shape="circle". then the specified number of vertices are added to the graph. The user should use it if a single vertex is added to the graph. then it is interpreted as the names of the vertices to add to the graph.g + edges("foo". the named arguments will be added as additional vertex attributes. "foobar2".union. The operands of the vertices function specifies the number of vertices to add and their attributes as well. • If it is a character scalar or vector. see graph.g + edges(c("bar". "bar2". Examples: g <. color=1:2. The actual operation that is performed depends on the type of the right hand side argument. "foobar2") g <. so instead of a numeric vertex id a vertex can also be given to ‘[’ and ‘[[’. The named arguments will be added as edge attributes. "bar2"). • If it is an object created with the path function. then new edges will be added to the graph. 147 Of course. color="blue") vertex("bar".

difference."foo" + "bar" + graph. width=1:3. created by the E function). • If it is an object created with the vertex (or the vertices) function.empty() it is not associative. i.empty() results a syntax error. The operation performed is selected based on the type of the right hand side argument: • If it is an igraph graph object.ring(1 ) V(g)$name <. then the difference of the two graphs is calculated. then these edges will be deleted from the graph."foo" + ( "bar" + graph.graph.e. "d") g + path("e". graph <.empty() + vertices(letters[1:1 ]) g + path("a". then all arguments of vertices are concatenated and the result is interpreted as a vector of vertex ids. "c".empty() + "foo" + "bar" The minus operator for deleting vertices and edges The minus operator (‘-’) can be used to remove vertices or edges from the graph.148 graph.g. see graph. "d")."foo" + graph. Example: g <. is possible to write graph <. • If it is an object created with the edge (or the edges) function. color="red") g + path(c("f". The remaining arguments are added as edge attributes. • If it is an edge sequence (e. then these vertices will be deleted from the graph. "b".structure The non-named arguments are concatenated and interpreted as the vertex ids along the path. Examples: g g g g <<<<graph. then it is interpreted as a vector of vertex ids and the specified vertices will be deleted from the graph.graph. "j". weight=1:2. we suggest to always put the graph object on the left hand side of the operator: graph <. These vertices will be removed from the graph. Example: .g . e.c("a". "f". created by the V function).g. color="green") It is important to note that. "g". then all arguments of edges are concatenated and then interpreted as edges to be removed from the graph.g. "c".letters[1:1 ] g <. "b") • If e2 is a vertex sequence (e. • If it is a numeric or character vector. unless parentheses are used: graph <. although the plus operator is commutative.empty() ) For clarity.

edges(g.layout. 2. 1 . letters[1]. Example: g <. delete.graph. The ids of the vertices are not preserved. The additionally supplied named arguments will be added as vertex attributes for the new vertices.g + path(letters[1:1 ]. The additionally supplied named arguments will be added as edge attributes for the new edges. If an attribute was not present in the original graph. The ids of the vertices are preserved.circle if (interactive()) { plot(g) } # The old-style operations g <. E(g.graph.3)) ) .b.letters[1:1 ] E(g)$name <. add.graph.ring(1 ) V(g)$name <.vertices removes the specified vertices from the graph together with their adjacent edges. and no edges g <. If a specified edge is not present.3. its value for the original edges will be NA. delete.graph. and the original graph remains unchanged.LETTERS[1:1 ] g <. replace=TRUE).edges adds the specified edges to the graph. its value is set to NA for the original vertices.structure g <.edges(g. If an attribute was not present in the original graph..letters[1:1 ] g <. "d") More functions to manipulate graph structure add.g .g .7) ) delete. The ids of the vertices are preserved.graph. "c".empty() + vertices(letters[1:1 ]) # Add edges to make it a ring g <.edges removes the specified edges from the graph.ring(1 ) V(g)$name <. "b". color="red") g$layout <.vertices adds the specified number of isolate vertices to the graph.ring(1 ) add. color="grey") # Add some extra random edges g <.gabor@gmail..c.1 .edge("H") 149 • If it is an object created with the path function.g . P=c(1.edge("e|f") g <.com> Examples # 1 vertices named a.g + edges(sample(V(g)..6.path("a". then all path arguments are concatenated and then interpreted as a path along which edges will be removed from the graph. Author(s) Gabor Csardi <csardi. The ids of the old vertices are preserved. c(2. the function gives an error message.

c(2.B} edge graph. This function creates an igraph graph object from such a list.adjlist.vertices(g. Note that the list is expected to be 0-indexed. "all". E. it specifies whether the graph to create is undirected (‘all’ or ‘total’) or directed. Character scalar.e.adjlist. It should be consistent. whether it contains the outgoing (‘out’) or the incoming (‘in’) neighbors of the vertices. duplicate = TRUE) Arguments adjlist The adjacency list.8) ) Graphs from adjacency lists Graphs from adjacency lists Create graphs from adjacency lists Description An adjacency list is a list of numeric vectors. Logical scalar. mode duplicate Details Adjacency lists are handy if you intend to do many (small) modifications to a graph. The idea is that you convert your graph to an adjacency list by get. Author(s) Gabor Csardi <csardi. For undirected graphs it gives whether edges are included in the list twice. containing the neighbor vertices for each vertex. mode = c("out". if it is TRUE then for an undirected {A.7. "in". "total"). and in the latter case.150 delete. Value An igraph graph object. the maximum throughout all vectors in the list must be less than the number of vectors (=the number of vertices in the graph).adjlist expects A included in the neighbors of B and B to be included in the neighbors of A.com> . i. In this case adjacency lists are more efficient than igraph graphs.adjlist(adjlist. do your modifications to the graphs and finally create again an igraph graph by calling graph. This argument is ignored if mode is out or in.gabor@gmail.g. Usage graph.

graph.multiple(g3) 151 grg.isomorphic(g. mode="all") graph.adjlist(g) g2 <. g2) ## Undirected g <. radius. duplicate=FALSE) ecount(g3) is. Details First a number of points are dropped on a unit square. If the torus argument is TRUE then a unit area torus is used instead of a square. dir=TRUE) al <. Logical scalar.graph.graph. The radius within which the vertices will be connected by an edge.game Geometric random graphs Description Generate a random graph based on the distance of random point on a unit square Usage grg.graph.ring(1 .adjlist(al) graph.graph.grg.ring(1 ) al <. these points correspond to the vertices of the graph to create. Two points will be connected with an undirected edge if they are closer to each other in Euclidean norm than a given radius. Logical constant. whether to add the positions of the vertices as vertex attributes called ‘x’ and ‘y’.adjlist(g.adjlist(al. torus = FALSE.game(nodes. whether to use a torus instead of a square.get.game See Also get. g2) ecount(g2) g3 <. .get.isomorphic(g. coords = FALSE) Arguments nodes radius torus coords The number of vertices in the graph. mode="all". mode="out") g2 <.adjlist(al.edgelist Examples ## Directed g <.

torus=FALSE) . . Logical.random.game(1 g2 <.com> See Also random. Value A new graph object. Author(s) growing.game(n.grg. number of edges added in each time step. Author(s) Gabor Csardi <csardi.gabor@gmail. If coords is TRUE then with vertex attributes ‘x’ and ‘y’.152 Value A graph object.game Gabor Csardi <csardi. ie. 5. whether to create a directed graph. number of vertices in the graph. Details This is discrete time step model.grg. directed = TRUE. Usage growing.random. torus=TRUE) growing.game Growing random graph generation Description This function creates a random graph by simulating its stochastic evolution. citation = FALSE) Arguments n m directed citation Numeric constant.game Examples g <. first version was written by Keith Briggs <keith.briggs@bt.gabor@gmail. If TRUE a citation graph is created. m = 1. otherwise the edges are connecting new vertex to uniformly randomly chosen old vertices. If citation is FALSE these edges are connecting two uniformly randomly chosen vertices.graph. Numeric constant. in each time step a new vertex is added to the graph and m new edges are created. 5. in each time step the added edges are originating from the new vertex.game(1 .random. Logical.com> . .com>.

) start steps . type=c("auto".predict allow this to be NULL as well..growing. . If this is zero. A hierarchical random graph model.consensus and hrg. steps = ) hrg. erdos. Usage hrg. hrg = NULL.samples = 1 hrg. "plain"). . from a random starting point. start = FALSE.game Examples g <. whether to start the fitting/sampling from the supplied igraphHRG object. then a HRG is fitted to the graph first. hrg. or from a random starting point. level = 3.game(5 .) ## S3 method for class ’igraphHRGConsensus’ print(x. in which case a random starting point is used for the fitting. Logical.fit (graph. start = FALSE.renyi.. citation=TRUE) 153 Hierarchical random graphs Hierarchical random graphs Description Fitting and sampling hierarchical random graph models. The number of MCMC steps to make. num. "tree".bins = 25) ## S3 method for class ’igraphHRG’ print(x. in the form of an igraphHRG object..game(5 .Hierarchical random graphs See Also barabasi. .growing.random. Edge directions are ignored in directed graphs.) Arguments graph hrg The graph to fit the model to.game.predict (graph.consensus (graph.random. citation=FALSE) g2 <..samples = 1 num. num. start = FALSE. then the MCMC procedure is performed until convergence. hrg = NULL.game (hrg) hrg. prob) hrg.fit allows this to be NULL. hrg = NULL.dendrogram (hrg) hrg.create (graph. hrg.

proportionally to their likelihood. It takes the specified steps number of MCMC steps to perform the fitting. hrg.game samples a graph from a given hierarchical random graph model. where the internal vertices are labeled with probabilities. igraphHRG or igraphHRGConsensus object to print. igraph contains functions for fitting HRG models to a given network (hrg.fit can start from a given HRG.edu/~aaronc/hierarchy/.santafe. A hierarchical random graph is an ensemble of undirected graphs with n vertices.. http://tuvalu. hrg. these are ignored for leaf vertices.consensus creates a consensus tree from several fitted hierarchical random graph models. not used currently. The probability that two vertices are connected in the random graph is given by the probability label at their closest common ancestor. or a convergence criteria if the specified number of steps is zero. This is done by sampling hierarchical models around the optimum model.dendrogram).samples prob num.predict).dendrogram creates the corresponsing igraph tree of a hierarchical random graph model. hrg. The igraph HRG implementation is heavily based on the code published by Aaron Clauset. The prob argument contains the HRG probability labels for each vertex. at his website. one for each vertex.bins x type level .create creates a HRG from an igraph graph. A vector of probabilities. if it is given and the start argument is set to TRUE. Please see references below for more about hierarchical random graphs. hrg. Value hrg. If the hrg argument is given and start is set to TRUE.create.. Details Hierarchical random graphs Number of samples to use for consensus generation or missing edge prediction. Number of bins for the edge probabilities. then it starts sampling from the given HRG. converting an igraph graph to a HRG and back (hrg. with n − 1 internal and n leaf vertices. How to print the dendrogram. Otherwise a HRG is fitted to the graph first.fit. Give a higher number for a more accurate prediction. and then samples starting from the optimum. for calculating a consensus tree from a set of sampled HRGs (hrg.154 num. see details below. The number of top levels to print from the dendrogram.consensus) and for predicting missing edges in a network based on its HRG models (hrg. for generating networks from a given HRG ensemble (hrg.game). hrg.fit returns an igraphHRG object. in the order of vertex ids. Additional arguments.predict uses a hierarchical random graph model to predict missing edges from a network. hrg. This is a list with the following members: . The igraph graph must be a directed binary tree. hrg. It is defined via a binary tree with n leaf and n − 1 internal vertices. The MCMC sampling is stated from hrg. hrg. using phylogeny methods. Otherwise it optimizes the HRG log-likelihood first. if this is given in the hrg argument and the start argument is TRUE.fit fits a HRG to a given graph.

88 6 3 9 4 2 1 7 5 8 . including itself. etc.dendrogram returns an igraph graph.e. The root node of the HRG is always vertex group #1 (‘g1’ in the the printout). so the first element of the vector is the left child of the root vertex. The first vertex is always the root vertex.5 . and the top three levels of the fitted hierarchical random graph are printed. if the vertex is the root vertex in the tree. starting from zero and up. and another larger subgroup that contains vertices 6. Vertex pairs in the left subtree of g1 connect to vertices in the right subtree with probability zero. or zero. The tree format looks like this: Hierarchical g1 p= ’. the second is an igraphHRG object. The first n vertex ids (from 0) refer to the original vertices of the graph. on lower levels.g15 p= ’. Leaf vertices are denoted by non-negative number. weights hrg. the root vertex is -1. depending on the type argument of the print function. the other ids refer to vertex groups. The number of edges in the subtree below the given internal vertex. The connection probabilities attached to the internal vertices. Vector that contains the right children of the vertices.33 1 .consensus returns a list of two objects.create returns an igraphHRG object. according to the fitted model.g5 p= random graph. at level 3: . internal vertex -1).g16 p= ’.2 2 14 17 19 11 15 16 13 12 18 This is a graph with 20 vertices. g15 and g8. The igraphHRGConsensus object has the following members: parents For each vertex. right prob edges vertices hrg. but less visual: . etc. The plain printing is simpler and faster to produce. The first is an igraphHRGConsensus object. with the same encoding as the left vector. g1 has two subgroups. the id of its parent vertex is stored. which selects tree for small graphs and simple (=list) for bigger ones. the first number belongs to the root vertex (i. The number of vertices in the subtree below the given internal vertex.game returns an igraph graph. counts the number of times a given tree split occured in the generated network samples. hrg. g15 has a subgroup of a single vertex (vertex 1). etc. Printing HRGs to the screen igraphHRG objects can be printed to the screen in two forms: as a tree or as a list. 3. hrg. By default the auto type is used. the second to internal vertex -2.g8 p= ’.e. The order is the same as in the parents vector. Numeric vector. Internal vertices are denoted with negative numbers. i.Hierarchical random graphs left 155 Vector that contains the left children of the internal tree vertices. for each internal vertices. starting from -1 and going down.g13 p= ’.

SpringerVerlag.1 -> g9 3 g4 g5 g11 p=1. Copy and paste them by hand to your R prompt if you want to run them.2 -> g13 p= . Structural Inference of Hierarchies in Networks. in as many columns as the screen width allows. start=TRUE) . 1–13.3 p= . -> 2 6 g13 g2 g17 p= .E. -> g6 5 g14 9 g14 p=1. -> 7 1 g17 15 g5 p= . 98–101 (2008). and it has two subgroups.erdos. Berlin Heidelberg (2007). hrg=hrg.renyi. Airoldi et al. -> g7 p=1.com>. p= . -> g16 p=1. -> g4 p=1. (Eds.consensus(g. Consensus dendrograms (igraphHRGConsensus objects) are printed simply by listing the children of each internal node of the dendrogram: HRG consensus tree: g1 -> 11 12 13 14 15 16 17 18 19 2 g2 -> 1 2 3 4 5 6 7 8 9 1 g3 -> g1 g2 The root of the dendrogram is g3 (because it has no incoming edges). thanks Aaron! References A.renyi. and M. Clauset. -> -> -> -> -> -> g18 14 1 4 g11 g16 g8 8 g19 18 12 19 It lists the two subgroups of each internal node. Hierarchical structure and the prediction of missing links in networks. and M. p=1/2) hrg <. p=1/2) + erdos.J. In E. C.J.): ICML 2006 Ws. Examples ## ## ## ## We are not running these examples any more.5 -> g7 13 g3 2 Hierarchical random graphs g3 g6 g9 g12 g15 g18 p=1. Moore.2 p=1. g1 and g2.156 Hierarchical g1 p= .game(1 . p= .8 p= . A. Moore.fit(g) hrg ## The consensus tree for it hrg. Lecture Notes in Computer Science 4503. -> g19 p= .hrg. Clauset. based on code from Aaron Clauset. C.gabor@gmail. ## Not run: ## A graph with two dense groups g <. Nature 453. Newman.game(1 . M. Author(s) Gabor Csardi <csardi.7 -> random graph: g12 g1 g2 p=1. because they take a long time (~15 seconds) to run and this is against the CRAN repository policy.E.4 -> g15 17 11 16 g8 p= . -> g1 p= . Newman.

full(4) . The console is written in Tcl/Tk and required the tcltk package. until the user closes it. to close it.console() Details The console can be started by calling the igraph. Then the console (re)opens each time an igraph function supporting it starts. Usage igraph.graph.console function.path(1.options.com> See Also igraph.2)) hrg.options and the verbose option.full(4) + (graph. invisibly. Value NULL. Author(s) Gabor Csardi <csardi.predict(g2) ## End(Not run) 157 igraph console The igraph console Description The igraph console is a GUI windows that shows what the currently running igraph function is doing. .igraph console ## Prediction of missing edges g2 <. set the verbose option to another value.gabor@gmail. Another way to start it to set the verbose igraph option to “tkconsole” via igraph. Then it stays open.

158 igraph options igraph options Parameters for the igraph package Description igraph has some parameters which (usually) affect the behavior of many functions. By default it is TRUE.names Logical scalar. See dendPlot for details.options and getIgraphOpt functions instead. add. for instance by insertions of appropriate calls to igraph. whether to add vertex names to node level indices. or any number of arguments may be in the name=value form. x default parid parvalue Details From igraph version 0. These can be set for the whole session via igraph.) getIgraphOpt(x. betweenness scores. Possible values are ‘auto’ (the default). default = NULL) igraph. See the Value and Details sections for explanation. ‘hclust’ and ‘dendrogram’. The new value of the parameter. The parameter values set via a call to the igraph. dend. igraph.options function will remain in effect for the rest of the session. This offers the possibility of customizing the functioning of the igraph package. whether to add model parameter to the graphs that are created by the various graph constructors.params Logical scalar. The currently used parameters in alphabetical order: add. Usage igraph. See the currently used parameters below. ‘phylo’.options in a load hook for package igraph.plot. If the specified option is not set in the options list. By default it is TRUE...6.par is deprecated.options(. this value is returned..par(parid. A list may be given as the only argument. This facilitates retrieving an option and checking whether it is set and setting it separately if not.. parvalue = NULL) Arguments . Please use the more flexible igraph.type The plotting function to use when plotting community structure dendrograms via dendPlot. A character string holding an option name. If NULL then the current value of the parameter is listed. The name of the parameter. like degree. . etc. affecting the subsequent behaviour of the other functions of the igraph package for which the given parameters are relevant.vertex.options. or no argument at all may be given.

attr. See nexus for details.options(verbose=oldval) . Examples oldval <. Defaults to FALSE. Otherwise the new value of the parameter is returned invisibly. If the argument list is not empty.attributes Logical constant.attr. whether to print graph attributes when printing graphs. whether to print vertex attributes when printing graphs. or NULL if the option is unset. whether igraph functions should talk more than minimal.attributes Logical constant. print.vertex.getIgraphOpt("verbose") igraph. Author(s) Gabor Csardi <csardi.ring(1 )) igraph. For getIgraphOpt. The default value is list(weight="sum". nexus. Defaults to FALSE. print.combination for details on this.comb Specifies what to do with the edge attributes if the graph is modified.attributes Logical constant. The default value is list(name="concat". Value igraph. or only a summary of the graph. sparsematrices Whether to use the Matrix package for (sparse) matrices. Eg.url The base URL of the default Nexus server.par returns the current value of the parameter. the returned list is invisible.gabor@gmail. Defaults to FALSE.options is similar to options and getIgraphOpt is similar to getOption.kawai(graph. if TRUE thne some functions will use progress bars while computing.igraph options 159 edge.full Logical scalar. It is recommended.com> See Also igraph.kamada. verbose Logical constant. "ignore"). the current value set for option x. whether to print edge attributes when printing graphs.options(verbose=TRUE) layout. name="concat". Defaults to FALSE.igraph should show the graph structure as well. vertex. See attribute. whether print.options returns a list with the updated values of the parameters. if the user works with larger graphs. print. If parvalue is NULL then igraph.edge.combination for details on this.comb Specifies what to do with the vertex attributes if the graph is modified. print.graph. "ignore") See attribute.

high. . The higher limit of the interval (inclusive).160 igraph. 13/1. ACM Transactions on Mathematical Software. 58–67. 1 rs .sample(1. It is much faster (but of course less general) than the builtin sample function of R. 1 ) The lower limit of the interval (inclusive). Value An increasing numeric vector containing integers. Usage igraph. Examples rs <. length) Arguments low high length Details The algorithm runs in O(length) expected time.sample Sampling a random integer sequence Description This function provides a very efficient way to pull an integer random sample sequence from an integer interval.sample igraph. Author(s) Gabor Csardi <csardi. The length of the sample.sample(low. the sample.igraph.com> References Jeffrey Scott Vitter: An Efficient Algorithm for Sequential Random Sampling. even if high-low is big.gabor@gmail.

types=rep( .undocumented Undocumented and unsupportted igraph functions Description These functions are still in the alpha stage or their arguments are expected to change. They are also not very useful for the general audience. types=rep( .cited. n). Vector (lastcit.undocumented 161 igraph. attr=TRUE) citing. whether to add the vertex types to the generated graph as a vertex attribute called ‘type’.type. the types of the vertices.type. whether to generate directed networks. nrow=length(types).game or matrix (citing. pref=(1:(agebins+1))^-3. edges=1. Vector of length ‘n’. edges=1.game and cited.igraph. Author(s) Gabor Csardi <csardi.type.game(n. Usage lastcit. Types are numbered from zero.cited. agebins=n/71 .com> .gabor@gmail.type. Logical scalar. so they’re not documented yet. directed=TRUE.game) giving the (unnormalized) citation probabilities for the different vertex types. Value A new graph. n). pref=rep(1. attr=TRUE) Arguments n edges agebins pref directed types attr Number of vertices.game(n. directed=TRUE) cited. edges=1. Number of aging bins.game(n. Number of edges per step. length(types)). Logical scalar. pref=matrix(1. ncol=length(types)). directed=TRUE.

using a Tk window. Otherwise it should be either a filename or the name of an igraph demo. invisibly.com> See Also demo Examples igraphdemo() if (interactive()) { igraphdemo("centrality") } . Usage igraphdemo(which) Arguments which If not given. somewhat interactively.162 igraphdemo igraphdemo Run igraph demos. Author(s) Gabor Csardi <csardi.gabor@gmail. step by step Description Run one of the accompanying igraph demos. Details This function provides a somewhat nicer interface to igraph demos that come with the package. with the possibility of inspecting the workspace between two chunks. than the standard demo function. Value Returns NULL. The tcltk package is needed for igraphdemo. Igraph demos are divided into chunks and igraphdemo runs them chunk by chunk. then the names of the available demos are listed.

vertex. but the opposite is not always true.sets Independent vertex sets Description A vertex set is called independent if there no edges between any two vertices in it.sets return a list containing numeric vertex ids. Details independent.sets finds the largest independent vertex sets in the graph. independence.vertex. largest.independent.. limit for the minimum size of the independent vertex sets to find.sets(graph) maximal.vertex.vertex. Numeric constant. min=NULL.vertex. loop edges and multiple edges are ignored. see reference below.sets and maximal.vertex.vertex. NULL means no limit. obeying the size limitations given in the min and max arguments. maximal.independent.sets(graph) independence.sets finds all independent vertex sets in the network. . The largest independent vertex sets are maximal.sets 163 independent. each list element is an independent vertex set.sets. Value independent.sets(graph.vertex. largest.independent. limit for the maximum size of the independent vertex sets to find. max=NULL) largest.vertex.vertex.number calculate the size of the largest independent vertex set(s). An independent vertex set is largest if there is no independent vertex set with more vertices. These functions find independent vertex sets in undirected graphs Usage independent. An independent vertex set is maximal if it cannot be extended to a larger independent vertex set.number returns an integer constant. Numeric constant.independent. NULL means no limit. independece.independent.vertex. directed graphs are considered as undirected.sets finds the maximal independent vertex sets in the graph.independent.number(graph) Arguments graph min max The input graph.independent. These functions use the algorithm described by Tsukiyama et al.

Shirawaka.8) independence.number(g)) largest.com> wrote the R interface and this manual page. See Also cliques Examples # A quite dense graph g <.independent. e. A new algorithm for generating all the maximal independent sets. . then a numeric vector of edge weights.sets(g)) infomap. M.weights The input graph.community Tamas Nepusz <ntamas@gmail. Ide.weights = NULL.vertex.trials = 1 .vertex.erdos.renyi. H.vertex. By default the ‘weight’ edge attribute is used as weights.community (graph.community Infomap community finding Description Find community structure that minimizes the expected description length of a random walker trajectory Usage infomap.sets(g) # Empty graph induced.it> and Gabor Csardi <csardi. If it is not present. largest.164 Author(s) infomap.independent. min=independence.sets(g)[[1]]) length(maximal. then all edges are considered to have the same weight. Tsukiyama.weights = NULL. 1977. . Ariyoshi and I. If not NULL. modularity = TRUE) Arguments graph e. References S. v.sets(g.independent.game(1 .com> ported it from the Very Nauty Graph Library by Keith Briggs <google@for.gabor@gmail.vertex. nb. The length must match the number of edges in the graph. SIAM J Computing.subgraph(g. 6:505–517.number(g) independent.

then a numeric vector of vertex weights.org/1 . By default the ‘weight’ vertex attribute is used as weights.org/abs/ 7 7.14 5. Rosvall and C. http://arxiv. See Also Other community finding methods and communities. Phys. J. T.doi.1179-1. Author(s) Martin Rosvall <martin.weights 165 If not NULL.community(g) membership(imc) communities(imc) .org/1 . Eur. then all vertices are considered to have the same weight. 7 68511 5. http://dx.gabor@gmail. This was ported to be more igraph-like by Emmanuel Navarro <navarro at irit dot fr>.1 73/pnas.114 /epjst/e2 1 .org/abs/ 9 6. Value infomap. Examples ## Zachary’s karate club g <. nb. The length must match the number of vertices in the graph.rosvall at physics dot umu dot se> wrote the original C++ code. D.famous("Zachary") imc <. Axelsson. 1118 (2008) http://dx. 13 (2009). Logical scalar. Special Topics 178.infomap. 6 9 A more detailed paper: M.infomap. please see the communities manual page for details.doi. whether to calculate the modularity score of the detected community structure. Rosvall. http://arxiv. Bergstrom. Maps of information flow reveal community structure in complex networks.community returns a communities object. and C.com>. References The original paper: M.trials modularity Details Please see the details of this method in the references given below.community v. PNAS 105. The number of attempts to partition the network (can be any integer value equal or larger than 1). The R interface and some cosmetics was done by Gabor Csardi <csardi.graph. The map equation. If it is not present. Bergstrom. T.

inter Value An igraph graph.n islands.game(3. 1) oc <.game (islands. and connect them with the specified number of edges. 1 .renyi.166 interconnected. The size of islands in the graph.game Examples g <. islands. 5/1 .size islands.n.islands interconnected. Usage interconnected. The number of edges to create between two islands.optimal.pin.pin n.community(g) oc The number of islands in the graph. n. Author(s) Samuel Thiriot <samuel.inter) Arguments islands.size.islands A graph with subgraphs that are each a random graph. islands. .thiriot at res-ear dot ch> See Also erdos.islands.interconnected. Description Create a number of Erdos-Renyi random graphs with identical parameters.islands. The probability to create each possible edge into each island.

whether to calculate the fill-in edges. newgraph = FALSE) Arguments graph alpha The input graph. alpham1 = NULL. fillin = FALSE.cardinality. Logical scalar.gabor@gmail. alpha = NULL. Value A list with three members: chordal fillin newgraph Author(s) Gabor Csardi <csardi. Usage is. then the triangulated graph.cardinality. Numeric vector.is.search.chordal(graph. It may be directed.chordal 167 is. but edge directions are ignored. then a numeric vector giving the fill-in edges.. Logical scalar. as the algorithm is defined for undirected graphs. If requested. NULL otherwise. and then calculating the set of fill-in edges. alpham1 fillin newgraph Details The chordality of the graph is decided by first performing maximum cardinality search on it (if the alpha and alpham1 arguments are NULL). Numeric vector. It is also true that adding the fill-in edges to the graph makes it chordal. or from alpha. . then it is automatically calculated by calling maximum. The set of fill-in edges is empty if and only if the graph is chordal. which is an edge joining two nodes that are not adjacent in the cycle. If requested.search. If it is NULL. it is TRUE iff the input graph is chordal. or from alpham1 if that is given. NULL otherwise.com> Logical scalar. An equivalent definition is that any chordless cycles have at most three nodes. the inverse of alpha.chordal Chordality of a graph Description A graph is chordal (or triangulated) if each of its cycles of four or more nodes has a chord. then it is automatically calculated by calling maximum. the maximal chardinality ordering of the vertices. whether to calculate the triangulated graph. If it is NULL. an igraph object.

. D-B:E:F. E-C:D:F:H.cardinality.dag(graph) Arguments graph Details is.search(g1) is. (1984).168 References is.dag Robert E Tarjan and Mihalis Yannakakis.cardinality.search Examples ## The examples from the Tarjan-Yannakakis paper g1 <. fillin=TRUE) g2 <.formula(A-B:E.dag Directed acyclic graphs Description This function tests whether the given graph is a DAG. H-C:E:G:I.chordal(g2. F-D:E:G. Value A logical vector of length one. The input graph.chordal(g1. It may be undirected. B-A:E:F:D. F-B:D:E. Usage is. H-G:I:J. SIAM Journal of Computation 13.formula(A-B:C:I. in which case FALSE is reported. C-A:B:E:H. If not.graph. 566–579. B-A:C:D. J-H:I) maximum. the graph is a DAG. G-F:H. E-A:B:C:D:F. C-E:D:G. I-A:H) maximum.dag checks whether there is a directed cycle in the graph. a directed acyclic graph. fillin=TRUE) is. D-B:F:E:C:G. test acyclicity of hypergraphs.graph.search(g2) is.cardinality. Simple linear-time algorithms to test chordality of graphs. G-C:D:H:I. I-G:H:J. See Also maximum. and selectively reduce acyclic hypergraphs.

sequence (out. For directed graphs.e.and out-degrees for directed graphs) can be realized by a graph.degree. i. is. Details is.graphical. These are known sufficient and necessary conditions for a degree sequence to be valid. it may contain loop and multiple edges. Examples g <.graphial. the function checks whether the lengths of the two degree vectors are equal and whether their sums are also equal. it also checks whether the sum of degrees is even. Usage is.and out-degrees for directed graphs) can be reliazed in a simple graph.is.dag(g2) is. For undirected graphs.deg Integer vector.deg in.degree.deg = NULL) Arguments out. For undireted graphs.g + edge(5.degree.deg = NULL) is.degree.sequence checks whether the given vertex degrees (in.degree.deg. Value A logical scalar. Gabor Csardi <csardi.sequence (out. in.com> for the R interface. if the graph is directed) of integers can be realized as vertex degrees by a graph or simple graph.sequence determines whether the given vertex degrees (in.tree(1 ) is.deg.com> for the C code. in.gabor@gmail.sequence Author(s) 169 Tamas Nepusz <ntamas@gmail.1) is. the degree sequence for undirected graphs. it should be NULL. NULL or an integer vector. For directed graphs it specifies the in-degrees.dag(g) g2 <.degree. .sequence Degree sequences of graphs Description These functions decide whether a sequence (or two. a graph without multiple or loop edges.graph. Note that the graph does not have to be simple. or the out-degree sequence for directed graphs.

Examples g <.com> Examples g <.igraph(graph) Arguments graph Value A logical constant.sequence(degree(g)) is.sequence(degree(g)) is. Author(s) Gabor Csardi <csardi.com> References is.graph.gabor@gmail. 2010. PL Erdos.igraph Hakimi SL: On the realizability of a set of integers as degrees of the vertices of a simple graph.erdos.degree. J SIAM Appl Math 10:496-506.degree. 1962. 2/1 ) is. I Miklos and Z Toroczkai: A simple Havel-Hakimi type algorithm to realize graphical degree sequences of directed graphs.renyi. TRUE if argument graph is a graph object.graphical.170 Author(s) Tamas Nepusz <ntamas@gmail.ring(1 ) is. The Electronic Journal of Combinatorics 17(1):R66. Usage is.igraph Is this object a graph? Description is.igraph(g) is.game(1 .graph makes its decision based on the class attribute of the object. .igraph(numeric(1 )) An R object.

multiple 171 is. The edges to which the query is restricted. count. if there are three i-j edges in the graph then is.multiple(graph.multiple counts the multiplicity of each edge of a graph.loop decides whether the edges of the graph are loop edges.multiple decides whether the edges of the graph are multiple edges.multiple returns ‘3’ for all three. is. By default this is all edges in the graph. Author(s) Gabor Csardi <csardi.multiple and count. A graph without multiple and loop edges is called a simple graph. Note that the semantics for is. count. Details is.multiple decides whether the graph has any multiple edges.multiple is different.multiple Find the multiple or loop edges in a graph Description A loop edge is an edge from a vertex to itself. Ie. eids=E(graph)) count.multiple(graph) is. Usage is.multiple(graph. is.loop and is.multiple returns a logical scalar.gabor@gmail. is.multiple returns TRUE for only two of them while count.multiple return a logical vector. has. Value has. eids=E(graph)) Arguments graph eids The input graph.multiple gives TRUE for all occurences of a multiple edge except for one. An edge is a multiple edge if it has exactly the same head and tail vertices as another edge. eids=E(graph)) has. See the examples for getting rid of multiple edges while keeping their original multiplicity as an edge attribute.com> .multiple returns a numeric vector.loop(graph.is.

2.graph( c(1. dir=FALSE )) # Remove multiple edges but keep multiplicity g <. .barabasi.multiple(g) g <.multiple(g)) E(g)$weight is.multiple(g) is. Usage is. m=3. es = E(graph)) Arguments graph es The input graph.2.loop(g) # Multiple edges g <.5) ) is.simplify(g) any(is. Edge sequence.multiple(simplify(g)) all(count.1.barabasi. algorithm="bag") has.2.multiple(graph( c(1.3.4.multiple(graph( c(1.multiple(simplify(g)) == 1) # Direction of the edge is important is.1) )) is. m=3.mutual is.multiple(g) count.mutual(graph.3. Examples # Loops g <. By default is includes all edges in the order of their ids.count.172 See Also simplify to eliminate loop and multiple edges. algorithm="bag") E(g)$weight <.game(1 . the edges that will be probed.2.1).multiple(g) is. 2.mutual Find mutual edges in a directed graph Description This function checks the reciproc pair of the supplied edges. 2.game(1 .

erdos.named(graph) Arguments graph The input graph.B) edge is mutual if the graph also includes a (B. Value A logical vector of the same length as the number of edges supplied.B) and one copy of (B. Usage is. Examples g <.5 .census(g) is.named Details In a directed graph an (A. if there is a symbolic name associated with its vertices. then these three edges are considered to be mutual.mutual(g))/2 == dyad.census(g)$mut is. dyad.gabor@gmail.is. Undirected graphs contain only mutual edges by definition.com> See Also reciprocity. .mutual(g) sum(is. Author(s) Gabor Csardi <csardi.A) directed edge.A).named Named graphs Description An igraph graph is named.type="gnm".directed=TRUE) reciprocity(g) dyad.game(1 .census if you just want some statistics about mutual edges. if the graph contains two copies of (A. i.renyi.e. 173 Note that multi-graphs are not handled properly.

Author(s) Gabor Csardi <csardi. This is. To allow this more flexible identification of vertices.ring(1 ) is. A numeric vector giving the vertex ids of the candidate separator. It may be directed. not always convenient. and in many cases there exist symbolic ids that correspond to the vertices. you have to check that for yourself. Note that the uniqueness of vertex names are currently not enforced in igraph. but edge directions are ignored.com> Examples g <. or a minimal vertex separator.174 Details is. "a") is. the symbolic vertex names can be used in all igraph functions. Usage is. when assigning the vertex names.separator(graph. .letters[1:1 ] is. instead of the numeric ids. candidate) is. candidate) Arguments graph candidate The input graph. Value A logical scalar. one can assign a vertex attribute called ‘name’ to an igraph graph.named(g) neighbors(g.graph.gabor@gmail. After doing this.minimal.named(g) V(g)$name <.separator In igraph vertices can always be identified and specified via their numeric vertex ids.separator Vertex separators Description These functions check whether a given set of vertices is a vertex separator. however.separator(graph.

17:23))) as. is. 22-23) # Cohesive subgraphs mw1 <.character(c(1:7. 14-15.induced.11.separator Details 175 is.sep(mw5) . whether the supplied vertex set is a (minimal) vertex separator or not. 6-7.character(c(7.size.separator decides whether the supplied vertex set is a minimal vertex separator. Examples # The graph from the Moody-White paper mw <. each set of n − 1 vertices is considered to be a vertex separator.sep <.induced. 17-18:19:2 .subgraph(mw. 3-4:6:7. 2-3:4:5:7. A vertex set is a vertex separator if its removal results a disconnected graph. 21-22:23. is.subgraph(mw. 12-16.induced. 15-16.minimum.8.gabor@gmail.minimal.subgraph(mw. Author(s) Gabor Csardi <csardi. 5-6:7:21. 4-5:6:7. such that none of its subsets is a vertex separator.character(17:23)) as.sep(mw3) check.separators(G) sapply(sep. Value A logical scalar. In the special case of a fully connected graph with n vertices. 11-12:14. as.separators lists all vertex separator of minimum size.separator decides whether the supplied vertex set is a vertex separator.size.induced. mw5 <. mw4 <.minimal.induced.sep(mw1) check.graph.formula(1-2:3:4:5:6.sep(mw2) check. mw3 <.separator. 2 -21. 9-1 .subgraph(mw.function(G) { sep <.sep(mw) check. graph=G) } check. A minimal vertex separator is a vertex separator. 1 -12:13. 18-2 :21.com> See Also minimum. 7-8:11:14:19. 19-2 :22:23. 13-16.character(7:16)) as. mw2 <.subgraph(mw. 8-9:11:14.is.14))) as.sep(mw4) check.character(1:7)) check.

) Edge weights are used for different purposes by the different functions.paths(g. shortest path functions use it as the cost of the path. 8.seq_len(ecount(g)) get. E. Value A logical scalar.176 is. .g. Author(s) Gabor Csardi <csardi.weighted(graph) Arguments graph Details In igraph edge weights are represented via an edge attribute. Check the manual pages of the functions working with weighted graphs for details.graph. 8. (It does not even checks that it is a numeric edge attribute. etc.shortest. 2) The input graph.ring(1 ) get.paths(g. called ‘weight’.com> Examples g <. The is.weighted Weighted graphs Description In weighted graphs. community finding methods use it as the strength of the relationship between two vertices.shortest.weighted function only checks that such an attribute exists. 2) E(g)$weight <.gabor@gmail. a real number is assigned to each (directed or undirected) edge. Usage is.weighted is.

P=NULL. Logcal constant.color=V(g)$color. See also details below. can be supplied only if either P or path is also present and gives whether the pairs or the path are directed or not. We set the color of these vertices to red.sample(1:1 . Details One often needs to perform an operation on a subset of vertices of edges in a graph. directed=TRUE) Arguments graph P path directed A graph object. this is for selecting all edges along a path. See details below.ring(1 ) V(g)$number <. a vertex sequence indexed by a logical expression) is another vertex sequence containing only vertices from the original sequence for which the expression evaluates to TRUE. vcount(g).circle. A vertex sequence can be indexed with the ‘$’ operator to select (or modify) the attributes of a subset of vertices.label=V(g)$number) . replace=TRUE) V(g)$color <. Numeric vector. A vertex sequence can be indexed by a logical expression. We assign random numbers between 1 and 100 to the vertices."red" plot(g. like selecting a subset of the vertices based on some vertex attributes. Let us see an example to make everything clear. Numeric vector for selecting edges by giving their end points. g <. path=NULL. vertex. A vertex sequence is created by V(g) this selects are vertices in increasing vertex id order. Usage V(graph) E(graph. layout=layout."grey" V(g)[ number < 5 ]$color <. but it has a special class attribute which makes it possible to perform graph specific operations on it. and a subset of all vertices can be selected. vertex.iterators 177 iterators Vertex and edge sequences and iterators Description Vertex and edge sequences are central concepts of igraph. A vertex sequence is simply a vector containing vertex ids. The return value of such a construct (ie. A vertex sequence can be indexed by a numeric vector. and select those vertices for which the number is less than 50. Vertex sequences provide powerful operations for dealing with vertex attributes.graph. and this expression may contain the names of the vertex attributes and ordinary variables as well.

the standard R rules apply and a warning is given if the number of items to replace is not a multiple of the replacement length."grey" V(g)[1:3]$color <. E."foo" V(g)$foo V(g)[5]$bar <. but only a subset of of vertices are specified. the following code gives a warning.) nei has a mandatory and an optional argument.c("black". edge.178 iterators There is a similar notation for edges.graph.list(bar="bar") V(g)$bar There are some special functions which are only defined in the indexing expressions of vertex and edge sequences.graph. because we set the attribute for three vertices.width=E(g)$width.color="black") It is important to note that.graph. E(g) selects all edges from the ‘g’ graph. in an alternated way.circle) For the recycling.tree(1 ) V(g)$color <. g <.runif(ecount(g)) E(g)$width <. from and to.g. "blue") If a new vertex/edge attribute is created with an assignment.5 ]$width <.ring(1 ) V(g)$color <. Thus for selecting all neighbors of vertices 1 and 2 one can write: V(g) [ nei( 1:2 ) ] . the first is another vertex sequence.c("green". So in the following example half of the vertices will be black.3 plot(g.circle. the other half red.1 E(g)[ weight >= . "red") plot(g. the new values are recycled. whenever we use iterators to assign new attribute values. (The adj special function is an alias for inc. For vertex sequences these are: nei. the second is a mode argument similar to that of the neighbors function. innei and outnei. Try the following: V(g)[5]$foo <. edge. Edge sequences can be also indexed with logical expressions containing edge attributes: g <. layout=layout. then the rest is set to NA if the new values are in a vector and to NULL if they are a list. nei returns a logical vector of the same length as the indexed vertex sequence and evaluates to TRUE for those vertices only which have a neighbor vertex in the vertex sequence supplied as a parameter. inc.ring(1 ) E(g)$weight <. but supply only two values: g <. layout=layout. for compatibility reasons.

the direction of the edges is ignored. vertex.erdos.game(1 ."green" V(g)[vsl]$color <. P=c(1."red" ## Not run: plot(g.com> Examples # mean degree of vertices in the largest cluster in a random graph g <. See also the examples below. from. (Time complexity is proportional to the total number of vertices/edges.reingold) . labels=NA. but only vertices at the source (from) or target (to) of the edge. others greens V(g)$color <. 2/1 ) c <. from and to are similar to inc. %--%.iterators 179 The mode argument (just like for neighbors) gives the type of the neighbors to be included. The path should be given with the visited vertex ids in the appropriate order.clusters(g) vsl <.renyi.size=3. vertex. and defaults to all types of neighbors. their performance is bad on large graphs.which(which. it is interpreted only in directed graphs. incident functions and simple R vector operations for manipulating vertex/edge sequences in large graphs. and outnei(v) is a shorthand for the ‘outgoing’ neighbors (nei(v. Author(s) Gabor Csardi <csardi.color="a:color". mode="in")). inc takes a vertex sequence as an argument and returns TRUE for edges which have an incident vertex in it. layout=layout. inc takes an edge sequence as an argument and returns TRUE for vertices which have at least one incident edge in it. E(g. For edge sequences the special functions are: inc. See the example below. The %->% is different only for directed graphs and only edges pointing from the left hand side argument to the right hand side argument are selected. Since all selectors are evaluated as logical vectors on all vertices/edges.fruchterman. vsl)) # set the color of these vertices to red. from and to are similar to inc but only edges originated at (from) or pointing to (to) are taken into account. Note A note about the performance of the V and E functions. E has two optional arguments: P and path. and the selection of edges and vertices. %<-% is exactly the opposite.mode="out")). %->% and %<-%. path can be used to select all edges along a path. The %--% operator selects edges connecting two vertex sequences.) We suggest using the neighbors. to. innei(v) is a shorthand for the ‘incoming’ neighbors (nei(v. eg.gabor@gmail.max(c$csize)==c$membership) mean(degree(g. it selects edges pointing from the right hand side to the left hand side. If given P can be used to select edges based on their end points.2)) selects edge 1->2.

lattice(c(1 . path=d) # performance for large graphs is bad largeg <.numeric() for (v in vsl) { paths <. k. Usage k.2.4). power= .game Create a random regular graph Description Generate a random graph where each vertex has the same degree.game (no.time(incident(largeg.game k. multiple = FALSE) Arguments no.of. 4.max(sapply(paths.get.4). from=v.3.game(1 . 1)) k.nodes.barabasi.game(1 . Integer scalar. 2.diameter(g) E(g.3) E(g) [ 1:3 %--% 2:6 ] E(g) [ 1:5 %->% 1:6 ] E(g) [ 1:3 %<-% 2:6 ] # the edges along the diameter g <.graph.of.180 ## End(Not run) # the longest geodesic within the largest cluster long <.2) ) V(g)[ nei( c(2. "out") ] # operators for edge sequences g <.barabasi. directed = FALSE.regular.nodes k Integer scalar. directed=FALSE) d <. to=vsl) fl <.4) ) ] V(g)[ nei( c(2.paths(g.regular.time(E(largeg)[inc(1)]) system. or the out-degree and indegree in a directed graph. "in") ] V(g)[ nei( c(2.4.get. the degree of each vertex in the graph. 2. the number of vertices in the generated graph.fl } } # the mode argument of the nei() function g <. .regular.shortest. 1 )) system.paths[[ which.graph( c(1. length)) ]] if (length(fl) > length(long)) { long <.

at least one of k and the number of vertices must be even.kleinberg directed multiple Details Logical scalar. For undirected graphs. Value An igraph graph. scale = TRUE.label=NA) kleinberg Kleinberg’s centrality scores. plot. scale = TRUE. weights=NULL.default) hub.sequence.default) .score (graph. whether to create a directed graph. k. weights=NULL. nrow=3.regular. 181 This game generates a directed or undirected random graph where the degrees of vertices are equal to a predefined constant k.regular.com> See Also degree.sequence.nodes=1 ) layout(matrix(1:9. with k=1:9 k1 <.lapply(1:9. Description Kleinberg’s hub and authority scores.of. options = igraph.game(1 .arpack. whether multiple edges are allowed. The game simply uses degree.arpack. options = igraph.k.score (graph. Author(s) Tamas Nepusz <ntamas@gmail.game. byrow=TRUE)) sapply(k1 . vertex. Logical scalar. 2) plot(ring) ## k-regular graphs on 1 vertices.game for a generator with prescribed degree sequence. no. Examples ## A simple ring ring <.game with appropriately constructed degree sequences. Usage authority.

Extended version in Journal of the ACM 46(1999). See Also evcent for eigenvector centrality. Some information about the ARPACK computation.gabor@gmail.graph. Proc. Kleinberg.182 Arguments graph scale weights options Details The input graph.score(g)$vector authority. where A is the adjacency matrix of the graph. for undirected matrices the adjacency matrix is symmetric and the two scores are the same. A named list. arpack for the underlining machinery of the computation. Authoritative sources in a hyperlinked environment. 1998. Optional positive weight vector for calculating weighted scores.star(1 ) hub. page. 9th ACM-SIAM Symposium on Discrete Algorithms. The hub scores of the vertices are defined as the principal eigenvector of AAT . Also appears as IBM Research Report RJ 10076. The authority scores of the vertices are defined as the principal eigenvector of AT A. See arpack for details. The corresponding eigenvalue of the calculated principal eigenvector. then this is used by default. Examples ## An in-star g <. May 1997.rank for the Page Rank scores. Author(s) Gabor Csardi <csardi.score(g)$vector .com> References J. where A is the adjacency matrix of the graph. whether to scale the result to have a maximum score of one. to override some ARPACK options. kleinberg Logical scalar. see that for documentation. Value A named list with members: vector value options The authority/hub scores of the vertices. If the graph has a weight edge attribute. If no scaling is used then the result vector has unit length in the Euclidean norm. Obviously. it has the same members as the options member returned by arpack.

propagation. and Kumara.N. and Albert. otherwise this element will be ignored. initial fixed Details This function implements the community detection method described in: Raghavan. This version extends the original method by the ability to take edge weights into consideration and also by allowing some labels to be fixed.propagation. R. (2007). U.label. should be undirected to make sense. Of course this makes sense only if you provided an initial state.propagation. An optional weight vector. Usage label. The ‘weight’ edge attribute is used if present. Otherwise it must be a vector with an entry for each vertex. Non-negative values denote different labels. Phys Rev E 76. please see the communities manual page for details.community (graph.score(g2)$vector 183 label. every vertex will have a different label at the beginning. From the abstract of the paper: “In our algorithm every node is initialized with a unique label and at every step each node adopts the label that most of its neighbors currently have. fixed = NULL) Arguments graph weights The input graph. negative entries denote vertices without labels.ring(1 ) hub. nearly linear time algorithm for detecting community structure in networks. It should contain a positive weight for all the edges.propagation. The initial state.graph. Logical vector denoting which labels are fixed. Also note that vertices without labels cannot be fixed.community returns a communities object. In this iterative process densely connected groups of nodes form a consensus on a unique label to form communities. 036106.community Finding communities based on propagating labels Description This is a fast. initial = NULL. S. Supply ‘NA’ here if you want to ignore the ‘weight’ edge attribute. In works by labeling the vertices with unique labels and then updating the labels by majority voting in the neighborhood of the vertex. .: Near linear time algorithm to detect community structures in large-scale networks.score(g2)$vector authority.” Value label.community ## A ring g2 <. weights = NULL. If NULL.

reingold. xmax = NULL. dim=2.. params) layout.kawai(graph. References Raghavan.graphopt(graph..kamada.com> for this manual page. params) layout.com> for the C implementation. d=shortest.lgl(graph.propagation.norm(layout.. S.. params) layout.community.spring(graph. params) layout. params) layout.community(g) layout Generate coordinates for plotting graphs Description Some simple and not so simple functions determining the placement of the vertices for drawing a graph. . Gabor Csardi <csardi.184 Author(s) layout Tamas Nepusz <ntamas@gmail. zmax = NULL) . .. fastgreedy..add.grid(graph..reingold. walktrap..paths(graph). .tilford(graph.community and spinglass.. params=list()) layout. 036106. dim=2.....reingold(graph. dim=2.community for other community detection methods. Usage layout.game(9.. and Albert.. dim=2) layout. .: Near linear time algorithm to detect community structures in large-scale networks.renyi. params) layout..sphere(graph.gabor@gmail. R.) layout. params) layout.game(1 ...auto(graph..erdos. ymin = NULL.N. and Kumara. 5/9) g <. zmin = NULL. params.fruchterman. . ymax = NULL..... xmin = NULL. Phys Rev E 76. 5/1 ) %du% erdos.renyi. params) layout..fruchterman.random(graph. c(1. . U.) layout. . . (2007) See Also communities for extracting the actual results. 12)) label.edges(g. ..svd(graph. Examples g <.circle(graph.

with the graph and any other extra arguments.circle places the vertices on a unit circle equidistantly.kawai.ymax zmin. and uses that to generate the layout. that is also used. if one of them or both are NULL then no normalization is performed along this direction. if one of them or both are NULL then no normalization is performed along this direction. the Kamada-Kawai layout is used.. if one is called.zmax Details These functions calculate the coordinates of the vertices for a graph usually based on some optimality criterion. this is an alternative notation to the params argument. layout. For layout. layout. if the graph has less than 1000 vertices. Function dependent parameters.random simply places the vertices randomly on a square.auto tries to choose an appropriate layout function for the supplied graph. by calling layout. layout. 4.reingold uses a force-based algorithm proposed by Fruchterman and Reingold. Otherwise. then this is used. if the graph has vertex attributes called ‘x’ and ‘y’. It is not clear however what “uniformly on a sphere” means. The graph to place. Otherwise. layout. then it is called.xmax ymin. 185 Numeric constant. the layout to normalize. supply this argument to change the default behavior. layout. if the graph is connected and has less than 100 vertices. if one of them or both are NULL then no normalization is performed along this direction. 5. by calling layout. Some functions are able to generate 2d and 3d layouts as well.reingold. this is thus a 3d layout. Otherwise the DrL layout is used. It has no parameters. The list of function dependent parameters. see references. The current implementations works like this: 1. the cooling exponent for the simulated annealing (3).sphere places the vertices (approximately) uniformly on the surface of a sphere. layout. 3. A matrix with two or three columns. either 2 or 3. The limits for the first coordinate.. The limits for the second coordinate.drl is called. The limits for the third coordinate. By default it is the distance matrix of the graph. The matrix used for singular value decomposition. Parameters and their default values: niter Numeric. . the number of iterations to perform (500). 2. If the graph has an additional ‘z’ vertex attribute.layout Arguments graph params dim . then the Fruchterman-Reingold layout is used. It has no paramaters. If the graph has a graph attribute called ‘layout’.auto these extra parameters are simply passed to the real layout function.kamada. then these are used as coordinates.fruchterman. If this attribute is an R function. d layout xmin. Otherwise. coolexp Numeric.fruchterman.

The length of the vector must match the number of vertices in the graph. repulserad Cancellation radius (area*vcount(graph)). then it must be a numeric vector that gives lower boundaries for the ‘x’ coordinates of the vertices. minx If not NULL. start If given. start If given. Parameters and default values: niter Number of iterations to perform (1000). then it should be a matrix with two columns and one line for each vertex. miny Similar to minx. layout. then a random starting matrix is used. This function was ported from the SNA package. area Area parameter (vcount(graph)^2). maxz Similar to minx. miny Similar to minx. minz Similar to minx. minz Similar to minx. but gives the upper boundaries of the ‘z’ coordinates.kamada. layout.186 maxdelta Maximum change (vcount(graph)).99). but gives the lower boundaries of the ‘y’ coordinates.kawai is another force based algorithm. This matrix will be used as starting positions for the algorithm. but gives the lower boundaries of the ‘y’ coordinates. This matrix will be used as starting positions for the algorithm. kkconst Sets the Kamada-Kawai vertex attraction constant (vcount(graph)**2). then it must be a numeric vector that gives lower boundaries for the ‘x’ coordinates of the vertices. minx If not NULL. but gives the lower boundaries of the ‘z’ coordinates. maxy Similar to minx. then a random starting matrix is used. Otherwise it is ignored. If not given. if the dim argument is 3. but gives the upper boundaries of the ‘y’ coordinates. maxz Similar to minx. then it should be a matrix with two columns and one line for each vertex. Otherwise it is ignored. initemp The initial temperature (10). coolexp The cooling exponent (0. If not given. sigma Sets the base standard deviation of position change proposals (vcount(graph)/4). if the dim argument is 3. Otherwise it is ignored. maxy Similar to minx. This function performs very well for connected graphs. but gives the lower boundaries of the ‘z’ coordinates. Parameters and default values: . The length of the vector must match the number of vertices in the graph. but gives the upper boundaries of the ‘y’ coordinates. If not NULL then the attraction along the edges will be multiplied by the given edge weights (NULL). maxx Similar to minx. but it gives poor results for unconnected ones. maxx Similar to minx. if the dim argument is 3. but gives the upper boundaries.spring is a spring embedder algorithm. Otherwise it is ignored. but gives the upper boundaries. but gives the upper boundaries of the ‘z’ coordinates. This function was ported from the SNA package. if the dim argument is 3. layout weights A vector giving edge weights or NULL.

utexas. When calculating the repulsion forces between vertices only vertices in the same or neighboring grid cells are taken into account (the fourth root of the number of area. Patameters and default values: niter Numeric.) k The spring coefficient (in ‘quasi-Newtons per quasi-meter’).) equil The equilibrium spring extension (in ‘quasi-meters’). The default is flipping because that puts the root vertex on the top.lgl is for large connected graphs. (The number of vertices in the graph. coolexp The cooling exponent of the simulated annealing (1.reingold. If not given.1. defaults to 1.) area The area of the surface on which the vertices are placed. (Defaults to 0. cellsize The size of the cells for the grid. (Defaults to 0. so it is mainly for trees. (The square of the number of vertices. Parameters and default values: maxiter The maximum number of iterations to perform (150). area The area of the surface on which the vertices are placed (square of the number of vertices). layout. circular Logical scalar.001.) repulse Should repulsion be used? (Defaults to FALSE. When calculating the repulsion forces between vertices only vertices in the same or neighboring grid cells are taken into account (the fourth root of the number of area. defaults to FALSE. then a random starting matrix is used.01.edu/lgl).) coolexp The cooling exponent of the simulated annealing (1. cellsize The size of the cells for the grid.5). layout.1.5). repulserad Cancellation radius for the repulsion (the area times the number of vertices). the number of iterations to perform (500). Parameters and default values: root The id of the root vertex.) This function was ported from the SNA package. .reingold but repelling force is calculated only between vertices that are closer to each other than a limit.icmb. (Defaults to 1. so it is faster. layout.fruchterman. then it should be a matrix with two columns and one line for each vertex. flip. maxdelta The maximum change for a vertex during an iteration (the number of vertices). This matrix will be used as starting positions for the algorithm. repulserad Cancellation radius for the repulsion (the area times the number of vertices). start If given. it is similar to the layout generator of the Large Graph Layout software (http://bioinformatics. whether to flip the ‘y’ coordinates. whether to plot the tree in a circular fashion. maxdelta Maximum change for one vertex in one iteration.tilford generates a tree-like layout.y Logical scalar. (Defaults to 0.fruchterman.layout mass The vertex mass (in ‘quasi-kilograms’). (Defaults to 0.) 187 repeqdis The point at which repulsion (if employed) balances out the spring extension force (in ‘quasi-meters’).grid is similar to layout.reingold.) kfr The base coefficient of kinetic friction (in ‘quasi-Newton quasi-kilograms’).

001.1 was rewritten in C and the support for layers was removed (might be added later) and a code was a bit reorganized to avoid some unneccessary steps is the node charge (see below) is zero. start If given.4. charge The charge of the vertices.constant The spring constant. max. The default value is -1 which means that a random vertex is selected. The default value is 500. (There is no simulated annealing or anything like that.drl for details.gabor@gmail.com> . See layout. so a stable fixed point is not guaranteed.length The length of the springs.drl is another force-driven layout generator. spring. Value All these functions return a numeric matrix with at least two columns and the same number of lines as the number of vertices.) See also http://www.svd is a currently experimental layout function based on singular value decomposition. If it is not good enough you can feed it in again in the start argument. The default is 0. Parameters and default values: niter Integer scalar.schmuhl. then a random starting matrix is used. used for the spring forces. the distance matrix of the graph. the number of iterations to perform.sa. layout. an integer number. layout.graphopt is a port of the graphopt layout algorithm by Michael Schmuhl. layout. If not given. it is suitable for quite large graphs. then it should be a matrix with two columns and one line for each vertex. The default value is zero. Should be a couple of hundred in general. used to calculate electric repulsion. This function generates the layout separately for each graph component and then merges them via layout. If you have a large graph then you might want to only do a few iterations and then check the result. graphopt uses physical analogies for defining attracting and repelling forces among the vertices and then the physical system is simulated until it reaches an equilibrium. graphopt version 0. layout. It does not have the usual params argument. the default value is one. This matrix will be used as starting positions for the algorithm. it gives the maximum amount of movement allowed in a single step along a single axis.188 layout root The id of the vertex to place at the middle of the layout. spring.org/graphopt/ for the original graphopt.merge. mass The mass of the vertices.norm normalizes a layout. it linearly transforms each coordinate separately to fit into the given limits. but take a single argument.movement Real constant. The default is 30. The default value is 5. Author(s) Gabor Csardi <csardi.

rep("". use. Software .drl The DrL graph layout generator Description DrL is a force-directed graph layout toolbox focused on real-world large-scale graphs.label=c("ego".dist=1.ba.2]). miny=minC. maxy=maxC) co[1.drl.size=3 .drl References 189 Fruchterman.] ## Not run: plot(g. developed by Shawn Martin and colleagues at Sandia National Laboratories. vertex.layout.ring(1 ) layout.kawai(g) # Fixing ego g <. fixed = NULL. See Also layout. dim = 2) . 21(11):1129-1164.arrow. Eng. ylim=range(co[. 31(1):7-15. m=2) minC <.fruchterman. S.game(2 . vcount(g)-1)). ncol = 2). edge.rep(-Inf. minx=minC.Practice and Experience. T.M. (1991). rescale=FALSE. maxx=maxC.random(g) layout.1]).maxC[1] <co <. J (1981). and Reingold.kamada. and Kawai. vcount(g)) maxC <. weights = E(graph)$weight.M. Kamada.drl (graph. plot. options = igraph. vertex. xlim=range(co[.drl.color="red") axis(1) axis(2) ## End(Not run) layout. vertex. SE7(2):223–228.2. E.label.seed = FALSE. tkplot Examples g <.. Information Processing Letters. layout=co. on Softw. Usage layout. IEEE Trans. Graph Drawing by Force-directed Placement. Reingold.reingold(g.graph.default. T. Tidier drawing of trees. An Algorithm for Drawing General Undirected Graphs.J.size= . seed = matrix(runif(vcount(graph) * 2).rep(Inf.label. (1989).layout.igraph. vcount(g)) minC[1] <. vertex. E and Tilford.

mult Damping. A matrix with two columns. cooldown. liquid. cooldown. liquid phase.attraction Attraction. cooldown.190 Arguments graph use.iterations Number of iterations.drl Logical scalar. init.temperature Start temperature. Note that because of the nature of the DrL algorithm. expansion phase. cooldown phase.iterations Number of iterations. expansion phase. cooldown phase. It is ignored it NULL or if use. By default the weight edge attribute is used if the graph has one. liquid phase. init.temperature Start temperature. The edge cutting parameter is a value between 0 and 1 with 0 representing no edge cutting and 1 representing maximal edge cutting. All vertices for which it is TRUE are kept at the coordinates supplied in the seed matrix.seed is TRUE. cooldown phase.damping. Logical vector.attraction Attraction. See details below. . expansion phase.cut Edge cutting is done in the late stages of the algorithm in order to achieve less dense layouts. Supply NULL here if you want to weight edges equally.attraction Attraction. dim Details This function implements the force-directed DrL layout generator. Options for the layout generator. first phase. Optional edge weights.damping. layout.damping. liquid. It is ignored otherwise. it specifies whether we want a two dimensional or a three dimensional layout. a named list. the three dimensional layout takes significantly longer to compute. liquid phase. expansion. in can be directed or undirected.damping. expansion. cooldown phase.mult Damping.attraction Attraction.mult Damping. init. cooldown. expansion phase. it can be used to fix some vertices.seed seed options weights fixed The input graph.iterations Number of iterations.iterations Number of iterations in the first phase. liquid. The generator has the following parameters: edge. whether to use the coordinates given in the seed argument as a starting point. first phase. Either ‘2’ or ‘3’. expansion. expansion. liquid.seed is FALSE.temperature Start temperature. Edges are cut if there is a lot of stress on them (a large value in the objective function sum). liquid phase. the starting coordinates for the vertices is use. init.mult Damping. first phase.temperature Start temperature.

K..W. References See the following technical report: Martin. Author(s) Shawn Martin <google@for.final.drl.it> and Gabor Csardi <csardi. crunch phase. these are called igraph. 191 There are five pre-defined parameter settings as well. vertex. Examples g <. layout=l.attraction= )) ## Not run: plot(g.layout. simmer phase. 2008.. Boyack.undirected(ba. Klavans. DrL: Distributed Recursive (Graph) Layout.as.drl.M. crunch. crunch phase. Value A numeric matrix with two columns.refine and igraph. 1-10. simmer phase.coarsen.drl.attraction Attraction. options=list(simmer. igraph.com> for the R/igraph interface and the three dimensional version. simmer. simmer. crunch phase.. R.coarsest.drl.iterations Number of iterations.drl.default.damping.temperature Start temperature. vertex.damping.drl(g. igraph.size=3. simmer phase.. m=1)) l <. SAND Reports. Brown.gabor@gmail. W. simmer phase. See Also layout for other layout generators.mult Damping.mult Damping. 2936: p. S.temperature Start temperature. crunch.game(1 .layout. crunch phase. simmer. simmer.iterations Number of iterations. crunch.drl crunch.attraction Attraction. igraph.label=NA) ## End(Not run) .

If you want to change the order of the vertices. width = . in two or three dimensions. it will be the cube root for layout. The number of vertices in a single row of the grid.lattice( c(3.grid Simple grid layout Description This layout places vertices on a rectangulat grid. Value A two-column matrix for layout. then it is determinted automatically.com> See Also layout for other layout generators Examples g <. rounded up to the next integer.grid.3.grid.3) ) layout.3) ) layout.3d (graph. Similarly.graph. one after the other. a three-column matrix for layout. If this is zero or negative for layout. If this is zero or negative.graph.grid.3d(g2) ## Not run: . Usage layout. height Details These functions place the vertices on a simple rectangular grid.grid(g) g2 <.3d.grid. The number of vertices in a single column of the grid.vertices function. for three dimensional layouts.192 layout. width = ) layout. height = ) Arguments graph width The input graph. then see the permute.3d. then the width of the grid will be the square root of the number of vertices in the graph.grid layout.lattice( c(3.grid. Author(s) Tamas Nepusz <ntamas@gmail.grid (graph.grid.

gabor@gmail.mds plot(g. options=igraph.merge. dist=NULL. dim=2. This function generates the layout separately for each graph component and then merges them via layout.layout.3d) ## End(Not run) 193 layout.mds uses metric multidimensional scaling for generating the coordinates. the only possible values is 2. By default igraph uses the shortest path matrix as the distances between the nodes.default) Arguments graph dist dim The input graph. then the unweighted shortest path matrix is used.grid.merge only works in 2D. but the user can override this via the dist argument. so that the distance between the points are kept as much as this is possible. If NULL (the default). for unconnected graphs. Usage layout. This is because layout.com> and Gabor Csardi <csardi. layout=layout.com> . Author(s) Tamas Nepusz <ntamas@gmail.mds supports dimensions up to the number of nodes minus one. layout=layout. This is currently ignored.mds(graph.grid) rglplot(g. The distance matrix for the multidimensional scaling. layout. Multidimensional scaling aims to place points from a higher dimensional space in a (typically) 2 dimensional plane. Value A numeric matrix with dim columns. but only if the graph is connected.mds Graph layout by multidimensional scaling Description Multidimensional scaling of some distance matrix defined on the vertices of a graph.arpack. as ARPACK is not used any more for solving the eigenproblem options Details layout.

2/1 ) l <. although right now only the dla method is implemented. layout=l. Right now only dla is implemented.. layouts.merge(graphs. Chapman and Hall. The input graph. and Cox.erdos. Second edition. Details layout.size=3) layout. plot. M. (2001) Multidimensional Scaling. See Also layout.game(1 . Then the other graphs are placed in decreasing order via a DLA (diffision limited aggregation) algorithm: the graph is placed randomly on a circle far away from the center and a random walk is conducted until the graph walks into the larger graphs already placed or walks too far from the center of the layout. The piecewise. F. Finally it merges the layouts via calling layout.194 References layout.merge.. vertex. Additional arguments to pass to the layout layout function. A list of graph objects. .label=NA.kamada. method = "dla") piecewise.) Arguments graphs layouts method graph layout .merge Cox.renyi.. A function object. vertex. .igraph Examples g <.layout. Character constant giving the method to use. A. The method to use is chosen via the method parameter.layout function disassembles the graph first into maximal connected components and calls the supplied layout function for each component separately. Then it sorts the graphs based on the number of vertices first and places the largest graph at the center of the layout..merge takes a list of graphs and a list of coordinates and places the graphs in a common layout. A.layout(graph. The dla method covers the graph with circles.merge Merging graph layouts Description Place several graphs on the same layout Usage layout. A list of two-column matrices. the layout function to use.mds(g) plot(g. layout=layout.kawai. T.

Details It is possible to choose the vertex that will be in the center.color="black") 195 layout. layouts) g <.game. Value A matrix with two columns and as many rows as the number of vertices in the input graph.com> See Also plot. that places one vertex in the center of a circle and the rest of the vertices equidistantly on the perimeter.graph. 2 .kawai) lay <. layout.kamada. edge. vertex.star Value A matrix with two columns and as many lines as the total number of vertices in the graphs.layout. layout.size=3. .igraph. The id of the vertex to put in the center.merge(graphs. By default it is the first vertex. layout=lay. the order of the vertices along the perimeter.lapply(graphs.disjoint. center = V(graph)[1].star(graph.lapply(sample(5:2 . Author(s) Gabor Csardi <csardi.union(graphs) ## Not run: plot(g.disjoint.layout.star Generate coordinates to place the vertices of a graph in a star-shape Description A simple layout generator.gabor@gmail. Numeric vector. The default ordering is given by the vertex ids. barabasi. labels=NA. and the order of the vertices can be also given. Usage layout. tkplot.union Examples # create 2 scale-free graphs and place them in a common layout graphs <. directed=FALSE) layouts <. graph. order = NULL) Arguments graph center order The graph to layout. replace=TRUE).

"all".mode’ and ‘arrow. weights = NULL.star(g) layout. vgap = 1. Supply NA here and igraph ignores the edge weights. then igraph calculates the layers automatically. ‘shape’. then it should specify the layer index of the vertices.star on how to create ring graphs.size’ edge attributes.igraph and tkplot on how to plot graphs and graph. the distance between layers.star(1 ) layout. "none")) Arguments graph layers The input graph. maxiter = 1 . If NULL. layers = NULL. if there is one. Examples g <.drl for other layout algorithms. A numeric vector or NULL. 100 is a reasonable default. Integer scalar. If NULL.com> See Also layout. Layers are numbered from one. If not NULL. Real scalar.gabor@gmail.sugiyama layout and layout. then the ’weight’ edge attribute is used. if you feel that you have too many edge crossings.sugiyama (graph. ‘default’ keeps the ‘size’. ‘all’ keep all graph.sugiyama The Sugiyama graph layout generator Description Sugiyama layout algorithm for layered directed acyclic graphs. The algorithm minimized edge crossings. Usage layout. plot. ‘none’ keeps none of them. Which graph/vertex/edge attributes to keep in the extended graph. ‘label’ and ‘color’ vertex attributes and the ‘arrow. the minimum horizontal gap between vertices in the same layer.graph. hgap = 1. Optional edge weight vector. vertex and edge attributes. hgap vgap maxiter weights attributes . the maximum number of iterations in the crossing minimization stage. attributes = c("default". increase this. ‘size2’.196 Author(s) Gabor Csardi <csardi. Real scalar.

dummy extd_graph The layout. The ‘dummy’ vertex attribute is set on this graph. You can also try to lay out undirected graphs. "ApexDC++ Speed-Mod" -+ "FlylinkDC++ ver <= 4xx". or graphs without an a priori layered assignment with this algorithm. The layout for the dummy vertices. Layers are indexed from zero. a two column matrix.com> References K. "FreeDC++" -+ "BMDC++":"EiskaltDC++". "LinuxDC++" -+ "FreeDC++". graphs containing cycles. "StrongDC++" -+ "StrongDC++ SQLite":"RSX++". to minimize edge crossings. "StrongDC++" -+ "AirDC++":"zK++":"ApexDC++":"TkDC++". Tagawa and M. This is achieved by adding dummy nodes to edges spanning more than one layer.narod. and it tells you whether the vertex is a dummy vertex. for the original graph vertices. The ‘layout’ graph attribute is also set. and it is the layout matrix for all (original and dummy) vertices. it is a logical attributes. . S. but there is no guarantee on the quality of the layout in such cases.graph. Sugiyama.ru/dc_clients/ DC <. IEEE Transactions on Systems. Examples ## Data taken from http://tehnick-8. see the reference below. "FlylinkDC++ ver <= 4xx" -+ "FlylinkDC++ ver >= 5xx".sugiyama Details 197 This layout algorithm is designed for directed acyclic graphs where each vertex is assigned to a layer. For more details. extended with dummy vertices. "BCDC++" -+ "StrongDC++". Toda. Value A list with the components: layout layout.layout. The Sugiyama layout may introduce “bends” on the edges in order to obtain a visually more pleasing layout. igraph will try to eliminate cycles and assign vertices to layers. Author(s) Tamas Nepusz <ntamas@gmail.formula("DC++" -+ "LinuxDC++":"BCDC++":"EiskaltDC++":"StrongDC++":"DiCe!++". The X coordinates of vertices within each layer are decided by the heuristic proposed by Sugiyama et al. Man and Cybernetics 11(2):109-125. 1981. "ApexDC++ Speed-Mod" -+ "GreylinkDC++". "StrongDC++ SQLite" -+ "FlylinkDC++ ver >= 5xx". The layout algorithm will also return the extended graph with the dummy nodes. "Methods for Visual Understanding of Hierarchical Systems". a two-column matrix. The original graph. "ApexDC++" -+ "FlylinkDC++ ver <= 4xx". The resulting layout assigns coordinates not only to the nodes of the original graph but also to the dummy nodes. and vertices of the same layer will be placed on the same horizontal line. "ApexDC++" -+ "ApexDC++ Speed-Mod":"DiCe!++".

c("LinuxDC++". "DiCe!++"). c("StrongDC++ SQLite".5) ## Another example. "TkDC++". c("BMDC++".sugiyama "FlylinkDC++ ver <= 4xx" -+ AvaLink.cex= . function(x) V(DC)$name %in% x). layers=apply(sapply(layers.5 ## Create a similar layout using the predefined layers lay1 <."white" V(DC)$shape <. collapse="\n")) E(DC)$arrow.label.layout.size <.1 V(DC)$label <..5) ## The same with automatic layer calculation ## Keep vertex/edge attributes in the extended graph lay2 <.2 ## Layers. "ApexDC++". "AirDC++".layout. 1. c("FlylinkDC++ ver >= 5xx". from the following paper: ## Markus Eiglsperger. "StrongDC++"). vertex. "ApexDC++ Speed-Mod".cex= .2 E(DC)["FreeDC++" %->% "EiskaltDC++"]$lty <.lapply(V(DC)$name.2 E(DC)["ApexDC++" %->% "DiCe!++"]$lty <. 4)) plot(DC.1 E(DC)["BCDC++" %->% "StrongDC++"]$lty <.1.2 E(DC)["StrongDC++ SQLite" %->% "FlylinkDC++ ver >= 5xx"]$lty <. "zK++". not very nice par(mar=rep(.5) ## Sugiyama plot plot(lay1$extd_graph.sugiyama(DC. c("FreeDC++". vertex.label. "GreylinkDC++" -+ AvaLink:"RayLinkDC++":"SparkDC++":PeLink) ## Use edge types E(DC)$lty <. function(x) paste(strwrap(x. "SparkDC++". "EiskaltDC++".label. as on the plot layers <. "PeLink")) ## Check that we have all nodes all(sort(unlist(layers)) == sort(V(DC)$name)) ## Add some graphical parameters V(DC)$color <.2 E(DC)["ApexDC++" %->% "FlylinkDC++ ver <= 4xx"]$lty <. "AvaLink".sugiyama(DC.198 layout. Michael Kaufmann: . vertex. attributes="all") plot(lay2$extd_graph."rectangle" V(DC)$size <. "RayLinkDC++". c("FlylinkDC++ ver <= 4xx". "BCDC++").list(c("DC++").2 V(DC)$size2 <. "GreylinkDC++"). "RSX++").2 E(DC)["GreylinkDC++" %->% "AvaLink"]$lty <. which)) ## Simple plot.cex= . Martin Siebenhaller. layout=lay1$layout. 12).

vertex. Journal of Graph Algorithms and ## Applications 9. nrow(layex$layout. 14. 1 . 5.formula( -+ 1 -+ 2 -+ 3 -+ 4. 6.19). layers=apply(sapply(layers. 2 :16. 8 -+ 9 -+ 1 -+ 11 -+ 12 -+ 13 -+ 14 -+ 15 -+ 16 -+ 17 -+ 18 -+ 19 -+ 2 -+ 21 -+ 22 -+ 23 -+ 24 -+ 25 -+ 26 -+ 27 -+ 28 -+ 29 -+ 29: 6: 5:2 : 4.15). c(29. 18.graph. c(25.get. 16:27. vertex. 13. 26.arrow. 25 199 ) layers <. 3). 24). 4.mode=ifelse(realedge. 5 -+ 6 -+ 7. 28: 4. ex <.2] <= vcount(ex) plot(layex$extd_graph. 18). 2 . function(x) V(ex)$name %in% as.label=ifelse(origvert. vertex. c(5. vcount(ex)). 27. 16.dummy))) realedge <.character(x)).list( .layout.8. 27.layout.arrow.c(rep(TRUE.22). c(23.21). which)) origvert <. 9:16. 3. vertex. 2. ).5.edgelist(layex$extd_graph)[. V(ex)$name. 4. c(13. 3 5--325 (2 5).size=ifelse(origvert. ""). c(1. 9:24. c(4. edge. rep(FALSE. 2:1 :14:26: 4: 3. 23: 8.label. 1 . c(2. 8: 9. edge.sugiyama ## An Efficient Implementation of Sugiyama’s Algorithm for ## Layered Graph Drawing. 17). 7. 11. "square". 12. 2 ). 27. 9:29:25:21:13. 1.cex= . 28). 22.sugiyama(ex. )) .size=. 12.shape=ifelse(origvert. 9:19. c(11. 7 ) layex <. 13:19. c(9. 9. 12:15:28.5. "none").

community(graph.le. B.eigenvector. options = igraph. a P[i.membership the number of merges to produce from the supplied membership vector. Usage leading. The environment in which the callback function is evaluated.default.community.to. Should be undirected as the method needs a symmetric matrix.eigenvector. then it must be callback function. It is not a particularly useful parameter.to. For community. NULL. and P contains the probability that certain edges are present according to the ‘configuration model’.community Community structure detecting based on the leading eigenvector of the community matrix Description This function tries to find densely connected subgraphs in a graph by calculating the leading nonnegative eigenvector of the modularity matrix of the graph. . see the reference below. The starting community structure on which steps merges are performed.eigenvector. which is B=A-P. The number of steps to take.le. In other words. See details below. giving the start configuration of the algorithm.200 leading. membership) Arguments graph steps The input graph. A being the adjacency matrix of the (undirected) network. or a numeric membership vector. this is actually the number of tries to make a step.community leading.eigenvector. The heart of the method is the definition of the modularity matrix. This is called after each iteration.j] element of P is the probability that there is an edge between vertices i and j in a random network in which the degrees of all vertices are the same as in the input graph. after calculating the leading eigenvector of the modularity matrix. steps = -1. Additional argument to supply to the callback function.frame()) community. If not NULL. possible from the result of leading. extra = NULL. A named list to override some ARPACK options. The merge matrix.arpack. callback = NULL.membership(merges. env = parent. start membership options callback extra env merges Details The function documented in these section implements the ‘leading eigenvector’ method developed by Mark Newman. steps. start = NULL.

when no more splits are possible.gabor@gmail.leading. the first line is the first merge and it creates community ‘N’. Information about the underlying ARPACK computation. 2006. etc. The following arguments are supplied to this function: membership The actual membership vector.le.community.community 201 The leading eigenvector method works by calculating the eigenvector of the modularity matrix for the largest positive eigenvalue and then separating vertices into two community based on the sign of the corresponding element in the eigenvector. with zero-based indexing. community numbering starts with zero here.membership returns a named list with two components: membership csize Callback functions The callback argument can be used to supply a function that is called after each eigenvector calculation.memberhip creates a membership vector from the result of leading. The communities are always numbered from one. N is the number of initial communities in the graph. extra The extra argument that was passed to leading. Supply the vector as an argument to perform this multiplication. a numerical vector indication which vertex belongs to which community. see arpack for details.community.to. This function can be used with ARPACK. community The community that the algorithm just tried to split. value The eigenvalue belonging to the leading eigenvector the algorithm just found. multiplier An R function that can be used to multiple the actual modularity matrix with an arbitrary vector. according to the supplied merges matrix.eigenvector. This is a two-column matrix and each line describes a merge of two communities.eigenvector. Physical Review E 74 036104.community returns a named list with the following members: membership merges The membership vector at the end of the algorithm. Author(s) Gabor Csardi <csardi. the second line creates community N+1. It takes membership and permformes steps merges. Check Newman’s paper to understand why this is a good method for detecting community structure.le. .to.eigenvector. The merges matrix starting from the state described by the membership member. options community.com> References MEJ Newman: Finding community structure using the eigenvectors of matrices. Value leading. If all elements in the eigenvector are of the same sign that means that the network has no underlying comuunity structure. community. A membership vector.eigenvector. A numeric vector giving the sizes of the communities. vector The leading eigenvector the algorithm just found.

L(G) has one vertex for each edge in G and two vertices in L(G) are connected by a directed edge if the target of the first vertex’s corresponding edge is the same as the source of the second vertex’s corresponding edge.add.graph. the first version of the C code was written by Vincent Matossian. 11)) lec <. start=membership(lec)) line. fastgreedy.community(g) lec leading.202 See Also line.full(5) %du% graph.com>. c(1.eigenvector. it can be directed or undirected. 1. The line graph L(G) of a G directed graph is slightly different.community. as.leading.dendrogram Examples g <. The input graph. edge.full(5) g <.community. Author(s) Gabor Csardi <csardi. 6.graph(graph) Arguments graph Details The line graph L(G) of a G undirected graph is defined as follows.6. Usage line. Value A new graph object.full(5) %du% graph. walktrap.11.graph Line graph of a graph Description This function calculates the line graph of another graph.eigenvector.graph modularity. .community.edges(g.betweenness.gabor@gmail. L(G) has one vertex for each edge in G and two vertices in L(G) are connected by an edge if their corresponding edges share an end point.community(g.

cardinality.graph(g)) line.cardinality. (1984). It may be directed.search Maximum cardinality search Description Maximum cardinality search is a simple ordering a vertices that is useful in determining the chordality of a graph.graph(line. and also is. Value A list with two components: alpha alpham1 Author(s) Gabor Csardi <csardi. as the algorithm is defined for undirected graphs.search(graph) Arguments graph The input graph. SIAM Journal of Computation 13. The inverse of alpha.search Examples # generate the first De-Bruijn graphs g <. Numeric vector. and selectively reduce acyclic hypergraphs. The vertices ordered according to the maximum cardinality search.graph(g) line. test acyclicity of hypergraphs. Ties are broken randomly.gabor@gmail.graph(line. Usage maximum. Simple linear-time algorithms to test chordality of graphs.com> References Robert E Tarjan and Mihalis Yannakakis.full(2.graph(g))) 203 maximum. see References below.graph(line.maximum.chordal.graph. The algorithm provides a simple basis for deciding whether a graph is chordal. Numeric vector. directed=TRUE. but edge directions are ignored. . Details Maximum cardinality search visits the vertices in such an order that every time the vertex with the most already visited neighbors is visited. loops=TRUE) line.cardinality. 566–579.

Usage minimal. J-H:I) maximum.formula(A-B:C:I. t) vertex separator. D-B:F:E:C:G.graph. fillin=TRUE) minimal.204 See Also is. t) vertex separator is minimal if none of its subsets is an (s. for some s and t. there is no path between s and t in the graph. I-G:H:J. G-C:D:H:I. E-A:B:C:D:F. H-C:E:G:I.graph.separators(graph) Arguments graph Details A (s.formula(A-B:E.cardinality. F-D:E:G.gabor@gmail. in an undirected graph. B-A:E:F:D. H-G:I:J. G-F:H.search(g2) is. E-C:D:F:H. B-A:C:D.st. Author(s) Gabor Csardi <csardi.separators Minimum size vertex separators Description List all vertex sets that are minimal (s.cardinality. F-B:D:E. I-A:H) maximum.com> The input graph. D-B:E:F.t) separators for some s and t.chordal(g2. C-E:D:G.t) separator of the input graph.st. such that after their removal from the graph. . but edge directions are ignored. fillin=TRUE) g2 <. A (s.st. C-A:B:E:H. t) vertex separator is a set of vertices.chordal(g1. each vector is an (s.search(g1) is. Each vector contains a vertex set (defined by vertex ids). It may be directed.chordal Examples ## The examples from the Tarjan-Yannakakis paper g1 <. Value A list of numeric vectors.separators minimal.

minimum.st. . but edge directions are ignored.size. In: Peter Widmayer. Author(s) Gabor Csardi <csardi. See the reference below for the details. Springer. In the special case of a fully connected input graph with n vertices.separators(ring) chvatal <.ring(4) minimal. It may be directed.gabor@gmail. all subsets of size n − 1 are listed as the result.size.separators (graph) Arguments graph Details This function implements the Kanevsky algorithm for finding all minimal-size vertex separators in an undirected graph.graph.famous("chvatal") minimal.st.separators References 205 Anne Berry. 1999. Examples ring <. Jean-Paul Bordat and Olivier Cogis: Generating All the Minimal Separators of a Graph. 167–172.com> The input graph.graph. Gabriele Neyer and Stephan Eidenbenz (editors): Graph-theoretic concepts in computer science.size. Value A list of numeric vectors. Each numeric vector is a vertex separator.separators Minimum size vertex separators Description Find all vertex sets of minimal size whose removal separates the graph into more components Usage minimum. 1665.separators(chvatal) minimum.

See Also is.character(7:16)) as.separators(mw5) # Another example. 15-16.Bill:Jennie:Ann.separators(camp).size.subgraph(mw. the science camp network camp <. mw2 <. minimum. 3-4:6:7. 68 103–127. Jennie .induced.separators(mw3) minimum.Holly:Michael:Lee:Ann:Pauline.size.size.Harry:Steve:Don:Bert.Pauline:Michael:Lee:Holly.size. American Sociological Review. 1993. Pam:Brazey:Carol:Pat . Gery .11.Gery:Russ:Michael) lapply(minimum. Michael .separators Arkady Kanevsky: Finding all minimum-size separating vertex sets in a graph. 17:23))) as. Holly .subgraph(mw. 9-1 . Pauline . 8-9:11:14. 2-3:4:5:7. Networks 23 533– 541. 18-2 :21.induced.size.Pat:Steve:Russ:John. 7-8:11:14:19.size. Lee .Pam:Brazey:Carol:Pat. John . J. mw4 <. 5-6:7:21. 19-2 :22:23. function(x) V(camp)[x]) as.14))) as. White. 351–372.Michael:Jennie:Pauline.character(c(7. JS Provan and DR Shier: A Paradigm for listing (s. mw5 <. mw3 <.formula(1-2:3:4:5:6.character(17:23)) as. 12-16. 4-5:6:7.character(c(1:7.Bill:Jennie:Ann:Lee:John.character(1:7)) . 1 -12:13.separators(mw1) minimum. 1996. Feb 2003. 21-22:23.graph. Algorithmica 15.Carol:Pat:Pam:Jennie:Bill.separators(mw2) minimum.size. Structural cohesion and embeddedness: A hierarchical concept of social groups.graph.8. 17-18:19:2 .formula(Harry:Steve:Don:Bert . 6-7.separator Examples # The graph from the Moody-White paper mw <.separators(mw4) minimum.t)-cuts in graphs. Russ . Moody and D. R.induced.Steve:Bert:Gery:John. 13-16.induced.206 References minimum. 11-12:14.induced.size. 22-23) # Cohesive subgraphs mw1 <.Michael:Bill:Jennie.subgraph(mw. 14-15. 2 -21. Ann .subgraph(mw.separators(mw) minimum. Bill .subgraph(mw.

See Also clusters . Author(s) Gabor Csardi <csardi. This is ignored if the unweighted algorithm is chosen The algorithm to use for calculation. If this is NULL then igraph tries to select the algorithm automatically: if the graph has an edge attribute called weight of the weights argument is not NULL then Prim’s algorithm is chosen. Details If the graph is unconnected a minimum spanning forest is returned. Value A graph object with the minimum spanning forest..tree Minimum spanning tree Description A subgraph of a connected graph is a minimum spanning tree if it is tree. ..) The edge and vertex attributes of the original graph are preserved in the result..) Arguments graph weights The graph object to analyze. algorithm . Additional arguments.C. Numeric algorithm giving the weights of the edges in the graph. 1957. and the sum of its edge weights are the minimal among all tree subgraphs of the graph. and prim runs Prim’s algorithm for weighted graphs.spanning. weights=NULL. unweighted can be used for unwieghted graphs.spanning.com> References Prim.. The order is determined by the edge ids.tree(graph.minimum. A minimum spanning forest of a graph is the graph consisting of the minimum spanning trees of its components. R.gabor@gmail. otherwise the unwweighted algorithm is performed.spanning. Shortest connection networks and some generalizations Bell System Technical Journal.tree 207 minimum. Usage minimum. unused. algorithm=NULL. (To check that it is a tree check that the number of its edges is vcount(graph)-1. 37 1389–1401.

208 Examples
g <- erdos.renyi.game(1 , 3/1 ) mst <- minimum.spanning.tree(g)

modularity

modularity

Modularity of a community structure of a graph

Description This function calculates how modular is a given division of a graph into subgraphs. Usage ## S3 method for class ’igraph’ modularity(x, membership, weights = NULL, ...) Arguments x membership weights ... Details The modularity of a graph with respect to some division (or vertex types) measures how good the division is, or how separated are the different vertex types from each other. It defined as Q= 1 2m Aij −
i,j

The input graph. Numeric vector, for each vertex it gives its community. The communities are numbered from one. If not NULL then a numeric vector giving edge weights. Additional arguments, none currently.

ki kj δ (ci , cj ), 2m

here m is the number of edges, Aij is the element of the A adjacency matrix in row i and column j , ki is the degree of i, kj is the degree of j , ci is the type (or component) of i, cj that of j , the sum goes over all i and j pairs of vertices, and δ (x, y ) is 1 if x = y and 0 otherwise. If edge weights are given, then these are considered as the element of the A adjacency matrix, and ki is the sum of weights of adjacent edges for vertex i. Value A numeric scalar, the modularity score of the given configuration. Author(s) Gabor Csardi <csardi.gabor@gmail.com>

multilevel.community References

209

MEJ Newman and M Girvan: Finding and evaluating community structure in networks. Physical Review E 69 026113, 2004. See Also walktrap.community, edge.betweenness.community, fastgreedy.community, spinglass.community for various community detection methods. Examples
g <- graph.full(5) %du% graph.full(5) %du% graph.full(5) g <- add.edges(g, c(1,6, 1,11, 6, 11)) wtc <- walktrap.community(g) modularity(wtc) modularity(g, membership(wtc))

multilevel.community

Finding community structure by multi-level optimization of modularity

Description This function implements the multi-level modularity optimization algorithm for finding community structure, see references below. It is based on the modularity measure and a hierarchial approach. Usage multilevel.community (graph, weights = NULL) Arguments graph weights The input graph. Optional positive weight vector. If the graph has a weight edge attribute, then this is used by default. Supply NA here if the graph has a weight edge attribute, but you want to ignore it.

Details This function implements the multi-level modularity optimization algorithm for finding community structure, see VD Blondel, J-L Guillaume, R Lambiotte and E Lefebvre: Fast unfolding of community hierarchies in large networks, http://arxiv.org/abs/arXiv: 8 3. 476 for the details. It is based on the modularity measure and a hierarchial approach. Initially, each vertex is assigned to a community on its own. In every step, vertices are re-assigned to communities in a local, greedy way: each vertex is moved to the community with which it achieves the highest contribution to modularity. When no vertices can be reassigned, each community is considered a vertex on its own, and the process starts again with the merged communities. The process stops when there is only a single vertex left or when the modularity cannot be increased any more in a step. This function was contributed by Tom Gregorovic.

210 Value

neighborhood

multilevel.community returns a communities object, please see the communities manual page for details. Author(s) Tom Gregorovic, Tamas Nepusz <tamas@cs.rhul.ac.uk> References Vincent D. Blondel, Jean-Loup Guillaume, Renaud Lambiotte, Etienne Lefebvre: Fast unfolding of communities in large networks. J. Stat. Mech. (2008) P10008 See Also See communities for extracting the membership, modularity scores, etc. from the results.

Other community detection algorithms: walktrap.community, spinglass.community, leading.eigenvector.community edge.betweenness.community, fastgreedy.community, label.propagation.community Examples
# This is so simple that we will have only one level g <- graph.full(5) %du% graph.full(5) %du% graph.full(5) g <- add.edges(g, c(1,6, 1,11, 6, 11)) multilevel.community(g)

neighborhood

Neighborhood of graph vertices

Description These functions find the vertices not farther than a given limit from another fixed vertex, these are called the neighborhood of the vertex. Usage neighborhood.size(graph, order, nodes=V(graph), mode=c("all", "out", "in")) neighborhood(graph, order, nodes=V(graph), mode=c("all", "out", "in")) graph.neighborhood(graph, order, nodes=V(graph), mode=c("all", "out", "in")) connect.neighborhood(graph, order, mode=c("all", "out", "in", "total"))

neighborhood Arguments graph order nodes mode The input graph. Integer giving the order of the neighborhood. The vertices for which the calculation is performed.

211

Character constatnt, it specifies how to use the direction of the edges if a directed graph is analyzed. For ‘out’ only the outgoing edges are followed, so all vertices reachable from the source vertex in at most order steps are counted. For ‘"in"’ all vertices from which the source vertex is reachable in at most order steps are counted. ‘"all"’ ignores the direction of the edges. This argument is ignored for undirected graphs.

Details The neighborhood of a given order o of a vertex v includes all vertices which are closer to v than the order. Ie. order 0 is always v itself, order 1 is v plus its immediate neighbors, order 2 is order 1 plus the immediate neighbors of the vertices in order 1, etc. neighborhood.size calculates the size of the neighborhoods for the given vertices with the given order. neighborhood calculates the neighborhoods of the given vertices with the given order parameter. graph.neighborhood is creates (sub)graphs from all neighborhoods of the given vertices with the given order parameter. This function preserves the vertex, edge and graph attributes. connect.neighborhood creates a new graph by connecting each vertex to all other vertices in its neighborhood. Value neighborhood.size returns with an integer vector. neighborhood returns with a list of integer vectors. graph.neighborhood returns with a list of graphs. connect.neighborhood returns with a new graph object. Author(s) Gabor Csardi <csardi.gabor@gmail.com>, the first version was done by Vincent Matossian Examples
g <- graph.ring(1 ) neighborhood.size(g, , 1:3) neighborhood.size(g, 1, 1:3) neighborhood.size(g, 2, 1:3) neighborhood(g, , 1:3) neighborhood(g, 1, 1:3) neighborhood(g, 2, 1:3) # attributes are preserved

212
V(g)$name <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j") graph.neighborhood(g, 2, 1:3) # connecting to the neighborhood g <- graph.ring(1 ) g <- connect.neighborhood(g, 2)

nexus

nexus

Query and download from the Nexus network repository

Description The Nexus network repository is an online collection of network data sets. These functions can be used to query it and download data from it, directly as an igraph graph. Usage nexus.list(tags=NULL, offset= , limit=1 , operator=c("or", "and"), order=c("date", "name", "popularity"), nexus.url=getIgraphOpt("nexus.url")) nexus.info(id, nexus.url=getIgraphOpt("nexus.url")) nexus.get(id, offset= , order=c("date", "name", "popularity"), nexus.url=getIgraphOpt("nexus.url")) nexus.search(q, offset= , limit=1 , order=c("date", "name", "popularity"), nexus.url=getIgraphOpt("nexus.url")) ## S3 method for class ’nexusDatasetInfo’ print(x, ...) ## S3 method for class ’nexusDatasetInfoList’ summary(object, ...) ## S3 method for class ’nexusDatasetInfoList’ print(x, ...) Arguments tags offset limit operator A character vector, the tags that are searched. If not given (or NULL), then all datasets are listed. An offset to select part of the results. Results are listed from offset+1. The maximum number of results to return. A character scalar. If ‘or’ (the default), then all datasets that have at least one of the given tags, are returned. If it if ‘and’, then only datasets that have all the given tags, are returned. The ordering of the results, possible values are: ‘date’, ‘name’, ‘popularity’.

order

list and nexus.nexus id 213 The numeric or character id of the data set to query or download. The nexus. For the complete documentation please see the Nexus homepage at http://nexus. licence url Character scalar. q nexus. ‘2011-01-09’. nexus. Other common tags are: ‘weighted’. unless you set up your own Nexus server. and multiple networks are separated by spaces. only the first search hit is downloaded. vertices/edges Character. name Character scalar.search searches Nexus.object . the name of the dataset.list have the following fields: id The numeric id of the dataset. They both return nexusDatasetInfo objects. .g. nexus. and programatic data download as well. networks The ids and names of the networks in the data set. and if the data set consists of multiple networks. See examples below. tags Character vector. Nexus search string. ‘bipartite’. this is usually a single sentence.. The various formats are separated by semicolons. nexusDatasetInfo objects returned by nexus. e. See below for some search examples.get downloads a data set from Nexus.igraph. ‘social network’. the number of vertices and edges in the graph(s). as nexusDatasetInfo objects. and returns a list of data sets. etc. the tags of the dataset. the licence of the dataset. Directed graph have the tags ‘directed’.info returns more information than nexus.url x. nexus.) The nexusDatasetInfo objects returned by nexus. it is possible to supply a nexusDatasetInfo or nexusDatasetInfoList object here directly and then the query is done on the corresponding data set(s).info have the following additional fields: date Character scalar. sid The character id of the dataset. The nexusDatasetInfo object to print. the short description of the dataset. or based on a Nexus search string. Vertices and edges are separated by a slash. the data formats in which the data set is available. but see also the offset argument. with an API that allow programatic queries against it. based on its numeric id. The numeric and character id are separated by a slash. the URL of the licence of the dataset. the date when the dataset was added to the database.list. then the function returns an error. (If there are not data sets found. Pleaase make sure you consult this before using a dataset.org.. For search strings. Instead of the data set ids. The URL of the Nexus server. then they are separated by spaces. Undirected graphs are tagged as ‘undirected’. Currently ignored. summary Character scalar. licence Character scalar. formats Character vector. Don’t change this from the default. Details Nexus is an online repository of networks.info functions query the online database.

similar to the format of igraph graphs. nexus citation Character scalar.4 39/1 9-223 [2] condmatcollab2 3 31163/12 29 [3] condmatcollab 16726/47594 [4] powergrid 4941/6594 [5] celegansneural 297/2359 #18 #17 #16 #15 #14 Kapferer tailor shop Condensed matter collaborations+ Condensed matter collaborations+ Western US power grid C. Elegans neural network Each line here represents a data set. For data sets with multiple graphs. the number of vertices and number of edges in the graph of the data sets. and the following information is given about them: the character id of the data set (e. Please cite these papers if you are using the dataset in your research. vertex or edge attribute and has the following entries: type Type of the attribute. The results of the Nexus queries are printed to the screen in a consise format. Value nexus. The third character is ‘W’ for weighted graphs. but there are some differences as well. A data set list (typically the result of nexus. The second is ‘N’ named graphs. the licence of most datasets requires this. the smallest and the largest values are given.list and nexus.search) looks like this: NEXUS 1-5/18 -. and the string id of the data set. intervals are given here.39 1 9-223 #18 kaptail -. Detailed data set information is printed similarly. name Character scalar.search return a list of nexusDatasetInfo objects. The list also has these attributes: size The number of data sets returned by the query. Then the number of vertices and number of edges are printed. description Character scalar.Kapferer tailor shop + tags: directed.data set list [1] kaptail. the fourth is ‘B’ if the data set contains bipartite graphs. 2/KAPFTS2. . The four characters after the NEXUS word give the most important properties of the graph(s): the first is ‘U’ for undirected and ‘D’ for directed graphs. the name of the attribute. attributes A list of lists. Summary information about an individual Nexus data set is printed as NEXUS B--. 3/KAPFTI1. Then comes the numeric id. datatype Data type of the attribute. the description of the attribute. the full description of the dataset. The end of the first line contains the name of the data set. for data sets with multiple graphs. and ‘B’ if the data set contains both directed and undirected graphs.list and nexus. kaptail or powergrid). social network. each list entry is a graph. but it contains more fields. undirected + nets: 1/KAPFTI2. 4/KAPFTS1 This is very similar to the header that is used for printing igraph graphs. The second row lists the data set tags.g. the paper(s) describing the dataset. and the third row the networks that are included in the data set. currently it can be ‘numeric’ and ‘string’.214 description Character scalar. either ‘graph’. Then the numeric id of the data set and the reamining space is filled with the name of the data set. ‘vertex’ or ‘edge’.

search("blog or US or karate") ## End(Not run) optimal.info returns a single nexusDatasetInfo object.igraph.get(2) summary(g) ## Data sets related to ’US’: nexus.community Optimal community structure Description This function calculates the optimal community structure of a graph.list(limit=3.list(tag="weighted") nexus. 215 nexus.org Examples ## Not run: nexus. Usage optimal. nexus.nexus.optimal.list(limit=3. Author(s) Gabor Csardi <csardi.community totalsize The total number of data sets found for the query. limit The limit parameter of the query.search("name:network") ## Any word can match nexus.get returns an igraph graph object. if the data set consists of multiple networks. by maximizing the modularity measure over all possible partitions. order="name") nexus.gabor@gmail. or a list of graph objects.search("US") ## Search for data sets that have ’network’ in their name: nexus. offset The offset parameter of the query.community(graph) . order="name")[[1]] nexus.info(2) g <.com> See Also http://nexus.

This means that you probably don’t want to run this function on larger graphs. Zoran Nikoloski. in terms of maximal modularity score. Examples ## Zachary’s karate club g <.216 Arguments graph Details optimal. This function calculates the optimal community structure for a graph. IEEE Transactions on Knowledge and Data Engineering 20(2):172-188. See also fastgreedy. Note that modularity optimization is an NP-complete problem. Please the reference below for details.community returns a communities object. Daniel Delling. Edge directions are ignored for directed graphs.com> References Ulrik Brandes.community The input graph.famous("Zachary") ## We put everything into a big ’try’ block. modularity. Author(s) Gabor Csardi <csardi. graphs with a couple of hundred vertices might be possible.community(g) ## Double check the result print(modularity(oc)) print(modularity(g. membership(oc))) .optimal. See Also communities for the documentation of the result.community for a fast greedy optimizer. and then calling the GLPK library to solve that. in case ## igraph was compiled without GLPK support try({ ## The calculation only takes a couple of seconds oc <. and all known algorithms for it have exponential time complexity.gabor@gmail. The calculation is done by transforming the modularity maximization into an integer programming problem. Marco Gaertler. Graphs with up to fifty vertices should be fine. 2008. please see the communities manual page for details. Robert Gorke. Martin Hoefer.graph. Dorothea Wagner: On Modularity Clustering. Value optimal.

rank.community(g) print(modularity(fc)) }. This argument can be used to give edge weights for calculating the weighted PageRank of vertices. silent=TRUE) 217 page. The maximum number of iterations to perform. 1.fastgreedy.default) page. See arpack for details. damping = . For personalized PageRank. Logical. Usage page. It is ignored for undirected graphs. The vertices of interest. weights options niter eps old .rank (graph. The algorithm will consider the calculation as complete if the difference of PageRank values between iterations change less than this value for every node. If this is NA. See details below. but it is given by this vector. Optional vector giving a probability distribution to calculate personalized PageRank. If weights is a numerical vector then it used. If this is NULL and the graph has a weight edge attribute then that is used.5) normalization to use. directed = TRUE. The vector should contains an entry for each vertex and it will be rescaled to sum up to one.arpack. directed = TRUE.rank The Page Rank algorithm Description Calculates the Google PageRank for the specified vertices. to override some ARPACK options.85.page.old (graph.85. vids = V(graph). personalized = NULL. damping = . A named list.rank ## Compare to the greedy optimizer fc <. even if the graph has a weights edge attribute. the probability of jumping to a node when abandoning the random walk is not uniform. whether the old style (pre igraph 0. if true directed paths will be considered for directed graphs. old = FALSE) Arguments graph vids directed damping personalized The graph object. options = igraph. niter = 1 . A numerical vector or NULL. vids = V(graph). eps = . weights = NULL. The damping factor (‘d’ in the original paper). then no edge weights are used (even if the graph has a weight edge attribute. A logical scalar.

218 Details page. It should be always exactly one. see the following webpage: http://www-db. If this argument is FALSE (the default). betweenness.com> References Sergey Brin and Larry Page: The Anatomy of a Large-Scale Hypertextual Web Search Engine. It should be avoided for new code. all of them must be calculated.rank a named list with entries: vector value options A numeric vector with the PageRank scores. For page. degree . see also arpack. The eigenvalue corresponding to the eigenvector with the page rank scores. If this argument is TRUE then (1 − d) is added. d is the damping factor. Proceedings of the 7th World-Wide Web Conference. then the proper PageRank algorithm is used.5 (and later) contains two PageRank calculation implementations. April 1998.edu/~backrub/google. Please note that the PageRank of a given vertex depends on the PageRank of all other vertices. April 1998. The page. so even if you want to calculate the PageRank for only some of the vertices. is does not necessarily converge to a fixed point. Since the calculation is an iterative process. Requesting the PageRank for only some of the vertices does not result in any performance increase at all.old has an argument called old. the algorithm is stopped after a given count of iterations or if the PageRank value differences between iterations are less than a predefined value.e.gabor@gmail.html. Author(s) Tamas Nepusz <ntamas@gmail. (1 − d)/n is added to the weighted PageRank of vertices to calculate the next iteration.rank.rank For the explanation of the PageRank algorithm. Australia. The page. See Also Other centrality scores: closeness. igraph 0.old function performs a simple power method.old a numeric vector of Page Rank scores.com> and Gabor Csardi <csardi. Australia. Value For page.5 igraph versions. Brisbane. this is the implementation that was available under the name page.rank. See arpack for details. and n is the total number of vertices. Proceedings of the 7th World-Wide Web Conference. or the following reference: Sergey Brin and Larry Page: The Anatomy of a Large-Scale Hypertextual Web Search Engine.rank in pre 0. A further difference is that the old implementation does not renormalize the page rank vector after each iteration.rank function uses ARPACK to perform the calculation. just like in the PageRank paper. Note that the old=FALSE method is not stable. Note that page. Brisbane. stanford.rank. it is only included for compatibility with old igraph versions. i. Some information about the underlying ARPACK calculation.

random.rank(g3)$vector reset <. vertex and edge attributes of the graph.vertices Examples g <.rank(g)$vector g2 <. Author(s) Gabor Csardi <csardi. etc.permute. permutation) Arguments graph permutation The input graph.vertices Permute the vertices of a graph Description Create a new graph.vertices(graph.game(2 .com> . personalized=reset)$vector 219 permute.vertices keeps all graph. directed=TRUE) page.graph.graph. Value A new graph object. Every number between one and vcount(graph) must appear exactly once. Details This function creates a new graph from the input graph by permuting its vertices according to the specified mapping.rank(g2)$vector # Personalized PageRank g3 <. it can directed or undirected. permute.ring(1 ) page. A numeric vector giving the permutation to apply.rank(g3.graph.permutation to create the canonical form of a graph. The first element is the new id of vertex 1. Call this function with the output of canonical. by permuting vertex ids. 5/2 .seq(vcount(g3)) page. Usage permute.gabor@gmail.star(1 ) page.

color A list of color vectors to use for the pies. 5 . sample(vcount(g))) graph.gabor@gmail. There are some extra graphical vertex parameters that specify how the pie charts will look like: pie Numeric vector.permute. in the same format as pie. 2 . If it is a list of a single vector. etc. pie.sample(1:5.isomorphic(g. pie.game(2 . then this is used for all pies.border The color of the border line of the pie charts. sample(vcount(g))) graph. pie charts can be used as vertices.lty The line type of the border of the slices.angle The slope of shading lines. pie. E. to denote vertex classes. ecount(g).220 See Also canonical.density The density of the shading lines. Non-positive values inhibit the drawing of shading lines.graph. Author(s) Gabor Csardi <csardi. Details The vertex shape ‘pie’ makes igraph draw a pie chart for every vertex.permute. Gnm. gives the sizes of the pie slices. given as an angle in degrees (counter-clockwise). type="gnm") g2 <.color. then it is recycled. fuzzy classification of vertices. in lines per inch.permutation Examples # Random permutation of a random graph g <. It the color vector is shorter than the number of areas in a pie. 5 " V(g)$name <.vertices(g. g2) # Permutation keeps all attributes g$name <.vertices(g. pie.g. g2) g2$name V(g2)$name E(g2)$weight all(sort(E(g2)$weight) == sort(E(g)$weight)) Pie charts as vertices Pie charts as vertices Using pie charts as vertices in graph plots Description More complex vertex images can be used to express addtional information about vertices.letters[1:vcount(g)] E(g)$weight <. pie."Random graph. replace=TRUE) g2 <.com> .random.isomorphic(g.

alpha= . Logical. Defaults to the empty string. mark.color=list(heat. vertex.expand=15. Usage ## S3 method for class ’igraph’ plot(x. Subtitle. alpha=1)..length=1 ). function(x) sample(1:1 .3). mark.lapply(1:1 .plot. or delete the device’s current contents first. whether to add the plot to the current device.plotting. The limits for the horizontal axis. axes=FALSE.1)..groups=list().graph.igraph See Also igraph.pie=values. Main title. ylim=c(-1. it is unlikely that you want to modify this. mark. add=FALSE. sub="". defaults to FALSE. ylab="". The label of the vertical axis.shape=1/2. xlim=c(-1.groups). vertex. it is unlikely that you want to modify this. The label of the horizontal axis.pie.1). plot. .size=seq(1 . mark. xlab="".igraph Plotting of graphs Description plot.groups).border=rainbow(length(mark.label=NA) } 221 plot. It is the non-interactive companion of the tkplot function. vertex.) Arguments x axes xlab ylab add xlim ylim main sub The graph to plot. The limits for the vertical axis. . vertex.igraph Examples g <. vertex.graph is able to plot graphs to any R device.colors(5)). Logical scalar. mark. main="".3)) if (interactive()) { plot(g.col=rainbow(length(mark. Defaults to the empty string.3 .ring(1 ) values <. whether to plot axes.shape="pie".

Examples g <. then different values are used for the different vertex groups. If a vector is given..graph. A numeric scalar or vector.plotting for the detailed description of the plotting parameters and tkplot and rglplot for other graph plotting functions. See igraph. symbolic color names.kamada. A scalar or vector giving the colors of marking the polygons.ring(1 ) ## Not run: plot(g.getcoords function and use them with plot to plot the graph to any R device. invisibly. Value Returns NULL. Author(s) Gabor Csardi <csardi. by plotting a colored smoothed polygon around and “under” it. If it is NA. the size of the border around the marked vertex groups. Additional plotting parameters. query the coordinates by the tkplot. layout=layout.color="green") .igraph A list of vertex id vectors.222 mark.border mark. then no border is drawn. or colors in RGB. its possible values are between -1 and 1. vertex. in any format accepted by xspline. A numeric scalar or vector. It is in the same units as the vertex sizes. It is interpreted as a set of vertex groups.com> See Also layout for different layouts.kawai. This is basically the ‘shape’ parameter of the xspline function.plotting for the complete list. Controls the smoothness of the vertex group marking polygons.gabor@gmail. igraph.g. numeric color ids. Each vertex group is highlighted.. See the arguments below to control the look of the polygons.col mark.groups plot. mark. A scalar or vector giving the colors of the borders of the vertex group marking polygons.shape mark.expand . then a different value is used for the different vertex groups. e. handtune the placement of the vertices. If it is a vector. Details One convenient way to plot graphs is to plot with tkplot first.

force. . In a power-law distribution. For implementation ‘R. For the ‘plfit’ implementation non-integer values might be present and then a continuous power-law distribution is fitted. . igraph will assume a continuous distribution if at least one sample is non-integer and assume a discrete distribution otherwise. then the BFGS optimization (see mle) algorithm is applied.mle")..law. start implementation Character scalar. The goal of this function is to determine α if xmin is given. and its value will be automatically determined for the ‘plfit’ implementation. "R. Which implementation to use. Additional arguments.continuous Logical scalar. power. Whether to force a continuous distribution for the ‘plfit’ implementation. Ususally it is safe to leave this untouched. so it is possible to change the optimization method and/or its parameters.law.fit fits a power-law distribution to a data set.mle’. Details This function fits a power-law distribution to a vector containing samples from a distribution (that is assumed to follow a power-law of course).mle’ implementation.law. the smallest value in x will be used for the ‘R. or to determine xmin and the corresponding value of α. If the implementation argument is ‘R. passed to the maximum likelihood optimizing function..power. . even if the sample vector contains integer values only (by chance). In many real-world cases. If this argument is false. mle.fit Fitting a power-law distribution function to discrete data Description power. implementation=c("plfit". Numeric scalar. force.fit 223 power.fit(x. xmin Numeric scalar. The initial value of the exponent for the minimizing function. See details below.mle’ the data must be integer values. the power-law behaviour kicks in only above a threshold value xmin .) Arguments x The data to fit. xmin=NULL. It is ignored by the ‘plfit’ implementation... a numeric vector.mle’ implementation is chosen. Usage power.continuous=FALSE. or NULL.mle’ implementation. This implementation can not to fit the xmin argument. if the ‘R. If NULL. so use the ‘plfit’ implementation if you want to do that. The lower bound for fitting the power-law. where x is a positive number and α is greater than 1. The additional arguments are passed to the mle function.law. for the ‘R. This argument makes it possible to fit only the tail of the distribution. start=2. it is generally assumed that P (X = x) is proportional to x−alpha .law.fit provides two maximum likelihood implementations.

224

power.law.fit The ‘plfit’ implementation also uses the maximum likelihood principle to determine α for a given xmin ; When xmin is not given in advance, the algorithm will attempt to find itsoptimal value for which the p-value of a Kolmogorov-Smirnov test between the fitted distribution and the original sample is the largest. The function uses the method of Clauset, Shalizi and Newman to calculate the parameters of the fitted distribution. See references below for the details.

Value Depends on the implementation argument. If it is ‘R.mle’, then an object with class ‘mle’. It can be used to calculate confidence intervals and log-likelihood. See mle-class for details. If implementation is ‘plfit’, then the result is a named list with entries: continuous alpha xmin Logical scalar, whether the fitted power-law distribution was continuous or discrete. Numeric scalar, the exponent of the fitted power-law distribution. Numeric scalar, the minimum value from which the power-law distribution was fitted. In other words, only the values larger than xmin were used from the input vector. Numeric scalar, the log-likelihood of the fitted parameters. Numeric scalar, the test statistic of a Kolmogorov-Smirnov test that compares the fitted distribution with the input vector. Smaller scores denote better fit. Numeric scalar, the p-value of the Kolmogorov-Smirnov test. Small p-values (less than 0.05) indicate that the test rejected the hypothesis that the original data could have been drawn from the fitted power-law distribution.

logLik KS.stat KS.p

Author(s) Tamas Nepusz <ntamas@gmail.com> and Gabor Csardi <csardi.gabor@gmail.com> References Power laws, Pareto distributions and Zipf’s law, M. E. J. Newman, Contemporary Physics, 46, 323-351, 2005. Aaron Clauset, Cosma R .Shalizi and Mark E.J. Newman: Power-law distributions in empirical data. SIAM Review 51(4):661-703, 2009. See Also mle Examples
# This should approximately yield the correct exponent 3 g <- barabasi.game(1 ) # increase this number to have a better estimate d <- degree(g, mode="in") fit1 <- power.law.fit(d+1, 1 ) fit2 <- power.law.fit(d+1, 1 , implementation="R.mle")

preference.game
fit1$alpha coef(fit2) fit1$logLik logLik(fit2)

225

preference.game

Trait-based random generation

Description Generation of random graphs based on different vertex types. Usage preference.game(nodes, types, type.dist=rep(1, types), fixed.sizes=FALSE, pref.matrix=matrix(1, types, types), directed=FALSE, loops=FALSE) asymmetric.preference.game(nodes, types, type.dist.matrix=matrix(1,types,types), pref.matrix = matrix(1, types, types), loops=FALSE) Arguments nodes types type.dist fixed.sizes The number of vertices in the graphs. The number of different vertex types. The distribution of the vertex types, a numeric vector of length ‘types’ containing non-negative numbers. The vector will be normed to obtain probabilities.

Fix the number of vertices with a given vertex type label. The type.dist argument gives the group sizes (i.e. number of vertices with the different labels) in this case. type.dist.matrix The joint distribution of the in- and out-vertex types. pref.matrix directed loops A square matrix giving the preferences of the vertex types. The matrix has ‘types’ rows and columns. Logical constant, whether to create a directed graph. Logical constant, whether self-loops are allowed in the graph.

Details Both models generate random graphs with given vertex types. For preference.game the probability that two vertices will be connected depends on their type and is given by the ‘pref.matrix’ argument. This matrix should be symmetric to make sense but this is not checked. The distribution of the different vertes types is given by the ‘type.dist’ vector. For asymmetric.preference.game each vertex has an in-type and an out-type and a directed graph is created. The probability that a directed edge is realized from a vertex with a given out-type to a vertex with a given in-type is given in the ‘pref.matrix’ argument, which can be asymmetric. The joint distribution for the in- and out-types is given in the ‘type.dist.matrix’ argument.

226 Value An igraph graph. Author(s)

print.igraph

Tamas Nepusz <ntamas@gmail.com> and Gabor Csardi <csardi.gabor@gmail.com> for the R interface See Also establishment.game. callaway.traits.game Examples
pf <- matrix( c(1, , , 1), nr=2) g <- preference.game(2 , 2, pref.matrix=pf) ## Not run: tkplot(g, layout=layout.fruchterman.reingold) pf <- matrix( c( , 1, , ), nr=2) g <- asymmetric.preference.game(2 , 2, pref.matrix=pf) ## Not run: tkplot(g, layout=layout.circle)

print.igraph

Print graphs to the terminal

Description These functions attempt to print a graph to the terminal in a human readable form. Usage ## S3 method for class ’igraph’ print(x, full=getIgraphOpt("print.full"), graph.attributes=getIgraphOpt("print.graph.attributes"), vertex.attributes=getIgraphOpt("print.vertex.attributes"), edge.attributes=getIgraphOpt("print.edge.attributes"), names=TRUE, ...) ## S3 method for class ’igraph’ summary(object, ...) ## S3 method for class ’igraph’ str(object, ...)

print.igraph Arguments x The graph to print.

227

full Logical scalar, whether to print the graph structure itself as well. graph.attributes Logical constant, whether to print graph attributes. vertex.attributes Logical constant, whether to print vertex attributes. edge.attributes Logical constant, whether to print edge attributes. names object ... Details summary.igraph prints the number of vertices, edges and whether the graph is directed. str.igraph prints the same information, and also lists the edges, and optionally graph, vertex and/or edge attributes. print.igraph behaves either as summary.igraph or str.igraph depending on the full argument. See also the ‘print.full’ igraph option and getIgraphOpt. The graph summary printed by summary.igraph (and print.igraph and str.igraph) consists one or more lines. The first line contains the basic properties of the graph, and the rest contains its attributes. Here is an example, a small star graph with weighed directed edges and named vertices: IGRAPH DNW- 1 9 -- In-star + attr: name (g/c), mode (g/c), center (g/n), name (v/c), weight (e/n) The first line always starts with IGRAPH, showing you that the object is an igraph graph. Then a four letter long code string is printed. The first letter distinguishes between directed (‘D’) and undirected (‘U’) graphs. The second letter is ‘N’ for named graphs, i.e. graphs with the name vertex attribute set. The third letter is ‘W’ for weighted graphs, i.e. graphs with the weight edge attribute set. The fourth letter is ‘B’ for bipartite graphs, i.e. for graphs with the type vertex attribute set. Then, after two dashes, the name of the graph is printed, if it has one, i.e. if the name graph attribute is set. From the second line, the attributes of the graph are listed, separated by a comma. After the attribute names, the kind of the attribute – graph, vertex or edge – is denoted, and the type of the attribute as well, character, numeric, or other (‘x’). As of igraph 0.4 str.igraph (and print.igraph) uses the max.print option, see options for details. Value All these functions return the graph invisibly. Logical constant, whether to print symbolic vertex names (ie. the name vertex attribute) or vertex ids. The graph of which the summary will be printed. Additional agruments.

228 Author(s) Gabor Csardi <csardi.gabor@gmail.com> Examples
g <- graph.ring(1 ) g summary(g)

read.graph

read.graph

Reading foreign file formats

Description The read.graph function is able to read graphs in various representations from a file, or from a http connection. Currently some simple formats are supported. Usage read.graph(file, format = c("edgelist", "pajek", "ncol", "lgl", "graphml", "dimacs", "graphdb", "gml", "dl"), ...) Arguments file format The connection to read from. This can be a local file, or a http or ftp connection. It can also be a character string with the file name or URI. Character constant giving the file format. Right now edgelist, pajek, graphml, gml, ncol, lgl, dimacs and graphdb are supported, the default is edgelist. As of igraph 0.4 this argument is case insensitive. Additional arguments, see below.

... Details

The read.graph function may have additional arguments depending on the file format (the format argument). See the details separately for each file format, below. Value A graph object. Edge list format This format is a simple text file with numeric vertex ids defining the edges. There is no need to have newline characters between the edges, a simple space will also do. Additional arguments: n The number of vertices in the graph. If it is smaller than or equal to the largest integer in the file, then it is ignored; so it is safe to set it to zero (the default). directed Logical scalar, whether to create a directed graph. The default value is TRUE.

The distance of the label from the vertex.) The rotation of the vertex (phi in Pajek). • Hypergraphs (graphs with non-binary edges) are not supported as igraph cannot handle them.1 igraph supports reading bipartite (two-mode) graphs from Pajek files and adds the type vertex attribute.fmf. labeldegree2 framewidth fontsize rotation radius diamondratio type description. eg. These igraph attributes are only created if there is at least one vertex in the Pajek file which has the corresponding associated information. see the Pajek manual on the Pajek homepage for some information about the file format. igraph implements only a subset of the Pajek format: • Only . A warning is given if invalid edges (edges connecting vertices of the same type) are present in the file.read. Eg.graph Pajek format 229 Pajek it a popular network analysis program for Windows.net files are supported.) It has a quite flexible but not very well documented file format. • Graphs containing both directed and undirected edges are not supported as igraph cannot represent them. Pajek attribute Vertex id The ‘x’. y.6. (lr in Pajek. • Time events networks are not supported.uni-lj. vertex types in bipartite (two-mode) graphs. if there are vertex coordinates for at least one vertex . yfact labeldist labeldegree. the file might contain edge weights as well. These are mainly parameters for graph visualization. Vertex color (ic in Pajek) if given with symbolic name Border color (bc in Pajek) if given with symbolic name Label color (lc in Pajek) if given with symbolic name The x_fact and y_fact Pajek attributes.si/pub/networks/pajek/. Vertex and edge attributes defined in the Pajek file will be also read and assigned to the graph object to be created. but not exclusively. The shape of the vertex when plotted.) The la and lphi Pajek attributes The width of the border (bw in Pajek). Poject files might be supported in a forthcoming igraph release if they turned out to be needed. From version 0. (See the Pajek homepage at http: //vlado. ‘y’ and ‘z’ coordinate of the vertex The size of the vertex when plotted (size in Pajek). Size of the label font (fos in Pajek. z vertexsize shape color framecolor labelcolor xfact. The following vertex attributes might be added: igraph name id x. For the diamond shape (q in Pajek). • Graph with multiple edge sets are not supported. Radius. for some vertex shapes (r in Pajek). Pajek project files (which can contain many graph and also other type of data) are not.

The following edge attributes might be added: igraph name weight label color color-red. By default the first graph is read (index 0). Bezier curve parameter. a1 and a2 in Pajek. s in Pajek. and can store graphs with an extensible set of vertex and edge attributes. • Nested graphs are not supported. Thus igraph supports only a subset of the GraphML language: • Hypergraphs are not supported. if the color is given with a symbolic name. GraphML file format GraphML is an XML-based file format (an XML application in the XML terminology) to describe graphs.org for more information about the GraphML format. angle2 velocity1. ap in Pajek. There are no additional arguments for this format. For those vertices for which the attribute is not defined. • Mixed graphs. velocity2 arrowpos labelpos labelangle. hook2 angle1. labelangle2 labeldegree fontsize arrowtype linepattern labelcolor description. w in Pajek. read. color-blue edgewidth arrowsize hook1. Pajek attribute Edge weights. la in Pajek. fos in Pajek.graphdrawing. this argument can be used to select the graph to read. h1 and h2 in Pajek. See the GraphML homepage at http://graphml. p in Pajek. a in Pajek.230 read. lp in Pajek. NaN is assigned. c in Pajek. and generalized graphs which igraph cannot handle. c in Pajek. lc in Pajek. Additional arguments: index If the GraphML file contains more than one graphs.graph then the ‘x’. ‘y’ and possibly also ‘z’ vertex attributes will be created. Bezier curve parameters. ie. Edge color if it was given in RGB notation. color-green. k1 and k2 in Pajek. lr and lphi in Pajek.graph() sets the graph directed if this is the default in the GraphML file. . It is a modern format. graphs with both directed and undirected edges are not supported. even if all the edges are in fact undirected. l in Pajek. Edge color.

uni-passau. whether to add the symbolic names as vertex attributes to the graph. DL file format The DL format is a simple textual file format used by the UCINET software. LGL cannot deal with files which contain multiple or loop edges. So if an attribute is an array or a record.htm for examples.e. analytictech. • There is no maximum keyword length. see http://www.read. the number can be negative and can be in scientific notation. Although all syntactically correct GML can be parsed. (The symbolic vertex names themselves cannot contain whitespace. and it is simply a symbolic weighted edge list.graph GML file format 231 GML is a simple textual format. • Character entities in strings are not interpreted. The resulting graph is always undirected. Note the specification does not mention whether the format is case sensitive or not.infosun. real or string. The default is to make the graph directed. this is however not checked here.de/Graphlet/GML/ for details. we implement only a subset of this format.com/networks/dataentry. This is case insensitive. • We allow inf (infinity) and nan (not a number) as a real number. ‘Larry’ and ‘larry’ are not the same. This is also true if only some values of the attribute are complex.fim.icmb. • There is no maximum line length. An edge is defined by two symbolic vertex names separated by whitespace. so nan. whether to create a directed graph. Here is a list of all the differences: • Only node and edge attributes are used. It is a simple text file with one edge per line. and only if they have a simple type: integer. Additional arguments: names Logical constant. See http://www. • Graph attributes except for node and edge are completely ignored. as igraph is happy with these. NCOL format This format is used by the Large Graph Layout program (http://bioinformatics.) They might followed by an optional number. i. . some attributes might be ignored. If there is no weight specified to an edge it is assumed to be zero. All formats mentioned here is supported by igraph. • Top level attributes except for Version and the first graph attribute are completely ignored. For igraph DL files are case sensitive. edu/lgl). There are not additional argument for this format.utexas. Additional arguments: directed Logical scalar. this will be the weight of the edge. Please contact us if you cannot live with these limitations of the GML parser. then it is ignored. NaN and NAN are equal. If TRUE the name of the vertex attribute will be ‘name’.

edge weights will added if they are present in the file. if they are not present in the file. From the LGL manual: “The second format is the LGL file format (. otherwise not. This is yet another graph file format that tries to be as stingy as possible with space. Exactly two node identification lines are expected (n). max or asn). yet keeping the edge file in a human readable (not binary) format.lgl file suffix). see the files at ftp://dimacs. more specifically the version for network flow problems. if they are not present in the file. DIMACS file format The DIMACS file format.edu/lgl).graph weights Character scalar. edge weights will not be added. ‘yes’. the number of vertices and number of edges in the graph. ‘auto’. edge weights will not be added. edge weights will added if they are present in the file. edge weights will be added. ‘yes’. There is one problem line (p) in the file. Possible values are and their meaning are: ‘no’. the first vertex of an edge is preceded with a pound sign ’\#’. whether to add the symbolic names as vertex attributes to the graph. LGL file format The lgl format is used by the Large Graph Layout visualization software (http://bioinformatics. the target vertex to the target graph attribute. The problem line has three fields separated by spaces: the problem type (min. The default is ‘auto’. Additional arguments: names Logical constant. The source vertex is assigned to the source. whether to create a directed graph. but in igraph it is not an error to have multiple and loop edges.232 read. Additional arguments: . weights Character scalar.edu/pub/netflow/general-info/ This is a line-oriented text file (ASCII) format.” LGL cannot handle loop and multiple edges or directed graphs. Then each vertex that shares an edge with that vertex is listed one per line on subsequent lines. the target vertex and the edge capacity. The first character of each line defines the type of the line. it must appear before any node and arc descriptor lines. The default is ‘auto’. Vertex ids are numbered from 1. Arc lines start with a and have three fields: the source vertex. edge weights will be added. The default is undirected. either s (=source) or t (=target). If the first character is c the line is a comment line and it is ignored.rutgers. The format itself is like the following: # vertex1name vertex2name [optionalWeight] vertex3name [optionalWeight] Here. directed Logical constant. ‘auto’. Possible values are and their meaning are: ‘no’. icmb. then all edges get zero weight. one for the target vertex. otherwise not. it can describe undirected optionally weighted graphs. These have two fields: the id of the vertex and the type of the vertex.utexas. The edge capacities are assigned to the capacity edge attribute. specifies whether edge weights should be added to the graph. one for the source. If TRUE the name of the vertex attribute will be ‘name’. then all edges get zero weight. specifies whether edge weights should be added to the graph.

for each node. By default a directed graph is created. Whether to create a directed graph. followed by a word for each edge.graphdb. "ratio")) Arguments graph ignore. used in the graph database for isomorphism testing (http://amalfi. Node numeration is 0-based. The file is composed of 16 bit words. Then. so the first node of the graph has index 0. Usage reciprocity(graph. GraphDB format This is a binary format. whether to ignore loop edges. See below. Author(s) Gabor Csardi <csardi. See also graph.dis.it/graph/ db/doc/graphdbat-2. Logical constant.graph reciprocity Reciprocity of graphs Description Calculates the reciprocity of a directed graph.html): The graphs are stored in a compact binary format.reciprocity 233 directed Logical scalar.it/graph/) From the graph database homepage (http://amalfi. the least significant byte of the word is stored first. . one graph per file. i. representing the destination node of the edge.loops mode The graph object.com> See Also write. mode = c("default". unina.unina.loops = TRUE. whether to create a directed graph. ignore. Only unlabelled graphs are implemented. which are represented using the so-called little-endian convention.dis. the file contains the list of edges coming out of the node itself. Additional attributes: directed Logical scalar.gabor@gmail.e. The list is represented by a word encoding its length.

st=FALSE. niter=5.6. error=TRUE. This measure is calculated if the mode argument is default. kernel. expected=FALSE. if we know that there is a (possibly non-mutual) connection between them.random. norm=FALSE. Usage evolver. cites=FALSE. In other words.d (graph.234 Details revolver The measure of reciprocity defines the proporsion of mutual connections. agebins=max(vcount(graph)/71 . 1 ). agebins=max(vcount(graph)/71 . where A · A is the elementwise product of matrix A and its transpose. (3) reciprocally connected. debug=matrix(ncol=2. sd=FALSE. nrow= )) revolver.d (nodes. expected=FALSE. in a directed graph. cites=FALSE. This measure is calculated if mode is ratio.e (graph.ade (graph. 1 ). cites=FALSE. sd=FALSE. 5/2 . another measure was implemented. The result is the size of group (3). debug=numeric()) revolver. nrow= )) revolver. outseq = NULL. outdist = NULL. debug=matrix(ncol=2.graph. niter=5. cats. Value A numeric scalar between zero and one. . cats. m = 1. directed=TRUE) reciprocity(g) revolver Measuring the driving force in evolving networks Description These functions assume a simple evolving network model and measure the functional form of a so-called attractiveness function governing the evolution of the network. norm=FALSE. (2) non-reciprocaly connected.ad (graph.com> Examples g <. sd=FALSE. (unordered) vertex pairs are classified into three groups: (1) notconnected. niter=5. norm=FALSE. expected=FALSE.gabor@gmail.game(2 . Prior to igraph version 0. error=TRUE. error=TRUE.com> and Gabor Csardi <csardi. Author(s) Tamas Nepusz <ntamas@gmail. Or in adjacency matrix notation: ij (A · A )ij . niter=5. defined as the probability of mutual connection between a vertex pair. directed = TRUE) revolver. divided by the sum of group sizes (2)+(3). It is most commonly defined as the probability that the opposite counterpart of a directed edge is also included in the graph.

l (graph.air (graph. 1 ). 1 ). cites=FALSE. error=TRUE.el (graph. error=TRUE.d (graph. kernel. expected=FALSE. expected=FALSE. 1 ). sd = FALSE. 1 ). vtime = V(graph)$time. cites = FALSE. debug = matrix(ncol = 2. cites=FALSE. error = TRUE. expected=FALSE. debug=numeric()) revolver. debug=matrix(ncol=2. sd=FALSE.ad (graph. agebins=max(vcount(graph)/71 . norm=FALSE. cats. sd=FALSE. error=TRUE. norm=FALSE. error=TRUE. kernel. debug=numeric()) revolver. expected=FALSE.revolver 235 sd=FALSE. expected=FALSE.d. 1 ). niter=5. window. niter=5. debug = matrix(ncol = 2. niter=5. nrow= )) revolver. 1 ). norm=FALSE. niter=5. sd=FALSE.il (graph. niter=5. debug=numeric()) revolver.p. expected=FALSE. sd = FALSE. norm=FALSE.adi (graph. expected = FALSE. cats. sd=FALSE.ade (graph. niter=5. agebins=max(vcount(graph)/71 . error=TRUE. norm = FALSE. norm=FALSE. "events").ar (graph. error=TRUE. sd=FALSE. vtime = V(graph)$time. window. cats. norm=FALSE. error=TRUE. cites=FALSE. niter = 5.r (graph.adi (graph. cites=FALSE. nrow= )) revolver. niter=5. norm=FALSE. cites=FALSE. cats. sd=FALSE. error=TRUE.ir (graph.p (graph. expected=FALSE.di (graph. cats. 1 ). cites=FALSE. window) . norm=FALSE.graph. norm=FALSE. norm=FALSE. etime = E(graph)$time. expected=FALSE. agebins=max(vcount(graph)/71 .error. sd=FALSE. cats) revolver. norm=FALSE. agebins=max(vcount(graph)/71 . expected = FALSE. agebins=max(vcount(graph)/71 . window. nrow = )) revolver. debug=numeric()) revolver. cites=FALSE. nrow = )) revolver. niter = 5. agebins=max(vcount(graph)/71 . error=TRUE. cites=FALSE. events = get.ar (graph. sd=FALSE. error = TRUE. debug=numeric()) revolver. cites=FALSE. cites=FALSE. kernel) revolver. error=TRUE.error. sd=FALSE. niter=5. cites = FALSE.error. niter=5. debug=matrix(ncol=2. nrow= )) revolver.attribute(graph. debug=numeric()) revolver. kernel) revolver.air (graph. debug=numeric()) revolver. sd=FALSE.de (graph. expected=FALSE. window. norm=FALSE. norm = FALSE. niter=5.dl (graph. debug=numeric()) revolver. niter=5. expected=FALSE. agebins=max(vcount(graph)/71 . etime = E(graph)$time. cites=FALSE.error. sd=FALSE. kernel. debug=matrix(ncol=2.d (graph.error. expected=FALSE. error=TRUE. cats. cats. error=TRUE. cats) revolver. cats. cites=FALSE. expected=FALSE.error. kernel. window) revolver. debug=numeric()) revolver.

parscale. alpha.8.ADE.error.ade (graph.l (graph. filter = NULL) revolver.alpha (graph. abstol = 1e. agebins = 3 . abstol = 1e.a.dpareto (graph. alpha.ml. alpha.de (graph. reltol = 1e. a. parbeta.ml. maxit = 1 .ADE. filter = NULL) revolver. beta. kernel) revolver.dpareto (graph.ADE.r (graph.ml. kernel. parbeta.8. cats. alpha. kernel.a.error. parscale. parscale.beta (graph.probs. kernel. abstol = 1e.probs.8.ml. a. agebins = 3 . cats. window) revolver. cats) revolver. maxit = 1 . parbeta. cats. delta = 1e-1 ) revolver.alpha. ntk = FALSE) revolver. delta = 1e-1 ) revolver. reltol = 1e.ml.ml. cats) revolver. cats. cats. filter = NULL) revolver.ad (graph.8. reltol = 1e.evalf (graph. alpha. agebins = 3 .eval (graph. maxit = 1 .error. gcats. filter = NULL) revolver.di (graph.l (graph.error. maxit = 1 .8.beta (graph. cats) revolver. parbeta. a.236 revolver. kernel. paralpha.8.ml. a.8.dpareto. kernel. abstol = 1e. filter = NULL) revolver.AD.d (graph. filter = NULL) revolver. cats. niter.D.f (graph.e (graph.il (graph.el (graph. delta = 1e-1 ) revolver revolver. ntk = FALSE) revolver. delta = 1e-1 . paralpha. a.alpha. alpha. cats) revolver. reltol = 1e. agebins. maxit = 1 . kernel. cats) revolver. filter = NULL) revolver. coeffs.ir (graph. paralpha. delta = 1e-1 . kernel.a (graph. kernel. a.ml. coeffs. kernel. alpha. agebins = 3 . coeffs.d (graph.AD. par. kernel. agebins) . niter.8.8. kernel) revolver.8. beta.eval (graph.ml.dpareto.error. alpha. agebins = 3 .probs.alpha.error. window) revolver. niter.df (graph.ml. abstol = 1e.alpha. filter = NULL) revolver.error. par.ADE. filter = NULL) revolver. a.ml. agebins = 3 .DE.de (graph.AD. filter = NULL) revolver.ml.probs.ml. filter = NULL) revolver.de (graph. paralpha. filter = NULL) revolver. niter.error.8. a. maxit = 1 .8. filter = NULL) revolver. parscale. agebins = 3 . niter.dpareto.ml. reltol = 1e.8. maxit = 1 .ade (graph.a (graph.8. cats. cats) revolver. abstol = 1e. delta = 1e-1 . abstol = 1e. coeffs. kernel.ml. cats.ml. cats. alpha.probs.error.dpareto (graph.D. reltol = 1e.dl (graph. agebins = 3 . niter. cats) revolver.ADE. reltol = 1e.

The width of the time window to use. Real scalar. the time steps when the vertices where added to the network. Only vertices corresponding to TRUE entries are used in the fitting. whether to create a directed graph. measured in number of vertices. Logical scalar. The number of bins for vertex age. Logical scalar. Real scalar. Real scalar. Currently not used. A list of numeric vectors. Starting value for the ‘parscale’ (Pareto scale) parameter. whether to return the number of citations to the different vertex types. starting value for the ‘beta’ parameter. the maximum number of iterations. whether to return the expected number of citations for the different vertex types. Logical scalar. whether to return the standard deviation of the estimates. depending on the number of model parameters. Real scalar. Logical vector. Numeric scalar. Starting value for the ‘a’ parameter. Logical scalar. the time steps when the edges where added to the network. or NULL if all vertices have the same out-degree. absolute tolerance for the ML fitting. Starting value for the ‘alpha’ parameter. length is the number of vertices. Logical scalar. The input graph. the error margin that is allowed for the convergence. Starting value for the ‘parbeta’ (Pareto beta) parameter. Starting value for the ‘paralpha’ (Pareto alpha) parameter. matrix or array. The number of categories to use. whether to return the error of the fit. a vector. This argument is ignored if the outseq argument is not NULL.revolver Arguments nodes kernel outseq outdist m directed graph niter sd norm cites expected error debug agebins cats window vtime etime events delta filter alpha a paralpha parbeta parscale abstol reltol maxit beta The number of vertices in the generated network. Numeric vector. or NULL if no out-degree sequence is used. Numeric vector. The out-degree distribution. 237 The kernel function. each vector represents an event. the out-degree of the verticec. Logical scalar. The out-degree sequence. Numeric scalar. with the participation of the listed vertices. . whether to return the normalizing factors. relative tolerance for the ML fitting. It is ignored if at least one of outseq and outdist is not NULL. The number of iterations to perform.

Sorry. starting values for the coefficients. niter = 1 ) Arguments graph mode The graph to be rewired. "loops"). whether to return the S(t) values.b) and (c. in a matrix. Author(s) Gabor Csardi <csardi.com> rewire Graph rewiring Description Randomly rewires a graph while preserving the degree distribution. Numeric vector. Value A new graph object.d)) and substitutes them with (a. . Usage rewire(graph. It can be one of the following: simple: simple rewiring algorithm which chooses two arbitrary edges in each step (namely (a. the vertex types. avoiding the creation or destruction of loop edges or loops: similar to simple but allows the creation and destruction of loop edges. mode = c("simple". Number of rewiring trials to perform. so no detailed documentation yet. niter Details This function generates a new graph based on the original one by randomly rewiring edges while preserving the original graph’s degree distribution. whether to return the Ntk values. The rewiring algorithm to be used. rewire The functions should be considered as experimental. Logical scalar.238 coeffs par ntk gcats st Details Numeric vector. Logical scalar. Value A named list. Pareto parameters for the different vertex types.b) if they don’t yet exist.d) and (c.gabor@gmail.

loops=FALSE. prob. Value A new graph object. whether multiple edges are allowed int the generated graph.edges Author(s) Tamas Nepusz <ntamas@gmail.edges(graph.com> The input graph The rewiring probability.ring(2 ) g2 <. .gabor@gmail. Logical scalar. niter=3) 239 rewire.com> and Gabor Csardi <csardi.game Examples g <. Author(s) Gabor Csardi <csardi. multiple=FALSE) Arguments graph prob loops multiple Details Note that this function might create graphs with multiple and/or loop edges.rewire(g. Usage rewire. whether loop edges are allowed in the rewired graph. a real number between zero and one.com> See Also degree.graph.gabor@gmail.edges Rewires the endpoints of the edges of a graph randomly Description This function rewires the endpoints of the edges with a constant probability uniformly randomly to a new vertex in a graph. Logical scalar.rewire.sequence.

rewire. layout=coords) ## End(Not run) The graph to plot.240 Examples # Some random shortcuts shorten the distances on a lattice g <. etc. prob= .plotting. nei=5 ) average.) Arguments x . dim=1.fruchterman. Value NULL.path.lattice( length=1 . dim=3) rglplot(g.. tkplot for interactive graph drawing in 2D.reingold(g. .graph. Author(s) Gabor Csardi <csardi.length(g) g <.edges( g.com> See Also igraph. Details Note that rglplot is considered to be highly experimental. but the coordinates of the vertices is fixed. plot. Examples ## Not run: g <. It is not very useful either.plotting for the possible arguments. see igraph.gabor@gmail.5. Additional arguments.layout.length(g) rglplot rglplot 3D plotting of graphs with OpenGL Description Using the rgl package.5) ) coords <. Usage rglplot(x. See igraph. 5 ) average.path... shifted..plotting for the details . invisibly. The plot can be zoomed. rglplot plots a graph in 3D. rotated.graph.lattice( c(5.igraph for the 2D version.

binwidth) Arguments v binwidth The numeric vector. smaller than the length of v.running. Details The running mean of v is a w vector of length length(v)-binwidth+1.mean(1:1 . the size of the bin. should be meaningful.com> Examples running. ie. The first element of w id the average of the first binwidth elements of v. Numeric constant.mean(v. the second element of w is the average of elements 2:(binwidth+1).mean Running mean of a time series Description running. Value A numeric vector of length length(v)-binwidth+1 Author(s) Gabor Csardi <csardi.gabor@gmail.mean calculates the running mean in a vector with the given bin width. etc. 1 ) scg All-in-one Function for the SCG of Matrices and Graphs Description This function handles all the steps involved in the Spectral Coarse Graining (SCG) of some matrices and graphs as described in the reference below. . Usage running.mean 241 running.

A probability vector of length nrow(X) (or vcount(X)). direction = c("default". nt contains the number of groups used to partition each eigenvector separately. "right"). A vector of positive integers of length one or equal to length(ev). resp. "exact_scg"). A numeric matrix of (eigen)vectors to be preserved by the coarse graining (the vectors are to be stored column-wise in evec). When algo is equal to “interv\_km” or “interv”. Character scalar. algo = c("optimum". semproj = FALSE. When set to “right”. "left". matrix or Matrix. left eigenvectors.arpack . When algo = “exact\_cg” this parameter is ignored. This parameter is ignored in all other cases. "graph"). nt groups mtype algo norm direction evec p use. Either “row” or “col”. 2 the one with second largest algebraic value. p is the stationary probability distribution of a Markov chain when mtype = “stochastic”. "stochastic"). A vector of nrow(X) or vcount(X) integers labeling each group vertex in the partition. "col"). "interv". epairs = FALSE. This argument is currently not implemented. “interv\_km”.prob = FALSE) Arguments X ev scg The input graph or square matrix. use. A vector of positive integers giving the indexes of the eigenpairs to be preserved. sparse = getIgraphOpt("sparsematrices"). nt contains the number of intervals used to partition each eigenvector. the parameters ev and evec refer to right. etc. Possible values are “optimum”. The type of semi-projector to be used for the SCG. Can be of class igraph. When algo = “optimum”. p = NULL. If this parameter is supplied most part of the function is bypassed. Character scalar. Logical scalar. “laplacian” and “stochastic” are available. nt. Character scalar. The same partition size or number of intervals is used for each eigenvector if nt is a single integer. resp. and right eigenvectors are always used. "interv_km". evec = NULL. This parameter should be set to TRUE if one deals with large (over a few thousands) AND sparse graphs or matrices. The algorithm used to solve the SCG problem. stat. otherwise it is the columns. “left”. mtype = c("symmetric". “interv” and “exact\_scg”. output = c("default".242 Usage scg(X. If set to “row” the rows of the Laplacian matrix sum up to zero and the rows of the stochastic matrix sum up to one. This argument is not implemented currently and LAPACK is used for solving the eigenproblems. norm = c("row". 1 designates the eigenvalue with largest algebraic value. For now “symmetric”. ev. Character scalar. When set to TRUE uses the function arpack to compute eigenpairs. the eigenvectors should correspond to the indexes in ev as no cross-check will be done. If supplied. groups = NULL. maxiter = 3 . it is the magnitude that matters. For real eigenpairs. "matrix".arpack = FALSE. In the complex case. "laplacian". When passed “default” it is the SCG described in the reference below that is applied (common usage).

the final grouping is worked out as follows: two vertices are grouped together in the final partition if they are grouped together in each minimizing partition. the algorithm “exact\_scg” groups the vertices with equal components in each eigenvector.prob Details Please see SCG for an introduction. It is O(m3 ) for the stochastic problem. The computed or supplied eigenvectors if epairs = The stationary probability vector if mtype = For other matrix types this is missing. When algo = “interv\_km”. Value Xt groups L R values vectors p The coarse-grained graph. V is calculated from X. the (Lloyd) k-means algorithm is run on each partition obtained by “interv” to improve accuracy. . if matrices are requested. This parameter is ignored in all other cases. The computed eigenvalues if epairs = TRUE. Whether to return sparse matrices in the result. The semi-projector L if semproj = TRUE. This is to collect the stationary probability p when dealing with stochastic matrices. Logical scalar. TRUE. The algorithm “optimum” solves exactly the SCG problem for each eigenvector in V.prob = TRUE. Logical scalar. stochastic and stat. In general the size of the final partition is not known in advance when ncol(V)>1. The running time of this algorithm is O(max nt · m2 ) for the symmetric and laplacian matrix problems (i. Logical scalar. Logical scalar.scg maxiter 243 A positive integer giving the maximum number of iterations for the k-means algorithm when algo = “interv\_km”. Once a minimizing partition (either exact or approximate) has been found for each eigenvector. that is nt[i] constant-size bins are used to partition V[. when mtype is “symmetric” or “laplacian”. The semi-projector R if semproj = TRUE. The last three algorithms essentially have linear running time and memory load.i]. if it is not given in the evec argument. A vector of nrow(X) or vcount(X) integers giving the group label of each object (vertex) in the partition. Set this parameter to “default” to retrieve a coarse-grained object of the same class as X. the memory usage is O(m2 ).e. Character scalar. possibly a sparse matrix. Here m is the number of rows in V. Set this to TRUE to collect the eigenpairs computed by scg. In all three cases. The algorithms “interv” and “interv\_km” solve approximately the SCG problem by performing a (for now) constant binning of the components of the eigenvectors. Set this parameter to TRUE to retrieve the semi-projectors of the SCG. In the following V is the matrix of eigenvectors for which the SCG is solved. sparse output semproj epairs stat. or matrix. Finally.

6. D.mortondelachapelle@swissquote.5 . vertex.scg(g. nt=interv.label=NA. Gfeller. 6. 1. c(1. vertex. Copy and paste them by hand to your R prompt if you want to run them.2)) plot(g.11.3.ch/david. Examples ## ## ## ## We are not running these examples any more. edge. http://people.morton@epfl.graph.kamada. 3.12. scgGrouping and scgSemiProjectors.full(5) %du% graph. vertex.2) cg <. Morton de Lachapelle.ch>. epairs=TRUE) ## are the eigenvalues well-preserved? .morton See Also SCG for an introduction.label = NA.ch> References D.scg(immuno.vcount(immuno) interv <. and P.2.vcount(cg$Xt) col <.full(5) g <. layout = layout) plot(cg$Xt.rainbow(nt) vsize <. vertex.full(5) %du% graph.add.size = 2 .kamada.25. edge.width = ewidth.2) op <.par(mfrow=c(1. mtype="laplacian". 1.kawai(g) nt <. algo="exact_scg") #plot the result layout <.edges(g. 2008.label = ewidth. layout = layout. ## Not run: # SCG of a toy network g <.color = col[cg$groups]. scgNormEps.layout. vertex. algo="interv".1 . De Los Rios. vertex.kawai) par(op) ## SCG of real-world network library(igraphdata) data(immuno) summary(immuno) n <. <david. 11)) cg <. Submitted to SIAM Journal on Matrix Analysis and Applications. because they take a long time (~2 seconds) to run and this is against the CRAN repository policy.round(E(cg$Xt)$weight.epfl.6.c(1 .color = col.size = 2 *vsize/max(vsize).table(cg$groups) ewidth <. Shrinking Matrices while Preserving their Eigenpairs with Application to the Spectral Coarse Graining of Graphs.244 Author(s) scg David Morton de Lachapelle <david. ev= n-(1:9).

"lambda_tilde_i") rownames(res) <."N-6". . groups. 2)$groups vsize <.kawai(gt) com.c("interv".color=col[com]."N-4". ev=n-c(1. vertex.kamada.laplacian(gt) evalt <. cg$values. vertex.label=NA) par(op) ## End(Not run) scgExtra SCG Extra Functions Description Some useful functions to perform general actions in Spectral Coarse Graining (SCG).2).2)) plot(immuno."N-7".2).eigen(Lt. norm = c("row". evalt) res <.color=col[com.scg(graph. vertex. "stochastic").cg <. only.cbind(interv. Usage scgNormEps(V.cg$Xt nt <. vertex.label=NA) plot(gt.auto(immuno) 245 plot(immuno.cg <.cg]. layout=layout."lambda_i".c("N-1".laplacian(gt). layout=layout.vector(table(cg$groups))) op <.values=TRUE)$values[nt-(1:9)] res <.cg. vertex.sqrt(as.graph.label=NA) ## display the coarse-grained graph gt <. "laplacian"."N-5". nt-c(1. vertex.vcount(gt) Lt <. vertex. mtype = c("symmetric". layout=layout.simplify(as.scgExtra gt <.vertex.5) colnames(res) <.undirected(gt)) layout."N-8".round(res.par(mfrow=c(1.size=3."N-2". "col")) Arguments V A numeric matrix of (eigen)vectors assumed normalized. nt=2)$groups rainbow(max(com)) <."N-3"."N-9") print(res) ## use com <col <layout SCG to get the communities scg(graph. The vectors are to be stored column-wise in V).layout.layout.laplacian(immuno). p = NULL.size=15*vsize/max(vsize). vertex.color=col[com].size=3.

p is the stationary probability distribution of a Markov chain when mtype = “stochastic”. Author(s) David Morton de Lachapelle <david. <david. Value normEps returns with a numeric vector whose ith component is vi − P vi (see Details). A probability vector of length nrow(V).rexp(2 ) km <.kmeans(v. De Los Rios.morton@epfl. Shrinking Matrices while Preserving their Eigenpairs with Application to the Spectral Coarse Graining of Graphs. otherwise it is the columns. Gfeller.epfl. For now “symmetric”.ch/david. This parameter is ignored otherwise. and P. Either “row” or “col”. norm Details scgNormEps computes vi − P vi . The type of semi-projector used for the SCG. D. http://people. Morton de Lachapelle.246 groups mtype p scgExtra A vector of nrow(V) integers labeling each group vertex in the partition. “laplacian” and “stochastic” are available. Submitted to SIAM Journal on Matrix Analysis and Applications.mortondelachapelle@swissquote. Examples v <. where vi is the ith eigenvector in V and P is the projector corresponding to the mtype argument.5) sum(km$withinss) scgNormEps(cbind(v).morton See Also SCG and scg. km$cluster)^2 . If set to “row” the rows of the Laplacian matrix sum to zero and the rows of the stochastic matrix sum to one.ch> References D. 2008.ch>.

It is O(m3 ) for the stochastic problem. the (Lloyd) k-means algorithm is run on each partition obtained by “interv” to improve accuracy. nt. "interv_km". nt contains the number of groups used to partition each eigenvector separately. mtype algo p maxiter Details The algorithm “optimum” solves exactly the SCG problem for each eigenvector in V. When algo is equal to “interv\_km” or “interv”.scgGrouping 247 scgGrouping SCG Problem Solver Description This function solves the Spectral Coarse Graining (SCG) problem. “laplacian” and “stochastic” are available. A probability vector of length equal to nrow(V).e. when mtype is “symmetric” or “laplacian”. that is nt[i] constant-size bins are used to partition V[. maxiter = 1 ) Arguments V nt A numeric matrix of (eigen)vectors to be preserved by the coarse graining (the vectors are to be stored column-wise in V). The running time of this algorithm is O(max nt · m2 ) for the symmetric and laplacian matrix problems (i. In all three cases. "stochastic"). mtype = c("symmetric". This parameter is ignored in all other cases. The type of semi-projectors used in the SCG. Usage scgGrouping(V. Possible values are “optimum”. A vector of positive integers of length one or equal to length(ev). or approximately but faster. nt contains the number of intervals used to partition each eigenvector. "interv".i]. When algo = “optimum”. The algorithms “interv” and “interv\_km” solve approximately the SCG problem by performing a (for now) constant binning of the components of the eigenvectors. The same partition size or number of intervals is used for each eigenvector if nt is a single integer. p is the stationary probability distribution of a Markov chain when mtype = “stochastic”. the memory usage is O(m2 ). When algo = “exact\_cg” this parameter is ignored. For now “symmetric”. The algorithm used to solve the SCG problem."exact_scg"). This parameter is ignored in all other cases. “interv\_km”. p = NULL. When algo = “interv\_km”. . algo = c("optimum". "laplacian". either exactly. A positive integer giving the maximum number of iterations of the k-means algorithm when algo = “interv\_km”. Here m is the number of rows in V. “interv” and “exact\_scg”.

col=col[gr]. scgNormEps Examples # M M V eigenvectors of a random symmetric matrix <. http://people. ylab="size") ## comparison with the grouping obtained by kmeans ## for a partition of same size gr. main="Group size". col=col.eigen(M. the final grouping is worked out as follows: two vertices are grouped together in the final partition if they are grouped together in each minimizing partition. Morton de Lachapelle. Shrinking Matrices while Preserving their Eigenpairs with Application to the Spectral Coarse Graining of Graphs.mortondelachapelle@swissquote. De Los Rios.3)) col <.2)) plot(V[.kmeans(V.1].scgGrouping(V. <david. nstart=1 op <. 2008.ch/david.c(1. In general the size of the final partition is not known in advance when ncol(V)>1.centers=max(gr).rainbow(max(gr)) plot(table(gr).2]. ylab = "2nd eigenvector") par(op) ## kmeans disregards the first eigenvector as it )$cluster . V[.(M + t(M))/2 <. xlab="group".par(mfrow=c(1. symmetric=TRUE)$vectors[. The last three algorithms essentially have linear running time and memory load. scg.max=1 .ch> References D.2]. Submitted to SIAM Journal on Matrix Analysis and Applications. 1 ^3. main = "K-means grouping".morton See Also SCG for a detailed introduction.2)] # displays size of the groups in the final partition gr <. main = "SCG grouping". iter. xlab = "1st eigenvector". col=col[gr. Gfeller. 1 ^3) <. D.morton@epfl. Value A vector of nrow(V) integers giving the group label of each object (vertex) in the partition. the algorithm “exact\_scg” groups the vertices with equal components in each eigenvector.1]. and P.matrix(rexp(1 ^6). ylab = "2nd eigenvector") plot(V[. nt=c(2.ch>.km <. xlab = "1st eigenvector".248 scgGrouping Once a minimizing partition (either exact or approximate) has been found for each eigenvector. Finally.km].epfl. V[. Author(s) David Morton de Lachapelle <david.

1 .true <. This parameter is ignored in all other cases. p = NULL. Logical scalar.scgSemiProjectors ## spreads a much smaller range of values than the second one ### comparing optimal and k-means solutions ### in the one-dimensional case. “laplacian” and “stochastic” are available. sparse = getIgraphOpt("sparsematrices")) Arguments groups mtype p A vector of nrow(X) or vcount(X) integers giving the group label of every vertex in the partition. For now “symmetric”. p is the stationary probability distribution of a Markov chain when mtype = “stochastic”. "col").rexp(2 . . |α | 1 |α | δαγ (j ) . A probability vector of length length(gr). "laplacian". 1 .kmeans(x. mtype = c("symmetric". whether to return sparse matrices.km) 249 scgSemiProjectors Semi-Projectors Description A function to compute the L and R semi-projectors for a given partition of the vertices.scgGrouping(cbind(x). norm = c("row". 2) gr. otherwise it is the columns. gr. If set to “row” the rows of the Laplacian matrix sum up to zero and the rows of the stochastic sum up to one. Usage scgSemiProjectors(groups. Let γ (j ) label the group of vertex j in a partition of all the vertices. The symmetric semi-projectors are defined as Lαj = Rαj = the (row) Laplacian semi-projectors as Lαj = 1 δαγ (j ) and Rαj = δαγ (j ) . Either “row” or “col”. The type of semi-projectors. x <. gr. norm sparse Details The three types of semi-projectors are defined as follows. "stochastic").km <.true) scgNormEps(cbind(x). 3 )$cluster scgNormEps(cbind(x). 1 ) gr.

ch> References D.lr$R) rowSums(Lt) The semi-projector L. scg. De Los Rios.lr$L %*% L %*% t(lr$R) ## or better lr$L %*% tcrossprod(L. http://people. Shrinking Matrices while Preserving their Eigenpairs with Application to the Spectral Coarse Graining of Graphs. scgNormEps. Gfeller.graph. Submitted to SIAM Journal on Matrix Analysis and Applications.ch/david. D.crossprod(lr$R) # same as t(lr$R) %*% lr$R #P is an orthogonal projector isSymmetric(P) sum( (P %*% P-P)^2 ) ## use L and R to coarse-grain the graph Laplacian lr <. mtype="laplacian") L <. L and R are defined in a symmetric way when norm = col.morton See Also SCG for a detailed introduction. The semi-projector R.ch>. k∈γ (j ) p1 (k ) scgSemiProjectors where p1 is the (left) eigenvector associated with the one-eigenvalue of the stochastic matrix.morton@epfl.epfl.barabasi. Value L R Author(s) David Morton de Lachapelle <david.edge.mortondelachapelle@swissquote.game(2 .scgSemiProjectors(memb) #In the symmetric case L = R tcrossprod(lr$R) # same as lr$R %*% t(lr$R) P <.community(g) memb <.250 and the (row) stochastic semi-projectors as Lαj = p1 (j ) and Rαj = δαγ (j )δαγ (j) . All these semi-projectors verify various properties described in the reference. and P. Morton de Lachapelle. scgGrouping Examples # compute the semi-projectors and projector for the partition # provided by a community detection method g <.scgSemiProjectors(memb.betweenness.laplacian(g) Lt <.membership(eb) lr <.5) eb <. . 2008. m=1. <david.

shortest. "in"). If out then the shortest paths from the vertex. directed=TRUE. "all". gives whether the shortest paths to or from the given vertices should be calculated for directed graphs. Possibly a numeric vector giving edge weights. "in").paths Shortest (directed or undirected) paths between vertices Description shortest. unconnected=TRUE) path.length. "epath".paths(graph. By default it includes all vertices. "out".shortest. then the attribute is used.paths(graph.length(graph.paths(graph. (This is not required for get. weights=NULL) average. v=V(graph). then Johnson’s algorithm is used. the vertices to which the shortest paths will be calculated. weights = NULL. to=V(graph). the vertices from which the shortest paths will be calculated. You can override igraph’s choice by explicitly giving this parameter.paths calculates one shortest path (the path itself. then an unweighted breadthfirst search is used.shortest. "in"). to=V(graph). mode = c("out". if in then to it will be considered. and not just its length) from or to the given vertex.paths every vertex must be included here at most once. "dijkstra".paths calculates the length of all the shortest paths from or to the vertices in the network. mode = c("out". Which algorithm to use for the calculation. then Dijkstra’s algorithm is used. mode = c("all". "both")) get. otherwise if all weights are positive. If this is NA then no weights are used (even if the graph has a weight attribute). from. Numeric vector.all. ie.hist (graph. algorithm = c("automatic". not directed paths are searched. If this is NULL and the graph has a weight edge attribute.shortest. directed = TRUE) Arguments graph v to The graph to work on. Usage shortest. This argument is ignored for undirected graphs. get. to = V(graph). Character constant. weights = NULL. then the corresponding undirected graph will be used. Otherwise the BellmanFord algorithm is used. "all". "bellman-ford". "unweighted". By default igraph tries to select the fastest suitable algorithm.shortest. "johnson")) get. Note that for shortest. If there are no weights.path. the default.paths. If there are negative weights and we do the calculation for more than 100 sources. output=c("vpath". If all. from. Numeric vector. Note that the igraph C core might still override your choice in mode weights algorithm .paths 251 shortest.

Note that right now this is not a vector of vertex ids. between the from vertex to the vertices given in to. More precisely. What to do if the graph is unconnected (not strongly connected if directed paths are considered). Character scalar. or geodesic between two pair of vertices is a path with the minimal number of vertices. if FALSE the length of the missing paths are counted having length vcount(graph). defines how to report the shortest paths. and Johnson’s algorithm (‘"johnson"’). . The latter only supports non-negative edge weights. this works for graphs with non-negative edge weights. from output Numeric constant.shortest.hist calculates a histogram. the Dijkstra algorithm (‘dijkstra’). “epath” means that the edges along the paths are reported. shortest. this argument is ignored for undirected graphs.paths calculates the lengths of pairwise shortest paths from a set of vertices (from) to another set of vertices (to).shortest. supply ‘automatic’ as the algorithm argument.length.252 shortest.paths calculates a single shortest path (i. by calculating the shortest paths between all pairs of vertices (both ways for directed graphs). one longer than the longest possible geodesic in the network.paths obvious cases. The latter only works if the edge weights are non-negative.shortest. regardless of this argument. then the unweighted algorithm will be used. the Bellman-Ford algorithm (‘bellman-ford’).paths calculates all shortest paths between pairs of vertices. The implemented algorithms are breadth-first search (‘unweighted’). The functions documented in this manual page all calculate shortest paths between vertex pairs. the path itself. not just its length) between the source vertex given in from.e.paths uses breadth-first search for unweighted graphs and Dijkstra’s algorithm for weighted graphs. i. This function does not consider edge weights currently and uses a breadth-first search.6. in a named list with components “vpath” and “epath”.) get. For directed graphs both directions are considered. so every pair of vertices appears twice in the histogram. igraph can choose automatically between algorithms. For automatic algorithm selection. get. to the target vertices given in to. Whether to consider directed paths in directed graphs. (This is also the default. “both” means that both forms are returned. path. and chooses the most efficient one that is appropriate for the supplied weights (if any).e. depending on the argorithm argument and the weight edge attribute of the graph.path. average. if there are no edge weights.all. but only a single vertex. get. directed unconnected Details The shortest path. the vertex from or to the shortest paths will be calculated. this form was used prior to igraph version 0.length calculates the average path length in a graph. If TRUE only the lengths of the existing paths are considered and averaged. but (naturally) only for graphs that don’t have a negative cycle. by calculating the shortest path length between each pair of vertices. “vpath” means that the vertices along the paths are reported. The latter two algorithms work with arbitrary edge weights. It uses different algorithms. this only works for unweighted graphs. It uses a breadth-first search for unweighted graphs and Dijkstra’s algorithm for weighted ones.

If there is no path between two vertices then a numeric vector of length zero is returned as the list element.1.1. 6.paths a numeric matrix with length(to) columns and length(v) rows. but the vectors in the list contain the edge ids along the shortest paths.1 .J. 4.9.2.shortest. in a named list with entries named as “vpath” and “epath”. then a list of length vcount(graph) is returned. path.graph. 3.6.paths(g) get. 5.3. byrow=TRUE.paths the return value depends on the output parameter. . 6. t(el[. 6.8.paths(g2. 2.shortest.2. 2.com> References West.3.length.2.paths Value 253 For shortest. 9. 4.4.empty(1 ).7. c(1.all. List element i contains the vertex ids on the path from vertex from to vertex i (or the other way for directed graphs depending on the mode argument).8. 5. weight=el[. 8.4) ) g2 <. The vector also contains from and i as the first and last elements.paths a list is returned.: Prentice Hall.hist returns a named list with two entries: res is a numeric vector.2. 1.1. Upper Saddle River. If output is “epath”.length a single number is returned. then a similar list is returned. mode="out") . 8. Introduction to Graph Theory.6. (1996).4.3. The sum of the two entries is always n(n − 1) for directed graphs and n(n − 1)/2 for undirected graphs.6.5.2. Author(s) Gabor Csardi <csardi. For unreachable vertices Inf is included.3. 1. For average. 6.shortest. the number of pairs for which the first vertex is not reachable from the second.7.matrix(nc=3.2.1. For get.2.B.edges(graph.shortest.add.1:2]).7. The shortest path length from a vertex to itself is always zero. unconnected is a numeric scalar. For get.1 . .5.all.paths(g. The shortest paths to the same vertex are collected into consecutive elements of the list.gabor@gmail. 6:8) average. 3. then both lists are returned. 3.1. instead of the vertex ids.1.path. N.paths(g. If from is the same as i then it is only included once. .shortest.1. 1. 5) get. the histogram of distances.length(g) ## Weighted shortest paths el <. Examples g <. If this is “vpath”. each list element contains a shortest path from from to a vertex in to. D. If output is “both”.path. 2.1.ring(1 ) shortest.3]) shortest.9.3.

jaccard calculates the pairwise Jaccard similarities for some (or all) of the vertices. Social Networks. since high-degree common neighbors are more likely to appear even by pure chance. The input graph. "out". "total")) Arguments graph vids mode loops Details The Jaccard similarity coefficient of two vertices is the number of common neighbors divided by the number of vertices that are neighbors of at least one of the two vertices being considered. Whether to include vertices themselves in the neighbor sets. "total"). The type of neighboring vertices to use for the calculation. loops = FALSE) similarity. 25(3):211-230. Self-similarities are not calculated. "out". mode = c("all". Value A length(vids) by length(vids) numeric matrix containing the similarity scores. similarity. "in". . similarity. vids = V(graph). "in". weighted by the inverse logarithm of their degrees. The vertex ids for which the similarity is calculated. mode = c("all". It is based on the assumption that two vertices should be considered more similar if they share a low-degree common neighbor. The inverse log-weighted similarity of two vertices is the number of their common neighbors. "total"). ‘all’.dice(graph. vids = V(graph). The Dice similarity coefficient of two vertices is twice the number of common neighbors divided by the sum of the degrees of the vertices. possible values: ‘out’. 2003. Adamic and Eytan Adar: Friends and neighbors on the Web. See the following paper for more details: Lada A. Isolated vertices will have zero similarity to any other vertex.dice calculates the pairwise Dice similarities for some (or all) of the vertices.jaccard(graph.invlogweighted(graph. "in". "out". vids = V(graph). Usage similarity. ‘in’. mode = c("all". loops = FALSE) similarity.254 similarity similarity Similarity measures of two vertices Description These functions calculates similarity scores for vertices based on their connection patterns.

graph.multiple=TRUE. Social Networks.loops remove. Adamic and Eytan Adar: Friends and neighbors on the Web.dice(g) similarity. if remove.attr.comb")) is.combination for details on this. In this case many edges might be mapped to a single one in the new graph.loops = TRUE. edge. Please see attribute.gabor@gmail.ring(5) similarity. 25(3):211230.simple(graph) Arguments graph remove.simplify Author(s) 255 Tamas Nepusz <ntamas@gmail. .comb Specifies what to do with edge attributes.com> and Gabor Csardi <csardi.comb = getIgraphOpt("edge. The graph to work on. See Also cocitation and bibcoupling Examples g <.attr.multiple Logical. edge.jaccard(g) simplify Simple graphs Description Simple graphs are graphs which do not contain loop and multiple edges.com> for the manual page.attr. whether the loop edges are to be removed. Usage simplify(graph. References Lada A. 2003.multiple = TRUE. remove. whether the multiple edges are to be removed. and their attributes are combined. remove. Logical.

g. representative of the original one.256 Details Spectral coarse graining A loop edge is an edge for which the two endpoints are the same vertex. is. Two edges are multiple edges if they have exactly the same two endpoints (for directed graphs order does matter).simple(simplify(g.multiple=FALSE)) is.3) ) is. A graph is simple is it does not contain loop edges and multiple edges.multiple.graph( c(1.vertices Examples g <.multiple are TRUE the function returns a simple graph.gabor@gmail.simple(simplify(g)) Spectral coarse graining Spectral Coarse Graining Description Functions to perform the Spectral Coarse Graining (SCG) of matrices and graphs.simple(simplify(g.simple(g) is.1.2.multiple and count.com> See Also is. thermodynamic properties of lattice models in statistical physics (e. that is features closely related with the eigenvalues and eigenvectors of a graph matrix (which for now can be the adjacency. Value A new graph object with the edges deleted. Author(s) Gabor Csardi <csardi. Common examples of such features comprise the first-passage-time of random walkers on Markovian graphs. SCG differs from traditional clustering schemes by producing a coarse-grained graph (not just a partition of the vertices). simplify removes the loop and/or multiple edges from a graph.loops and remove. Principal Component . the stochastic. delete. If both remove. delete. or the Laplacian matrix). Ising model). for reducing large graphs while preserving their spectral-related features.edges. As shown in [1]. is. called Spectral Coarse Graining (SCG). remove.loops=FALSE)) is.loop. Introduction The SCG functions provide a framework. remove.simple checks whether a graph is simple.3.2. and the epidemic threshold of epidemic network models (SIR and SIS models).

R ∈ Cn are such that LR∗ = In ˜ (R denotes the conjugate transpose of ∗ R). Under this constraint the SCG problem reduces to finding the partition of {1. this result can be generalized to eigenvectors [1]. ˜ ×n ∗ where n ˜ < n and L. For instance. |λ − λ where eP (v ) = v − P v . c3 : Pij ≥ 0. a block) in a partition of {1. . . and |α| is the number of elements in α. n} (labeling the original vertices) minimizing n ˜ eP (v ) 2 = α=1 i∈α [v (i) − (P v )(i)]2 .e. one can preserve to any desired level the original eigenvalue λ in the coarsegrained matrix M . the problem is to find a projector P solving P ∈Ω min eP (v ) . Choosing pertinent constraints to solve the SCG problem is of great importance in applications. where the matrix to be coarsegrained is the covariance matrix of some data set. . We have designed a particular constraint. . . which ensures that vertices belonging to the same group are merged consistently from a physical point of view (see [1] for details). called homogeneous mixing. Hence. . . SCG in brief The main idea of SCG is to operate on a matrix a shrinkage operation specifically designed to preserve some of the matrix eigenpairs while not altering other important matrix features (such as its structure). Under these assumptions.e. M v = λv ) and P is orthogonal. This leads to the following generic definition of a SCG problem. Given M ∈ Cn×n and (λ. as for instance is the case of dynamical processes on networks. If M is symmetric or stochastic. . this idea was expressed as follows. R so that M is symmetric or stochastic as well. where α denotes a group (i. etc). v ) is a (right) eigenpair of M (i. cr (e. in the absence of constraints the SCG problem is solved trivially by P = vv ∗ (v is assumed normalized). . Consider a (complex) n × n matrix M and form the product M = LM R∗ . where Ω is a set of projectors in Cn×n described by some ad hoc constraints c1 . n}. v ) a (right) eigenpair of M to be preserved by the coarse graining. Mathematically. .g. stochastic [3] and Laplacian [2] matrices. called exact SCG. . SCG should be of interest to practitioners of various fields dealing with problems where matrix eigenpairs play an important role. In short. for instance. then it may be desirable (or mandatory) to choose L. This structural constraint has led to the construction of particular semi-projectors for symmetric [1]. the coarse graining of matrices and graphs involves: . c1 : P ∈ Rn×n . it can be shown that P = R L is an n ˜ -rank projector and that. if P (or equivalently L. under extra assumptions on M . c2 : P = P t . that are made available.Spectral coarse graining 257 Analysis can be viewed as a particular SCG. if ˜ (λ. R) is chosen so as to make eP (v ) as small as possible. there exists an eigenvalue λ of M such that ˜ | ≤ const eP (v ) [1 + O( eP (v ) 2 )].

Laplacian and stochastic matrices are available). Retrieving a matrix or a graph matrix M from the problem. Computing the eigenpairs of M to be preserved in the coarse-grained graph or matrix.2 55 D. graph. (2) Work out some prescribed eigenpairs of M e. Gfeller. Functions for performing SCG The main function is the “all-in-one” scg.g. if needed. and P. Spectral Coarse Graining of Complex Networks. (4) Compute the semiprojectors L and R using scgSemiProjectors and from there the coarse-grained matrix M = LM R∗ . 5.epfl. and finally outputs a coarse-grained matrix or graph along with other useful information. 2008. De Los Rios. Shrinking Matrices while Preserving their Eigenpairs with Application to the Spectral Coarse Graining of Graphs. 2008. as in [1]).ch/david. Solving the constrained SCG problem. Gfeller. defining from M a coarse-grained graph. If necessary.mortondelachapelle@swissquote. following the method proposed in [1]). scg computes some prescribed eigenpairs of a matrix or a graph matrix (for now adjacency. 100(17). http://arxiv.morton D. De Los Rios.community Finding communities in graphs based on statistical meachanics Description This function tries to find communities in graphs via a spin-glass model and simulated annealing. spinglass. construct a coarse-grained graph from M (e. D.258 1. <david. 4. http://arxiv. De Los Rios. Spectral Coarse Graining and Synchronization in Oscillator Networks.g.community 2.g.adjacency. Morton de Lachapelle. Physical Review Letters. 2007. These steps can also be carried out independently: (1) Use get. 812 spinglass. Gfeller. In more details. that is finding P . Author(s) David Morton de Lachapelle <david. 3.morton@epfl. 6. (3) Invoke one the four algorithms of the function scgGrouping to get a partition that will preserve the eigenpairs in the coarse-grained matrix. by means of eigen or arpack. and P. . Computing from P two semi-projectors L and R (e.g. http://people. This function handles all the steps involved in the Spectral Coarse Graining (SCG) of some particular matrices and graphs as described above and in reference [1]. Working out the product M = LM R∗ and.org/abs/ 7 8.stochastic to compute a matrix M . Setting some problem-specific constraints (e. and P.ch>. Submitted to SIAM Journal on Matrix Analysis and Applications. dimension of the coarse-grained object). works out an optimal partition to preserve the eigenpairs. 99(3).laplacian or get.ch> References D. Physical Review Letters.org/abs/ 7 6.

Real constant.0 value makes existing and non-existing links equally important. This argument is ignored if the second form of the function is used (ie. Either a numeric vector or NULL. vertex spins parupdate start.spinglass. This argument is ignored if the second form of the function is used (ie.fact update. the stop temperature. Possible values: “simple” and “config”. start. whether to update the spins of the vertices in parallel (synchronously) or not.temp=1. greater values the missing links more important.community Usage spinglass. The faster original implementation is the default. Note that if this argument is present then some other arguments are ignored. that takes into account negative weights. “simple” uses a random graph with the same number of edges as the baseline probability and “config” uses a random graph with the same vertex degrees as the input graph. Integer constant.temp stop.rule gamma implementation Character scalar. can be chosen by supplying ‘neg’ here.fact= . It is not a problem to supply a (reasonably) big number here. This parameter can be used to calculate the community of a given vertex without calculating all communities. 259 The weights of the edges.rule=c("config". weights=NULL. but you don’t want to use it for community detection. The simulation terminates if the temperature lowers below this level. "neg"). . Smaller values make the existing links. the start temperature. 1.99. spins=25. Logical constant. implementation=c("orig". can be directed but the direction of the edges is neglected. Character constant giving the ‘null-model’ of the simulation.community(graph. Roughly. "random". gamma=1. in which case some spin states will be unpopulated. cool. "simple"). This specifies the balance between the importance of present and non-present edges in a community. The default 1. If NULL and no such attribute is present then the edges will have equal weights. update.temp= . If it is null and the input graph has a ‘weight’ edge attribute then that will be used. The other implementation. the gamma argument of the algorithm. Cooling factor for the simulated annealing. Currently igraph contains two implementations for the Spinglass community finding algorithm. Set this to NA if the graph was a ‘weight’ edge attribute. the ‘vertex’ argument is present). This argument is ignored if the second form of the function is used (ie. the number of spins to use. stop. a comunity is a set of vertices having many edges inside the community and few edges outside the community. the ‘vertex’ argument is present). Real constant.temp cool. vertex=NULL.minus=1) Arguments graph weights The input graph. Real constant. parupdate=FALSE. This is the upper limit for the number of communities. the ‘vertex’ argument is present). gamma. the ‘vertex’ argument is present). This argument is ignored if the second form of the function is used (ie.

This specifies the balance between the importance of present and non-present negative weighted edges in a community. then the regular community detection problem is solved (approximately).260 gamma.minus spinglass. A community is a set of nodes with many edges inside the community and few edges between outside it (i. by optimizing the an energy function.links outer. The adhesion score of the result.links Numeric vector giving the ids of the vertices in the same community as vertex.minus parameter of the algorithm. leads to communities with lesser negative intra-connectivity.community Real constant. This argument is ignored if the ‘orig’ implementation is chosen. see references. using the number of spins as the number of colors. i. The number of edges within the community of vertex. the first form is used then a spinglass. If the vertex argument is given and it is not NULL.fm>.gabor@gmail.community returns a communities object. the second form is used then a named list is returned with the following components: community cohesion adhesion inner. Smaller values of gamma. See also the examples below.cummunity function can solve two problems related to community detection.com> for the igraph glue code.e.) This idea is reversed for edges having a negative weight. then it must be a vertex id. The number of edges between the community of vertex and the rest of the graph. Note that only the ‘neg’ implementation supports negative edge weights. The cohesion score of the result.e. If the vertex argument is not given (or it is NULL). the gamma. If this argument is set to zero. Value If the vertex argument is not given. ie. partitioning the vertices into communities. Details This function tries to find communities in a graph. .uni-wuerzburg.minus. If the vertex argument is present.de> for the original code and Gabor Csardi <csardi. the algorithm reduces to a graph coloring algorithm. ie. Changes to the original function for including the possibility of negative ties were implemented by Vincent Traag <vtraag@f-m. see references. between the community itself and the rest of the graph. and the same energy function is used to find the community of the the given vertex. The spinglass. Author(s) Jorg Reichardt <lastname@physik. ie. few negative edges inside a community and many negative edges between communities.

Logical scalar. Phys. 026113 (2004) V. http://arxiv.org/abs/ 811.A.edges(g.edges fitness.game (no.out fitness. Newman and M. vertex=1) static. 74. 1)) spinglass.edges. whether to allow multiple edges in the graph. Rev. Logical scalar. otherwise an undirected one. fitness. If this argument is not NULL.fitness. E. Reichardt and S. this specifies the out-fitness of each vertex. Phys.2329 (2008).out. Girvan: Finding and evaluating community structure in networks.org/abs/cond-mat/ 6 3718 M. whether to allow loop edges in the graph. http://arxiv. 5/1 ) %du% erdos. c(1.add. A numeric vector containing the fitness of each vertex.static. For directed graphs.game(9.subgraph(g. J. fitness. then it should be a numeric vector and it specifies the in-fitness of each vertex.of. E 69. clusters Examples g <. subcomponent(g.erdos. 12)) g <.fitness. spins=2) spinglass. See Also communities. then a directed graph is generated. Traag and Jeroen Bruggeman: Community detection in networks with positive and negative links.game Random graphs from vertex fitness scores Description This function generates a non-growing random graph with edge probabilities proportional to node fitness scores.induced. Rev.community(g. multiple = FALSE) Arguments no. If not NULL. E. loops multiple .renyi.game(1 .fitness.in The number of edges in the generated graph. 5/9) g <.game References 261 J. If NULL (the default). Bornholdt: Statistical Mechanics of Community Detection. 016110 (2006). Usage static. loops = FALSE.of.renyi.community(g. the generated graph will be undirected.in.

This model is commonly used to generate static scale-free networks. i is selected according to the out-fitnesses and j is selected according to the in-fitnesses).1 g <. It can be shown that the expected degree of each vertex will be proportional to its fitness. otherwise we select a new pair. sample((1:5 )^-2. For undirected graphs.power. If you need to generate a graph with an exact degree sequence.law. Alternatively. although the actual.distribution(g) ## Not run: plot(degree.distribution(g. with probabilities proportional to their fitnesses. 2001.law. Kim D: Universal behaviour of load distribution in scale-free networks. Author(s) Tamas Nepusz <ntamas@gmail. each vertex has an out.power. We start from N disconnected nodes (where N is given by the length of the fitness vector). from vertex fitness scores Description This function generates a non-growing random graph with expected power-law degree distributions.game This game generates a directed or undirected random graph where the probability of an edge between vertices i and j depends on the fitness scores of the two vertices involved.law.fitness.sequence. The generation process goes as follows. Value An igraph graph. To achieve this. observed degree will not be. If the vertices are not connected yet (or if multiple edges are allowed). Then we randomly select two vertices i and j . consider degree. N.and an in-fitness. directed or undirected. we connect them. .com> References Goh K-I.game Scale-free random graphs. Examples N <. Phys Rev Lett 87(27):278701.game which generates the fitnesses for you with a given exponent. replace=TRUE)) degree.262 Details static. For directed graphs.power. (When the generated graph is directed. you may use static. and the probability of an edge from i to j depends on the out-fitness of vertex i and the in-fitness of vertex j .game instead. each vertex has a single fitness score. This is repeated until the desired number of links are created.game(5*N. log="xy") static.static. cumulative=TRUE). Kahng B. you have to draw the fitness scores from the desired power-law distribution.

of.out. see references below.law. you will get back an ErdosRenyi random network.and out-degrees in case of directed graphs.nodes. the power law exponent of the degree distribution. It must be greater than or equal to 2. If greater than or equal to 2.in loops multiple Logical scalar. The game simply uses static. where alpha = 1/(gamma − 1) and gamma is the exponent given in the arguments.game (no.edges..nodes no. finite. this argument specifies the exponent of the in-degree distribution. For directed graphs. To remove correlations between in.edges exponent.game with appropriately constructed fitness vectors. loops = FALSE. finite.law. Value An igraph graph.of.of. whether to allow loop edges in the generated graph.in = -1.size. whether to allow multiple edges in the generated graph. If non-negative but less than 2.fitness. For directed graphs. the generated graph will be undirected. The number of edges in the generated graph. whether to use the proposed finite size correction of Cho et al. If negative. multiple = FALSE. directed or undirected.fitness. Note that significant finite size effects may be observed for exponents smaller than 3 in the original formulation of the game.game is called.size. Numeric scalar.of. Details This game generates a directed or undirected random graph where the degrees of vertices follow power-law distributions with prescribed exponents.power.correction Logical scalar. this specifies the exponent of the out-degree distribution. exponent.out The number of vertices in the generated graph.game Usage static. exponent.static. the in-fitness vector will be shuffled after it has been set up and before static.correction = TRUE) Arguments no. In particular. Logical scalar. If you pass Inf here.com> . exponent. see the paper of Chung and Lu. the fitness of vertex i is i−alpha . 263 Numeric scalar. Author(s) Tamas Nepusz <ntamas@gmail. an error will be generated. This function provides an argument that lets you remove the finite size effects by assuming that the fitness of vertex i is (i + i0 − 1)−alpha where i0 is a constant chosen appropriately to ensure that the maximum degree is less than the square root of the number of edges times the average degree. no.power. the exponents of the inand out-degree distributions may be specified separately. and Cho et al for more details.

2. Park J.static. t)-cut is a set of edges. E ). t)-cut. The input graph. Phys Rev Lett 87(27):278701.power.distribution(g. source. Each vector is an (s. A list of numeric vectors containing vertex ids.3) ## Not run: plot(degree. the vertex set X and its complementer V − X . Examples g <.t)-cuts in a directed graph. Kim D: Percolation transitions in scale-free networks under the Achlioptas process. Each vertex set is a generator of the corresponding cut. Cho YS. s and t. Annals of Combinatorics 6.e.t)-cuts of a graph Description List all (s. The target vertex.264 References stCuts Goh K-I. Phys Rev Lett 103:135702. The source vertex. they correspond to the edge cuts. Usage stCuts(graph. an (s. 3 .game(1 . cumulative=TRUE. Kahng B. 125-145. target) Arguments graph source target Details Given a G directed graph and two. log="xy") stCuts List all (s. Kim JS. mode="out").law. Chung F and Lu L: Connected components in a random graph with given degree sequences. 2009. It must be directed. generates the cut that contains exactly the edges that go from X to V − X . different and non-ajacent vertices. 2. Kahng B. 2002. such that after removing these edges from G there is no directed path from s to t. in the graph G = (V. Kim D: Universal behaviour of load distribution in scale-free networks.2. Value A list with entries: cuts partition1s A list of numeric vectors containing edge ids. 2001. i. .

Numeric vector giving the edge capacities. Examples # A very simple graph g <. For forcing unit edge capacities.t)-cuts in graphs.gabor@gmail. Usage stMincuts(graph. capacity = NULL) Arguments graph source target capacity The input graph. a:b --+ t. supply NA here. If this is NULL and the graph has a weight edge attribute. Algorithmica 15. source="a". See Also stMincuts to list all minimum cuts. source="s".com> References 265 JS Provan and DR Shier: A Paradigm for listing (s. The id of the target vertex. t)-cuts of a directed graph. even for graphs that have a weight edge attribute. target="t") stMincuts List all minimum (s. target="e") # A somewhat more difficult graph g2 <. The id of the source vertex.graph.formula(a -+ b -+ c -+ d -+ e) stCuts(g. 1996. target. for given s and t. .stMincuts Author(s) Gabor Csardi <csardi. It must be directed.formula(s --+ a:b. then this attribute defines the edge capacities. a --+ 1:2:3. 351–372.graph. t)-cuts of a graph Description Listing all minimum (s. source. 1:2:3 --+ b) stCuts(g2.

Author(s) Gabor Csardi <csardi.gabor@gmail. an (s. in the graph G = (V. a --+ 1:2:3:4:5. See Also stCuts. An (s. such that after removing these edges from G there is no directed path from s to t. A list of numeric vectors containing edge ids. target="t") .266 Details stMincuts Given a G directed graph and two. t)-cut is a set of edges. different and non-ajacent vertices.separators Examples # A difficult graph. For unweighed (=equally weighted) graphs. t)cut. A list of numeric vectors containing vertex ids. the size of the minimum cut(s). t)-cut is defined as the sum of the capacities (or weights) in the cut. The size of an (s. the vertex set X and its complementer V − X . i. source="s". 1996. this is simply the number of edges.graph. Algorithmica 15.formula(s --+ a:b. 351–372. minimum.com> References JS Provan and DR Shier: A Paradigm for listing (s.t)-cuts in graphs. a:b --+ t. from the Provan-Shier paper g <. t)-cut is minimum if it is of the smallest possible size. 1:2:3:4:5 --+ b) stMincuts(g. they correspond to the edge cuts. Each vector is a minimum (s. generates the cut that contains exactly the edges that go from X to V − X .size.e. E ). Value A list with entries: value cuts partition1s Numeric scalar. s and t. Each vertex set is a generator of the corresponding cut.

directed gives whether the graph is directed or not. id) get. v2) get. test whether two vertices are connected by an edge. mode=c("all". vcount gives the number of vertices in the graph. v1. Usage vcount(graph) ecount(graph) neighbors(graph. The vertices connected by multiple edges are listed as many times as the number of connecting edges. v. ‘all’ ignores edge directions. The id of the first vertex. "total")) is. "in". A numeric edge id. v. mode = 1) incident(graph. the neighbors of a node. is. This argument is ignored for undirected graphs. specifying the type of adjacent vertices or incident edges to list in a directed graph. then only outgoing edges (or their corresponding vertices) are considered. neighbors gives the neighbors of a vertex. “in” considers incoming edges.connected(graph. It just gives its directed attribute. If “out”.edges(graph.edge(graph. Character string. An edge sequence. The id of the second vertex. The vertex of which the adjacent vertices or incident edges are queried. incident gives the incident edges of a vertex. ecount gives the number of edges in the graph.info 267 structure.structure. "out". es) Arguments graph v mode The graph. . For directed graphs only edges pointing from v1 to v2 are searched.directed(graph) are.info Gaining information about graph structure Description Functions for exploring the basic structure of a network: number of vertices and edges. v1 v2 id es Details These functions provide the basic structural information of a graph. For directed graphs only edges pointing from v1 to v2 are searched.

connected return boolean constants. 5) incident(g. for undirected graphs.com> See Also graph Examples g <.edges returns a matrix with the endpoints of the edges in the edge sequence argument. v) . 2) are. eids.edge returns the end points of the edge with the supplied edge id. subgraph get. neighbors returns an integer vector. For directed graph the source vertex comes first.gabor@gmail.subgraph(graph.connected decides whether there is an edge from v1 to v2.268 are.vertices = TRUE) subgraph(graph. impl=c("auto". delete. vids. is.edges(g.edges(graph.directed and are.edge returns a numeric vector of length two. Author(s) Gabor Csardi <csardi.graph. "create_from_scratch")) subgraph. get. the order is arbitrary. get. 1. Usage induced. get. 1:6) subgraph Subgraph of a graph Description subgraph creates a subgraph of a graph.connected(g. 5) are. 4) get.edges returns a two-column matrix. "copy_and_delete". 2. containing only the specified vertices and all the edges among them.connected(g.ring(1 ) vcount(g) ecount(g) neighbors(g. Value vcount and ecount return integer constants.

1:7) g3 <. ‘create_from_scratch’ searches for all vertices and edges that must be kept and then uses them to create the graph from scratch.subgraph(g.induced.ring(1 ) g2 <. 269 Numeric vector. This function will be renamed to subgraph in the next major version of igraph.graph currently (assuming ‘auto’ as the impl argument).graph. ‘copy_and_delete’ copies the graph first.subgraph.edges(g. but it is deprecated and will be removed in the next major version of igraph. the vertices of the original graph which will form the subgraph. Character scalar. The subgraph function does the same as induced.com> Examples g <. using heuristics based on the size of the original and the result graph.subgraph calculates the induced subgraph of a set of vertices in a graph. Author(s) Gabor Csardi <csardi.centrality Arguments graph vids. eids The edge ids of the edges that will be kept in the result graph. delete.v impl The original graph. 1:5. Value A new graph object. For this function one can specify the vertices and edges to keep.centrality Find subgraph centrality scores of network positions Description Subgraph centrality of a vertex measures the number of subgraphs a vertex participates in.subgraph.gabor@gmail. This means that exactly the specified vertices and all the edges between then will be kept in the result graph. .vertices Logical scalar. ‘auto’ chooses between the two implementations automatically. 1:5) subgraph.edges calculates the subgraph of a graph. subgraph. Details induced. whether to remove vertices that do not have any adjacent edges in eids. to choose between two implementation of the subgraph calculation. and then deletes the vertices and edges that are not included in the result graph. weighting them according to their size.

centrality(g) cor(degree(g). Details The subgraph centrality of a vertex is defined as the number of closed loops originating at the vertex.subgraph. 056103 (2005). Value A numeric vector. page.ba. it should be undirected. Author(s) Gabor Csardi <csardi. Boolean scalar.rank Examples g <. m=4. This effectively means that the measure can only be calculated for small graphs. but the implementation does not check this currently. diag=FALSE) Arguments graph diag subgraph.centrality (graph.centrality The input graph. Physical Review E 71. Rodriguez-Velazquez: Subgraph centrality in Complex Networks.gabor@gmail. Giving FALSE here effectively eliminates the loops edges from the graph before the calculation. the subgraph centrality scores of the vertices.com> based on the Matlab code by Ernesto Estrada References Ernesto Estrada. dir=FALSE) sc <. sc) .game(1 . See Also evcent. where longer loops are exponentially downweighted.270 Usage subgraph. Juan A. whether to include the diagonal of the adjacency matrix in the analysis. Currently the calculation is performed by explicitly calculating all eigenvalues and eigenvectors of the adjacency matrix of the graph.

Not all parameters of the plot can be changed interactively right now though. canvas. The GUI was written in Tcl/Tk..height=45 . width = NULL.id.screen(tkp.. the colors of vertices.) tkplot. Value Returns NULL. please see that for the details about how to use it.gabor@gmail.id) .width=45 . Usage tkplot(graph.) tkplot.id.off() tkplot. invisibly. .postscript(tkp. window. eg.export. Author(s) Gabor Csardi <csardi.id. newlayout.com> See Also tkplot for interactive plotting of graphs. tkplot Interactive plotting of graphs Description tkplot and its companion functions serve as an interactive graph drawing facility. height = NULL) tkplot.tkigraph 271 tkigraph Experimental basic igraph GUI Description This functions starts an experimental GUI to some igraph functions..close(tkp.to. edges. Usage tkigraph() Details tkigraph has its own online help system.fit.. so it is cross platform. canvas.reshape(tkp. . and also others have to be pre-defined.close = TRUE) tkplot.

tkplot tkplot is an interactive graph drawing facility. The height of the rectangle for generating new coordinates.272 tkplot. The ‘Select some vertices’ dialog allows to give an expression for the vertices to be selected: this can be a list of numeric R expessions separated by commas.id window.id. tkp. The width of the rectangle for generating new coordinates..to. if some of these are NULL the actual phisical width od height of the plot window is used.height The size of the tkplot drawing area.14.off closes all Tk plots. Details The id of the tkplot window to close/reshape/etc. . should we norm the coordinates. Additional plotting parameters. It’s handling should be quite straightforward most of the time.getcoords(tkp. In the color dialog a color name like ’orange’ or RGB notation can also be used.rotate(tkp. The new layout.canvas. norm = FALSE) tkplot.id. The degree to rotate the plot.id. see the layout parameter of tkplot. It is not very well developed at this stage. See igraph. canvas.screen fits the plot to the given rectange (width and height). One selection can be active at a time. Both operate on the current selection if the vertex/edge under the cursor is part of the selection and operate on the vertex/edge under the cursor if it is not. The other commands utilize this id to be able to query or manipulate the plot. activated by the right mouse button. degree = NULL. tkplot. like ‘1.plotting for the complete list. The tkplot command creates a new Tk window with the graphical representation of graph. There are different popup menus. Selections can be made also from the Select menu.width.close closes the Tk plot with id tkp.close width height newlayout norm degree rad . The degree to rotate the plot.center(tkp. the tkplot id. either a vertex or an edge selection. but it should be still useful. here are some remarks and hints. Leave this on the default value. in radian. Doing this again deselect the vertex/edge. Logical. The command returns an integer number. tkplot. tkplot. rad = NULL) Arguments graph The graph to plot. Similarly in the ‘Select some edges’ dialog two such lists can be given and all edges connecting a vertex in the first list to one in the second list will be selected.id) tkplot. for vertices and edges.2:1 ..15’ for example. A vertex/edge can be added to a selection by holding the control key while clicking on it with the left mouse button.fit.12.

screen. tkplot. tkplot.center and tkplot. layout Examples g <.fit.postscript creates a dialog window for saving the plot in postscript format. "in")) .reshape. tkplot.sort(graph.rotate return NULL invisibly. tkplot.reshape applies a new layout to the plot. Author(s) Gabor Csardi <csardi. tkplot. tkplot. this can be used to manipulate it from the command line. tkplot.par.export. tkplot. mode=c("out".com> See Also plot.to. Each row corresponds to one vertex. tkplot.postscript.center shifts the figure to the center of its plot window.export.topological.off. the id of the plot.rotate rotates the figure.gabor@gmail. Value tkplot returns an integer.getcoords returns the coordinates of the vertices in a matrix. "all".ring(1 ) ## Not run: tkplot(g) topological.igraph.sort Topological sorting of vertices in a graph Description A topological sorting of a directed acyclic graph is a linear ordering of its nodes where each node comes before all nodes to which it has edges. tkplot. its parameter can be given either in degrees or in radians.sort 273 tkplot.graph.getcoords returns a matrix with the coordinates. its optional parameters will be collected to a list analogous to layout.close. Usage topological. tkplot.

per.sort(g) ) traits Graph generation based on different vertex types Description These functions implement evolving network models based on different vertex types. type. types. Value A numeric vector containing vertex ids in topologically sorted order. types). types.game (nodes.step = 1.matrix = matrix(1. Usage callaway. should be directed traits Specifies how to use the direction of the edges.com> and Gabor Csardi <csardi. types). pref. types). Nodes with no outgoing edges go first. directed = FALSE) . so nodes with no incoming edges go first.game(1 topological.com> for the R interface Examples g <. and may have many. Author(s) Tamas Nepusz <ntamas@gmail. types. k = 1. This function returns a possible topological sort among them.traits.dist = rep(1. a partial topological sort is returned and a warning is issued. the sorting order ensures that each node comes before all nodes to which it has edges. If the graph is not acyclic (it has at least one cycle).gabor@gmail. type.matrix = matrix(1. types. types).274 Arguments graph mode The input graph. pref. For “in”. directed = FALSE) establishment.barabasi.dist = rep(1. it is quite the opposite: each node comes before all nodes from which it receives edges. Details Every DAG has at least one topological sort.game(nodes. edge. For “out”.

pref. nc=2)) g2 <. The number of trials per time step.matrix=matrix( c(1. . Value A new graph object.game(1 . pref. Then two vertices are selected uniformly randomly from the graph.matrix.step times in each time step.per. This is assumed to be stationary in time. numbers between zero and one. This new vertex tries to connect to k vertices in the graph. The number of edges to add to the graph per time step. These should be probabilities.step type.transitivity Arguments nodes types edge. nc=2)) transitivity Transitivity of a graph Description Transitivity measures the probability that the adjacent vertices of a vertex are connected.establishment.matrix=matrix( c(1.gabor@gmail. they like only themselves g1 <. .traits.callaway.1). The type of this vertex is generated based on type. Author(s) Gabor Csardi <csardi. For establishment.1).game(1 . 275 The distribution of the vertex types. This is sometimes also called the clustering coefficient. Logical constant. .matrix directed k Details The number of vertices in the graph. Then another two vertices are selected and this is repeated edges.traits.game the simulation goes like this: a single vertex is added at each time step. whether to generate directed graphs.com> Examples # two types of vertices. The probability that they will be connected depends on the types of these vertices and is taken from pref.matrix.dist pref.per. 2.dist. A matrix giving the preferences of the given vertex types.game the simulation goes like this: in each discrete time step a new vertex is added to the graph. For callaway. 2. k=2. The probability that such a connection is realized depends on the types of the vertices involved and is taken from pref. The number of different vertex types. see details below. . . ie.

barrat The weighted transitivity as defined A. and they are included in the averaging. then it is used automatically. "global". "globalundirected". type=c("undirected". globalundirected This is the same as global. For directed graph the direction of the edges is ignored. "localundirected". If it is ‘zero’. this is a local vertex-level quantity. if an average is calculated. weights=NULL. The type of the transitivity to calculate. localundirected This is the same as local. This is simply the ratio of the triangles and the connected triples in the graph. "weighted"). then we report 0 transitivity for them. See details below. "barrat". in this case all vertices are considered. For directed graph the direction of the edges is ignored. defines how to treat vertices with degree zero and one. this is calculated for each vertex given in the vids argument. weights isolates Details Note that there are essentially two classes of transitivity measures. undirected This is the same as global. vids The vertex ids for the local transitivity will be calculated. This will be ignored for global transitivity types. If it is NULL (the default) and the graph has a weight edge attribute. local The local transitivity of an undirected graph. one is a vertex-level. The local transitivity of a vertex is the ratio of the triangles connected to the vertex and the triples centered on the vertex. There are several generalizations of transitivity to weighted graphs. then the averaging will still result NaN. "localaverageundirected". Character scalar.h wij + wih aij aih ajh 2 . "local". Optional weights for weighted transitivity. It is ignored for other transitivity measures. isolates=c("NaN". here we use the definition by A. for the transitivity types that calculate an average. vids=NULL. The default value is NULL. Barrat. its formula is w Ci = 1 si (ki − 1) j. Possible values: transitivity global The global transitivity of an undirected graph (directed graphs are considered as undirected ones as well). the other a graph level property. weighted The same as barrat. If there are no vertices with degree two or higher. It is slightly faster to supply NULL here than V(graph). Barrat. If it is ‘NaN’ then they local transitivity is reported as NaN and they are not included in the averaging. "average". "localaverage". "zero")) Arguments graph type The graph to analyze.276 Usage transitivity(graph.

vids="A". Author(s) Gabor Csardi <csardi.renyi. Cambridge: Cambridge University Press.undirected with the collapse mode first.1 t1 <. type="weighted") all(is. S.transitivity(gw2. or NaN if there are no connected triples in the graph. Alessandro Vespignani: The architecture of complex weighted networks. This formula gives back the normal not-weighted local transitivity if all the edge weights are the same.game(1 . call as. 1 /1 ) E(gw2)$weight <. and Faust.. USA 101. Alain Barrat. Sci.erdos. Natl. the figure from the Barrat paper gw <. Marc Barthelemy. see graph.na(t1) == is. type="local") transitivity(gw. 3747 (2004) Examples g <. type="weighted") # Weighted reduces to "local" if weights are the same gw2 <.omit(t1 == t2)) .1 E(gw)[ V(gw)[name == "A"] %--% V(gw)[name == "E" ] ]$weight <. wij are the weights.formula(A-B:C:D:E. Value For ‘global’ a single number.graph. Social Network Analysis: Methods and Applications.gabor@gmail. C-D) E(gw)$weight <. vids="A". For ‘local’ a vector of transitivity scores. ki is the vertex degree. If you want to calculate it for a directed graph. K.game(1 . 1 /1 ) transitivity(g2) # this is about 1 /1 # Weighted version. one for each vertex in ‘vids’.strength. B-C:D.transitivity 277 si is the strength of vertex i. Proc. aij are elements of the adjacency matrix. (1994).renyi. Acad.na(t2)) all(na. The barrat type of transitivity does not work for graphs with multiple and/or loop edges.ring(1 ) transitivity(g) g2 <.graph.5 transitivity(gw. type="local") t2 <.erdos.com> References Wasserman. Romualdo Pastor-Satorras.transitivity(gw2.

A<->C. A<->C.census(graph) Arguments graph The input graph. the complete graph. the graph with a single directed edge. An undirected graph results a warning. the empty graph. A<->C. Details Triad census was defined by David and Leinhardt (see References below). 012 A->B. and undefined results.census Triad census. 021D A<-B->C. 201 A<->B<->C. A->C. A->C. 300 A<->B<->C. it should be directed. 102 A<->B.278 triad. 111U A<->B->C. the subgraph counts. 021U A->B<-C.motifs. A<->C. 030C A<-B<-C. in the order given in the above description.B.C. directed line. see graph. Usage triad. 120C A->B->C. . the graph with a mutual connection between two vertices.census triad. 120D A<-B->C. 111D A<->B<-C. the out-star. 030T A->B<-C. C. 120U A->B<-C. 210 A->B<->C. the in-star. Every triple of vertices (A. Value A numeric vector. B. C) are classified into the 16 possible states: 003 A. A<->C. 021C A->B->C. subgraphs with three vertices Description This function counts the different subgraphs of three vertices in a graph. This functions uses the RANDESU motif finder algorithm to find and count the subgraphs. C.

S. 45. "out". The Structure of Positive Interpersonal Relations in Small Groups. "total").census for classifying binary relationships. dir=TRUE) triad. roots Details A forest is a graph. Character string. mode = c("all". 218-251. “in” the incoming edges.). Berger (Ed.renyi. Volume 2. Typically it contains one vertex per component. (1972). it can be either directed or undirected. and Leinhardt. whose components are trees.erdos.gabor@gmail. The roots vector can be calculated by simply doing a topological sort in all components of the graph. roots) Arguments graph mode The input graph. A vector giving the vertices from which the breadth-first search is performed. type="gnm". "in".census(g) unfold. Sociological Theories in Progress. In J.unfold.tree Author(s) Gabor Csardi <csardi.motifs for the underlying implementation. See Also dyad.A. Usage unfold.tree(graph. defined the types of the paths used for the breadth-first search. Examples g <. “all” and “total” both of them.game(15. . This argument is ignored for undirected graphs. see the examples below. “out” follows the outgoing.com> References 279 See also Davis. J. graph. Boston: Houghton Mifflin.tree Convert a general graph into a forest Description Perform a breadth-first search on a graph and convert it into a tree or forest by replicating vertices that were found more than once.

See Details below. clip = igraph. coords.end. the plotting function. .’. params) Arguments shape clip plot parameters Character scalar. parameters = list()) igraph. If it is NULL for vertex. Other general plotting parameters should have a prefix ‘plot. Named list. Author(s) Gabor Csardi <csardi.el. end = c("both". "to")) igraph.sort(x)[1]+1 ] }) tree <.tree(1 ) V(g)$id <.’. roots=roots) Vertex shapes Various vertex shapes when plotting igraph graphs Description Starting from version 0.tree(g. then the names of all defined vertex shapes are returned.graph.com> Examples g <.gabor@gmail.shape.1 igraph supports different vertex shapes when plotting graphs. Vertex parameters should have a prefix ‘vertex.v See parameters of the clipping/plotting functions below. Usage vertex.graph(g). additional plot/vertex/edge parameters.noclip. An R function object.sapply(decompose.params. Vertex shapes A numeric vector.shape. edge parameters a prefix ‘edge. a tree or a forest.’. the clipping function.noplot. and the elements themselves define their default values. name of a vertex shape. An R function object.5. an igraph object.seq_len(vcount(g))-1 roots <.shapes.280 Value A list with two components: tree vertex_index The result.vertex.noplot (coords. v = NULL. el.shape. function(x) { V(x)$id[ topological.shapes (shape = NULL) add.unfold. "from".noclip (coords. it gives a mapping from the vertices of the new graph to the vertices of the old graph.shape. params. The element named define the new parameters.shape (shape. plot = igraph.

otherwise two. it contains the coordinates of the vertices for the edge list supplied in the el argument. igraph. el A matrix with two columns. The matrix contains the modified coordinates. If end is both then the matrix must have four columns. in the parameters argument. that does not plot anything. vertex. An example would be a generic regular polygon shape. The first argument of the function is “vertex”. It should have the same number of rows as coords. v The ids of the vertices to plot. It does no clipping. "size") end Character string. Possible values are “both”. or setting the shape argument to NULL. a matrix with two columns. the edges will be drawn exactly until the listed vertex position coordinates. params This is a function object that can be called to query vertex/edge/plot graphical parameters. If a shape name is given. It should match the number of rows in the coords argument. These functions are called “shape functions” in the rest of this manual page.Vertex shapes Details 281 In igraph a vertex shape is defined by two functions: 1) provides information about the size of the shape for clipping the edges and 2) plots the shape if requested. For this one must give the clipping and plotting functions of the new shape. it gives which end points will be used. The clipping function should return a matrix with the same number of rows as the el arguments. then the clipping and plotting functions of that shape are returned in a named list. The first one is the clipping function and the second is the plotting function.noclip is a very simple clipping function that the user can use in their own shape definitions. which can have a parameter for the number of sides. “edge” or “plot” to decide the type of the parameter. params("vertex".g. E. that the clipping and/or plotting functions can make use of. The plotting function has the following arguments: coords The coordinates of the vertices. see above.shapes can be used to list the names of all installed vertex shapes.shape. “both” selects both.shape. “from” and “to”. igraph.noplot is a very simple (and probably not very useful) plotting function. If “from” the function is expected to clip the first column in the el edge list. params The same as for the clipping function. by calling it without arguments. The return value of the plotting function is not used. . The clipping function has the following arguments: coords A matrix with four columns. “to” selects the second column. with the clipping applied. the second is a character string giving the name of the parameter. add. the edges of which some end points will be clipped. It is also possible to list the plot/vertex/edge parameters.shape can be used to add new vertex shapes to igraph.vertex.

shapes("circle")$clip. that might not be available shapes <.com> See Also igraph.color) != 1 && !is. y=coords[. bg=vertex. igraph.vertex.size).size[v] } symbols(x=coords[.color.shape="nil") ################################################################# # triangle vertex shape mytriangle <.size=15.shape("triangle". vertex. "color") if (length(vertex. vertex.vertex.vertex. vertex.pie.shape. It returns a named list with entries named ‘clip’ and ‘plot’.size. invisibly.graph. inches=FALSE) } # clips as a circle add.null(v)) { vertex.size. stars=cbind(vertex. plot nothing with no clipping add. add. minus "raster". vertex.1/2 * params("vertex". function(x) if (x=="pie") 2:6 else ). vertex.null(v)) { vertex.function(coords.label=shapes.color <.label. "size") if (length(vertex.vertex.size <.shape=shapes. vertex.size2=15. params) { vertex.shapes(). both of them R functions.shapes returns a character vector if the shape argument is NULL.noplot returns NULL. v=NULL. plot.seed(42) plot(g.282 Value Vertex shapes vertex.igraph Examples ################################################################# # all vertex shapes. vertex.shape("nil") plot(g.shape returns TRUE. "") g <.gabor@gmail. vertex.vertex. clip=vertex.dist=1.pie=lapply(shapes. Author(s) Gabor Csardi <csardi. vertex. invisibly.ring(length(shapes)) set.2]. igraph.color=list(heat.size <.color <. add=TRUE.params("vertex". plot=mytriangle) .noclip returns the appropriate columns of its coords argument.setdiff(vertex.color[v] } vertex.1].colors(5))) # add new vertex shape.shape.plotting. vertex.size) != 1 && !is.

nrow=1. params) { vertex.audioscrobbler. xmlValue) if (img != "") { con <.Vertex shapes plot(g. y. vertex. n=1 ^6) close(con) .function(artist) { cat("Downloading from last.color) != 1 && !is.size. vertex. stars=matrix(c(size.color. "norays") if (length(norays) != 1 && !is.function(coords. we start from an artist and # will query two levels. vertex.color=rainbow(vcount(g)). norays. vertex. v=NULL.size <.getinfo&artist=%s&api_key=1784468ada3f544faf9172ee8b99 getartist <. clip=igraph.com/2.null(v)) { norays <.null(v)) { vertex.xmlTreeParse(txt. vertex. "size") if (length(vertex.. . bg=bg.2 .size[v] } norays <.size=seq(1 .2 .fm. inches=FALSE) }) } # no clipping.color[v] } vertex. nor) { symbols(x=x.size=seq(1 .url(img.’http://ws.readBin(con. plot=mystar.2]. FUN=function(x.null(v)) { vertex.params("vertex".color=rainbow(vcount(g)). ncol=nor*2). vertex.. useInternal=TRUE) img <. vertex.fm.norays=5)) plot(g.shape="star".readLines(sprintf(url. bg.size/2).norays=rep(4:8. /?method=artist.length=vcount(g))) ################################################################# # generic star vertex shape.xpathSApply(xml. edges will be below the vertices anyway add.length=vcount(g)). vertex.shape. vertex.length=vcount(g))) plot(g.1]. We will use the XML. vertex. vertex.color <. open="rb") bin <. ") txt <. URLencode(artist))) xml <. 283 if (require(XML) && require(png) && require(jpeg)) { url <. size. add=TRUE.noclip.color=rainbow(vcount(g)).vertex. png and jpeg packages # for this. vertex.size <. length=vcount(g))) ################################################################# # Pictures as vertices.norays[v] } mapply(coords[. # Similar musicians from last.vertex. parameters=list(vertex.shape="triangle".1/2 * params("vertex".color <.shape="star".vertex.shape("star". coords[.params("vertex".2 . "color") if (length(vertex. what="raw".size=seq(1 . with a parameter for number of rays mystar <.size) != 1 && !is. y=y. "/lfm/artist/image[@size=’medium’][1]".

layout=layout. "/lfm/artist/similar/artist/name". vertex.2] %in% c(ego$name.lapply(similar. checks=TRUE) vertex. "image")) plot(musnet.simplify(graph.frame(name=c(ego$name.connectivity if (grepl("\.cohesion(graph. vertex.frame(edges. ego$similar)))) str(musnet) V(musnet)$raster <. Usage vertex.2. vertex.xpathSApply(xml.star.label. image=rast.edges3[ edges3[. source=NULL.lapply(ego$similar. ego$similar) & edges3[.\n") list(name=artist.connectivity(graph.paths(graph. xmlValue) cat("done.raster(numeric()) } sim <. source.call(rbind. this is recently also called group cohesion. ] musnet <. ego$similar).data.label=V(musnet)$name. img)) { rast <.c(list(ego$image). function(x) cbind(x$name.disjoint. vertex. img)) { rast <.dist=2.rbind(edges1.readJPEG(bin. edges2)) edges <.cbind(ego$name. do.label. lapply(similar. checks=TRUE) . Description The vertex connectivity of a graph or two vertices.284 vertex. native=TRUE) } else if (grepl("\. getartist) edges1 <. vertex.readPNG(bin. margin=. target=NULL.size2=5 . vertices=data.size=5 . dir=FALSE.as. ego$similar) edges2 <. "[[".raster(matrix()) } } else { rast <.getartist("Placebo") similar <.degree= ) } vertex. target) graph.connectivity Vertex connectivity.shape="raster".png$". native=TRUE) } else { rast <.1] %in% c(ego$name. x$similar)) edges3 <. similar=sim) } ego <. vertex.jpe?g$".as.

for vertex. In other words this is the minimum number of vertices needed to remove to make the graph not strongly connected.connectivity calculates this quantitty if neither the source nor target arguments are given. as they can be done quickly compared to the connectivity calculation itself. If the graph is not (strongly) connected then the connectivity is obviously zero.connectivity it can be NULL.connectivity Arguments graph source target checks The input graph.connectivity it can be NULL. The maximum number of vertex disjoint paths between two vertices is the same as their vertex connectivity in most cases (if the two vertices are not connected by an edge).connectivity calculates this quantity if both the source and target arguments are given and they’re not NULL.) vertex. see details below. more precisely vertex. The vertex connectivity of a graph is the minimum vertex connectivity of all (ordered) pairs of vertices in the graph. They were suggested by Peter McMahan. (Ie. (If the graph is not strongly connected then this is zero. 285 The id of the source vertex. Value A scalar real value. vertex. thanks Peter. Logical constant. Otherwise if the minimum degree is one then the vertex connectivity is also one.vertex. These three functions essentially calculate the same measure(s). It is a good idea to perform these checks. see references). Details The vertex connectivity of two vertices (source and target) in a directed graph is the minimum number of vertices needed to remove from the graph to eliminate all (directed) paths from source to target. Author(s) Gabor Csardi <csardi. the other two are included only for the ease of using more descriptive function names. This is calculated by graph. for vertex. The id of the target vertex. they are both NULL.com> References White. is the vertex connectivity of the graph. Whether to check that the graph is connected and also the degree of the vertices. The cohesion of a graph (as defined by White and Harary. see details below. The Cohesiveness of Blocks In Social Networks: Node Connectivity and Conditional Density. Sociological Methodology 31 (1) : 305-359.) A set of vertex disjoint directed paths from source to vertex is a set of directed paths between them whose vertices do not contain common vertices (apart from source and target).cohesion.gabor@gmail. . Douglas R and Frank Harary 2001.connectivity is the most general.

Logical scalar. 1) vertex. E(g)[ 1 %--% 1 ]) g2 <. 1 .barabasi.game(5 . The idea is that short random walks tend to stay in the same community.disjoint. weights = E(graph)$weight. m=5) g2 <. Logical scalar. The edge weights. Usage walktrap. whether to include the merge matrix in the result.maxflow.delete. graph. Details This function is the implementation of the Walktrap community finding algorithm.community(graph. whether to include the vector of the modularity scores in the result.edges(g.connectivity(g2. The length of the random walks to perform.org/abs/physics/0512106 . 1 .adhesion Examples g <.disjoint. also called communities in a graph via random walks. Matthieu Latapy: Computing communities in large networks using random walks. 5/5 ) g <. subcomponent(g.connectivity(g. http://arxiv.cohesion(g) walktrap. then it will be always calculated. merges = TRUE.as. m=1) g <.induced. edge directions are ignored in directed graphs.community Community strucure via short random walks Description This function tries to find densely connected subgraphs. whether to calculate the membership vector for the split corresponding to the highest modularity value.directed(g) g <. 1) vertex.game(1 .game(1 .renyi.paths.paths(g2. 1 . membership = TRUE) Arguments graph weights steps merges modularity membership The input graph. modularity = TRUE. 1)) graph.community graph. edge.erdos.286 See Also walktrap. edge.delete. Logical scalar.connectivity. 1) g <.edges(g2. E(g2)[ 1 %--% 1]) vertex.barabasi. If the membership argument is true.subgraph(g. see Pascal Pons. steps = 4.

Matthieu Latapy: Computing communities in large networks using random walks. p. Logical scalar.eigenvector. 1.full(5) %du% graph.6. leading.community returns a communities object. size. merge matrix. modularity and fastgreedy. etc. Logical scalar. whether multiple edges are allowed int the generated graph.gabor@gmail. Integer constant.edges(g.it> and Gabor Csardi <csardi. spinglass.community for other community detection methods.watts. .game The Watts-Strogatz small-world model Description Generate a graph according to the Watts-Strogatz network model.full(5) %du% graph.community.add.com> for the R and igraph interface References Pascal Pons. please see the communities manual page for details.graph. the rewiring probability. Author(s) Pascal Pons <google@for. Integer constant.strogatz.full(5) g <. 11)) walktrap. nei.game(dim. the neighborhood within which the vertices of the lattice will be connected. modularity score.community(g) watts. loops = FALSE.community. Real constant between zero and one. the size of the lattice along each dimension.strogatz. http://arxiv. 6.org/abs/physics/0512106 See Also See communities on getting the actual membership vector.betweenness.11.strogatz.game Value 287 walktrap. c(1.community. Examples g <. whether loops edges are allowed in the generated graph. multiple = FALSE) Arguments dim size nei p loops multiple Integer constant. edge. Usage watts. the dimension of the starting lattice.

type="average") .game(1. Nature 393. 5) write. however not many formats are implemented right now.graph First a lattice is created with the given dim. .watts. rewire. "pajek".edges Examples g <.graph Writing the graph to a file in some format Description write. "lgl". 440-442.length(g) transitivity(g. "ncol". You can use simplify to get rid of these. 5. Value A graph object.) . Note that this function might create graphs with loops and/or multiple edges..strogatz. format=c("edgelist". Usage write.lattice. See Also graph. size and nei arguments. average.288 Details write. "gml". Then the edges of the lattice are rewired uniformly randomly with probability p. Author(s) Gabor Csardi <csardi. "dimacs". 1998. "dot".graph(graph.. "graphml". 1 .com> References Duncan J Watts and Steven H Strogatz: Collective dynamics of ‘small world’ networks.graph is a general function for exporting graphs to foreign file formats.gabor@gmail.path. "leda"). file.

graph for details. A connection or a string giving the file name to write the graph to.. LGL format The lgl format is also a simple text file. Edge list format The edgelist format is a simple text file. GraphML format The GraphML format is a flexible XML based format.. Additional arguments: names If you want to write symbolic vertex names instead of vertex ids. lgl. Vertex and edge attributes are written to the file. see below. see read. This format has no additional arguments.graph Arguments graph file format The graph to export. As of igraph 0. See read. This format has no additional arguments.graph for GraphML details. Value A NULL. Right now pajek. isolates Logical. This format has no additional arguments. Supply NULL here if you want to omit the weights. By default the ‘name’ attribute is used if there is one. gml. format specific arguments. By defaults the vertex attribute ‘weights’ are used if they are installed. this is the format expected by the ’Large Graph Layout’ layout generator software. The file is sorted by the first and the second column. . they are omitted by default.write. Appropriate vertex and edge attributes are also written to the file. Pajek format The Pajek format is a text file. with one edge in a line. Vertex and edge attributes are also written to the file. graphml. There are no additional arguments for this format. See read. invisibly.4 this argument is case insensitive. if TRUE the isolate vertices are also written to the file. ncol and dimacs are implemented. dot. supply the name of the edge attribute here. 289 Character string giving the file format. edgelist. Supply NULL if you want to use numeric vertex ids even if there is a ‘name’ vertex attribute. weights If you want to write edge weights to the file. the two vertex ids separated by a space character. Other. supply the name of the vertex attribute containing the symbolic names here. Dot format The dot format is used by the popular GraphViz program.graph for details. .

the target vertex and the edge capacity. it is a text file.fim. capacity A numeric vector giving the edge capacities. it must appear before any node and arc descriptor lines. it might be neccessary to simplify the them before writing to the GML file. As igraph is more forgiving about attribute names. Dimacs format The dimacs file format. By default the ‘name’ attribute is used if there is one.edu/pub/netflow/general-info/ This is a line-oriented text file (ASCII) format. If NULL (the default) then it is taken from the capacity edge attribute. see http://www. see read. vertex and edges attributes are written to the file as well. weights If you want to write edge weights to the file.rutgers. the number of vertices and number of edges in the graph. if NULL (the default) then it is taken from the source graph attribute. target The id of the target vertex. igraph does not check this. if they are numeric of string. The “id” vertex attribute is treated specially. The graph. max or asn). The first character of each line defines the type of the line. supply the name of the edge attribute here. The following simple procedure is performed on each attribute name: first the alphanumeric characters are extracted. one for the target vertex. By defaults the vertex attribute ‘weights’ are used if they are installed. one for the source. These have two fields: the id of the vertex and the type of the vertex. If the id argument is not NULL then it should be a numeric vector with the vertex ids and the “id” vertex attribute is ignored (if there is one). either s (=source) or t (=target). Additional arguments: names If you want to write symbolic vertex names instead of vertex ids. The problem line has three fields separated by spaces: the problem type (min. more specifically the version for network flow problems. If the first character is c the line is a comment line and it is ignored. Additional arguments: source The id of the source vertex.uni-passau. If id is 0 .290 NCOL format write. There is one problem line (p in the file.de/Graphlet/ GML/ for details. Exactly two node identification lines are expected (n).infosun. Then if the first character is not a letter then the attribute name is prefixed with <quote>igraph</quote>. Supply NULL here if you want to omit the weights. This way we’ll have a syntactically correct GML file.graph for details. Vertex ids are numbered from 1. if NULL (the default) then it is taken from the target graph attribute.graph The ncol format is also used by LGL. GML file format GML is a quite general textual format. Supply NULL if you want to use numeric vertex ids even if there is a ‘name’ vertex attribute. see the files at ftp://dimacs. Note that this might result identical names for two attributes. the others are ignored. supply the name of the vertex attribute containing the symbolic names here. Arc lines start with a and have three fields: the source vertex.

graph. "/tmp/g.com> References Adai AT.html for the details of this format. If the graph has edge attributes named “source” or “target” they’re silently ignored. "edgelist") . Rename them before calling this function if you want to preserve them. 2004 Jun 25.graph 291 and there is a numeric id vertex attribute that is used instead. edge.txt". Marcotte EM. creator A character scalar to be added to the “Creator” line in the GML file. Wieland S. so we cannot write them to the file. igraph writes only the LEDA graph section which supports one selected vertex and edge attribute and no layout information or visual attributes. If this is NULL (the default) then the current date and time is added. algorithmic-solutions. See details above. GML uses these attributes to specify the edges.write.340(1):179-90. See Also read. Additional arguments: vertex. The support for the LEDA format is very basic at the moment. their uniqueness is not checked.info/leda_guide/graphs/leda_native_graph_fileformat. LEDA file format LEDA is a library for efficient data types and algorithms. Date SV. J Mol Biol.attr The name of the edge attribute whose values are to be stored in the output or NULL if no edge attribute has to be stored.ring(1 ) ## Not run: write. Additional arguments: id NULL or a numeric vector giving the vertex ids.graph(g.attr The name of the vertex attribute whose values are to be stored in the output or NULL if no vertex attribute has to be stored. Note that whichever way vertex ids are specified.gabor@gmail. LGL: creating a map of protein function with an algorithm for visualizing very large biological networks. See http://www. Author(s) Gabor Csardi <csardi.graph Examples g <. If ids are not specified in either way then the regular igraph vertex ids are used.

36 cliques.igraphHRG. 63 decompose.community. 74 dyad. 92 get.stochastic. 103 graph-operators-by-name. 114 graph. 15 as.game. 94 get. 21 autocurve. 249 ∗Topic datagen igraph. 29 bipartite. 68 dendPlot. 51 community.communities. 65 degree.constructors.bfs. 116 graph. 81 edge. 160 ∗Topic graphs aging. 55 compare.blocks. 40 clusters. 106 graph.coreness.components. 110 graph. 59 conversion. 129 . 58 contract. 64 292 degree.census.renyi.game.hull.membership. 112 graph.automorphisms. 32 canonical. 125 graph.incidence.permutation. 24 betweenness. 97 graph-motifs. 44 Combining attributes.directed. 109 graph.edges.mapping.igraph. 62 convex. 120 graph.game.game. 34 centralization. 96 graph-isomorphism.to. 121 graph.community.Index ∗Topic array scgSemiProjectors.density.projection. 48 communities. 43 cohesive.dfs.famous. 42 cocitation. 18 assortativity. 119 graph. 127 graph.adjacency. 66 dendPlot. 93 get. 10 arpack.full. 11 articulation.bipartite. 60 conversion between igraph and graphNEL graphs.prefatt.sample. 57 constraint.adjlist. 101 graph-operators. 67 dendPlot.points. 80 eccentricity.bipartite.connectivity.communities. 26 biconnected.vertices. 72 dominator.betweenness. 84 erdos. 28 bipartite. 7 alpha.frame. 95 girth. 73 Drawing graphs. 86 evcent.bruijn.sequence.ids. 87 fastgreedy. 123 graph. 23 barabasi.tree.fire. 82 edge. 31 bonpow.de. 19 attributes. 16 as.formula. 89 forest.edge.graph.data. 56 components.game. 117 graph.centrality.diversity. 90 get. 104 graph. 70 diameter. 39 closeness.

graph. 203 minimal. 174 is. 181 label.structure. 162 independent. 265 structure. 274 transitivity. 254 simplify.game. 256 spinglass.lcf.strogatz. 143 Graphs from adjacency lists. 183 layout.census. 169 is.mds.graph.drl.game. 207 modularity.maxflow. 161 igraphdemo.kautz. 208 multilevel. 271 tkplot.regular.game.community.INDEX graph. 278 unfold. 158 igraph.st. 202 maximum. 173 is. 132 graph.sets.vertex.search. 268 subgraph.centrality.sugiyama. 150 grg. 152 Hierarchical random graphs. 279 Vertex shapes. 192 layout. 137 graph. 288 ∗Topic manip running.grid. 258 static. 171 is. 245 scgGrouping.power.size.chordal.sort.paths.fitness.tree.vertices. 177 k. 130 graph. 221 power. 241 scgExtra.community. 228 reciprocity.mean.multiple.structure).cardinality. 193 layout.igraph. 239 rglplot.connectivity. 212 optimal.random. 172 is. 225 print.undocumented.rank.game. 249 shortest. 133 graph. 204 minimum. 164 interconnected. 234 rewire. 241 +. 264 stMincuts.community. 151 growing.community.spanning. 189 layout. 184 layout.law. 215 page. 286 watts. 233 revolver.info.propagation.tree. 275 triad. 267 subgraph. 194 layout.knn.named. 134 graph.igraph.igraph (graph.laplacian.dag.weighted. 217 permute.graph. 219 Pie charts as vertices.merge.degree. 205 minimum. 143 293 . 170 is. 209 neighborhood. 166 is. 176 iterators. 247 scgSemiProjectors. 271 topological.islands.separators. 284 walktrap.fit. 269 tkigraph. 168 is. 136 graph.separator. 226 read.eigenvector.edges.mutual. 251 similarity.law. 153 igraph console. 138 graph.community. 261 static. 163 infomap. 167 is. 273 traits.sequence.igraph. 142 graph. 240 scg. 287 write. 195 layout. 220 plot. 255 Spectral coarse graining.matching.game. 200 line.game.game. 196 leading. 210 nexus.star.graphdb.incidence. 157 igraph options.separators. 262 stCuts. 238 rewire. 223 preference. 140 graph.community.community. 180 kleinberg.strength. 280 vertex.

blocks). 39. 22. 91. 36 centralize. 90. 255 attribute. 67. 210.prefatt.igraph.game (traits).path.igraph. 165.vs (iterators). 40. 143 add. 43 biconnected. 21.directed. 18 as. 51 as. 261.structure). 161 clique.shape (Vertex shapes).igraph. 164 closeness. 51 assortativity.igraph. 161 citing. 7 aging. 50 authority. 218 bibcoupling.membership. 9.structure).game (igraph.igraph.vertex. 11. 44 cohesive.mapping.vs (iterators). 98–100. 34 are.eigenvector. 181 autocurve. 19 as. 87. 177 %->% (iterators). 287 community.type. 202 as. 16 asPhylo (communities).vertices (graph. 48 attributes. 225 INDEX attribute. 200 community. 44 bonpow. 23. 184. 261 cocitation.blocks.dendrogram.game (aging.prefatt. 177 $<-.preference. 177 $<-. 277 as. 28 bipartite. 88.number (cliques). 44 cohesiveBlocks (cohesive. 183. 12.igraph. 83. 58. 48 communities.membership (leading. 24. 255 code.undirected.type.game.length (communities). 56. 41.permutation.combination (Combining attributes).structure). 37.distribution (clusters). 34.game). 267 arpack. 216.es (iterators).communities (communities). 207. 55 . 36 cited.scores (centralization).game (barabasi.game (aging. 17.community).igraph (graph. 177 [<-. 51. 153 betweenness. 16. 177 [.undirected (as.structure). 177 %--% (iterators). 177 %<-% (iterators). 10.integer. 51 alpha. 218. 26. 64. 103 add.to. 251 ba.structure).igraph (graph.blocks).es (iterators). 6.294 -. 220 centralization. 87. 103 %s% (graph-operators).game).es (iterators). 51 cohesion (cohesive. 177 [[.es (iterators). 11 articulation.igraph (graph. 84. 7 aging. 59.score (kleinberg). 39 cliques.unpack. 201. 143 [<-. 143 $.traits. 68. 78 average. 182.directed).vs (iterators). 217. 177 %c% (graph-operators). 143 [. 110. 260.traits.game).game (igraph. 11.dendrogram. 29 as. 42. 226 callaway.game (preference. 143 [.game). 32 callaway. 16.points. 143 aging.blocks).game.game.vs (iterators). 219.undocumented).to. 103 %m% (graph-operators). 274 canonical. 28. 19 asymmetric.igraph. 89.components. 218 cluster. 7 algorithm (communities). 177 [<-.prefatt.igraph. 103 %u% (graph-operators).undocumented). 31 blockGraphs (cohesive. 159.ba.complex (arpack). 11 arpack. 24 barabasi. 242 arpack-options (arpack).communities (communities).centrality. 255 bibcoupling (cocitation).le.structure). 51 as. 29 bipartite.hclust.paths).igraph (graph. 177 $.edges (graph. 44 Combining attributes.length (shortest. 16 as. 42 clusters.info). 43.combination. 29. 15.cited.projection.blocks).connected (structure.igraph. 103 %du% (graph-operators).barabasi. 44 blocks (cohesive. 280 add.edges.

info). 267 get. 67.frame (graph. 96.capabilities.multiple (is.graph).graph).communities.paths (edge. 60 get. 210 constraint. 37.nodes (diameter). 143 edge. 256 delete. 84 295 edges (graph.paths).edge. 143 delete.game (traits). 234 exportPajek (cohesive.attribute. 228 dominator. 65.disjoint. 279 E. 116 graph. 202. 89. 166 establishment. 258 get.INDEX compare (compare. 60 conversion between igraph and graphNEL graphs. 6.multiple). 90 get. 56 components. 63. 72 get.communities. 218 degree. 114 graph-isomorphism. 51 decompose. 63. 6. 210.structure). 270 evolver (revolver). 256 delete. 54. 6. 141. 26 edge. 151 get. 28.multiple. 93 get.adjacency (conversion). 54.attribute (attributes). 90. 256 count. 251 get. 57.connectivity).adjacency. 21 get. 209.connectivity.neighborhood (neighborhood). 97 graph-motifs.betweenness. 53.adjlist.data. 286 edge. 62 convex. 94 get. 80. 54.vertex. 9.paths (shortest. 68. 44 farthest. 63 .vertices. 84 edge.incidence.edge. 81 ecount. 239. 55.shortest. 12. 6. 68.adjlist.adjlist). 127. 72 DL (read.ids. 287 edge.all. 57. 64 degree. 216.disjoint. 74 dyad.adhesion.graph.betweenness. 76 diameter. 92. 82. 15.stochastic.sequence. 227 getIgraphOpt (igraph options). 210. 286 edge.structure). 96 GML (read.diameter (diameter).structure).attribute (attributes).edge (structure. 84. 11.game. 153.edges (structure. 61.community. 177 E<. 171 crossing (communities). 162 dendPlot. 21 get.constructors). 262 delete.fire.edges (graph.frame). 6 get. 113.game. 121 ecount (structure. 117 get. 59 conversion. 104 graph.game. 158 getOption. 92.(iterators). 228 graph. 287 forest.igraphHRG.edges. 66.vertices (graph. 137.structure). 87. 49. 106. 286 graph. 209. 84 graph.paths).vertex. 143 erdos.renyi. 251 get.betweenness (betweenness). 143. 63 count. 143 demo.connectivity). 84.adjedgelist (get.community. 226 establishment. 86.game. 267 edge (graph. 184. 108. 158 dendPlot.adjacency.attribute (attributes). 60 get. 117. 70 dendrogram. 38.census. 181. 148 E (iterators). 258 get. 21 getIgraphOpt.data. 6. 41. 34.graph. 56 compare.paths (shortest. 274 evcent. 159 girth.vertices.paths. 173. 150 get. 63. 72 fastgreedy. 142. 267 get. 55. 57 connect.blocks).info).hull. 92 get. 54. 95.adhesion (edge. 182. 58 contract. 268 graph (graph. 68 dendPlot.communities).edgelist (conversion).tree. 67. 202. 177 eccentricity.shortest. 101 graph-operators. 92. 83.info). 103 graph-operators-by-name.edgelist. 54 dev. 51 cutat (communities). 73 Drawing graphs. 129.

coreness.consensus (Hierarchical random graphs). 277 graph. 114.union (graph-operators). 153 hrg.dfs. 147.constructors. 130 graph. 125 graph.maxflow).by. 101.subisomorphisms.count. 97 graph. 153 hub.vf2 (graph-isomorphism).fit (Hierarchical random graphs). 123 graph.compose (graph-operators).laplacian. 36 graph.vf2 (graph-isomorphism).adjlist (Graphs from adjacency lists).star. 153 hierarchy (cohesive. 136.subisomorphisms.diversity.intersection (graph-operators). 97 graph. 137 graph. 6 graph.difference.full. 97 graph.motifs.random.difference (graph-operators). 181 . 152 has.vf2.cohesion.fit. 119. 120 graph. 6. 5 graph.union. 171 Hierarchical random graphs. 131 graph. 133 graph. 104 graph.multiple).graph). 210 graph.multiple (is.ring.union.by. 47. 44 HRG (Hierarchical random graphs).disjoint.motifs (graph-motifs).game. 286 graph.count.isomorphic (graph-isomorphism). 85 graph. 150 grg.create (Hierarchical random graphs). 143 graph. 127 graph. 150 graph. 148 graph.disjoint. 95.cohesion (vertex.296 graph.get.isoclass (graph-isomorphism).name (graph-operators-by-name). 288 graph. 153 hrg.data. 6 graph. 99. 133 graph. 15 hub. 140. 228 Graphs from adjacency lists. 110. 153 hrg.structure.incidence. 153 hrg.predict (Hierarchical random graphs). 18 hrg. 151 growing.isomorphisms.frame.lattice.bipartite. 97 graph.dendrogram (Hierarchical random graphs).kautz. 105 graph.edgelist. 195 graph.union (graph-operators). 103 graph. 134 graph. 70 hrg. 153 hrg. 103 graph. 134.maxflow. 6. 116.isomorphic. 103 graph.isocreate (graph-isomorphism). 97 graph.lcf.isoclass.name (graph-operators-by-name).intersection.density. 140 graph.famous.bipartite. 116 graph.knn. 138 graph.get.blocks). 196 graph. 284 graph.name (graph-operators-by-name).vf2 (graph-isomorphism). 18. 142.graphdb. 121 graph.strength.score (kleinberg). 233 graph. 129 graph.atlas.subisomorphic.vf2 (graph-isomorphism).neighborhood (neighborhood).difference.game. 119 graph.vf2 (graph-isomorphism).union.formula. 103 graph. 97 graph. 112. 103 graph.bruijn. 102 graph. 153 hrg. 104 graph.score. 279 graph. 130. 123 graph. 117 graph. 120.connectivity). 112.by. 258 graph.bfs. 97 graph. 103 graph. 97 INDEX graph. 101 graph.de. 132 graph. 108.isomorphisms.automorphisms. 116.matching.complementer (graph-operators).full. 109 graph.isomorphic. 104 GraphML (read. 119.game (Hierarchical random graphs). 6.consensus.mincut (graph. 278. 85. 134 graph.

arpack.subgraph (subgraph).propagation. 84.INDEX igraph (igraph-package). 272.default (arpack).plotting (Drawing graphs).shape.options.multiple. 194 layout.vertex. 200.weighted. 40.merge.drl). 268 infomap.info).attributes (attributes). 62 igraph. 163 . 42 is. 280 igraph. 79.dag. 5 igraph.matching (graph.info).options (igraph options).noclip (Vertex shapes).minimal. 256 is. 184. 169 is. 267 is.cliques (cliques).final (layout. 171 is. 255 is. 194–196.matching (graph. 171. 210 largest.drl.vertex. 158 igraph.graph).sequence). 160 igraph.community.separator. 203. 189 igraph.refine (layout. 51 is. 181 label.game. 6. 183.drl). 169 297 is. 39 largest. 90.independent.graphNEL (conversion between igraph and graphNEL graphs).sets (independent.chordal.star.drl).sets.coarsen (layout.regular. 7 maxcohesion (cohesive. 157 igraph.vertex. 7.vertex. 16.number (independent. 189 igraph.vertex. 192 layout.console (igraph console).degree. 54. 170 is. 112 is. 21 list. 180 kleinberg. 192. 5 igraph console.directed (structure. 62 igraph. 44 maximal.attributes (attributes).graph. 167.game (igraph.sequence (is. 179 incident (structure.vertex.graphical.maximal.graph. 76 igraph. 189.communities (communities). 15.cohesiveBlocks (cohesive.sets (independent.vertex.degree. 282 igraph.drl. 256 is.sets). 228 line.separator (is.bipartite).sample.drl. 193. 138 is.mds.community. 44 length. 280 igraphdemo. 50. 45 is. 273 layout.loop (is. 39 maximal.cliques (cliques). 189 igraph.igraph. 54. 280 igraph. 54.vertex.shape. 191.drl.default (layout. 189 igraph. 53.par (igraph options). 196 layout.mutual.undocumented). 161 igraph.edge. 240.connected. 222. 188. 74 igraph. 21 list. 221.community. 189. 189 igraph. 164 interconnected. 172 is.loop.subgraph. 163 lastcit. 24. 138 is. 206 is.vertex.sets). 75.shapes.blocks).simple. 64 is.plotting.simple (simplify).undocumented. 162 incident. 168 is.shapes (Vertex shapes). 174 is.drl).multiple).matching).drl. 11 igraph.from.coarsest (layout. 158 igraph. 174. 158 igraph-package.grid. 176 iterators.bipartite (graph.eigenvector.attributes (attributes). 210. 287 length. 6 induced. 29.islands.connected (clusters). 202 list.hierarchical (communities). 51 LGL (read.matching).blocks). 177 k. 163 independent. 157 igraph options. 196 leading. 134. 161 layout. 163 induced. 188. 53. 173 is.sugiyama.drl.to.independent. 77. 222.separator).graphNEL (conversion between igraph and graphNEL graphs). 195 layout.sequence. 193 layout.drl).degree. 120. 267 independence. 166 is. 157 igraph. 204 is.named.sets).noplot (Vertex shapes). 21 load.

21 set. 74. 248. 13. 246.length.nexusDatasetInfo (nexus).matching (graph. 205. 173.table.communities (communities). 177 print. 119 reciprocity. 118 read.fitness. 81 random.attribute (attributes).communities (communities). 258 scgExtra.community. 118. 21 remove. 178. 251 showtrace (communities).igraphHRGConsensus (Hierarchical random graphs). 209.community. 243.layout (layout. 72. 159. 21 revolver. 245 scgSemiProjectors.blocks).edge. 250 SCG (Spectral coarse graining).spanning. 244. 175. 241 save. 248. 246. 177 print. 287 static. 54.game). 78 parent (cohesive.community.vertex. 75–77. 207 mle.graph. 240 running. 244. 203 membership (communities).tree.vertex. 212 print.mean. 289–291 read.blocks). 15. 21 set. 208.game (erdos. 51 modularity. 5.search.edge. 76 par.vs (iterators). 90.game. 52–54. 263 static.graph. 273. 54. 53 multilevel. 194–196.cohesiveBlocks (cohesive.clusters (clusters).igraph. 10. 224 modularity. 216. 61. 44 path (graph.renyi. 127. 250. 209 neighborhood. 233 remove. 221. 222. 99. 7. 75–79.es (iterators). 168.bipartite. 57. 267 nexus. 152 random.power. 262 .igraph. 36. 194 plot. 7.law. 12. 192.attribute (attributes). 159. 234 rewire.communities (communities). 221. 247.vertices. 42 optimal. 7. 217. 248.hist (shortest. 79 plot.structure). 258 scgNormEps. 82. 167. 138 maximum. 131. 288 rglplot. 225 print. 51 merges (communities). 153 print.cardinality. 51 print. 75 SCG.graph. 212 nexusDatasetInfo (nexus). 7. 110. 260. 228. 159.igraphHRG (Hierarchical random graphs). 202. 239. 244. 250. 262.graph.attribute (attributes). 254 simplify.attribute (attributes). 256 scg. 172. 210.cohesiveBlocks (cohesive.paths. 210 neighbors. 223 preference. 118 read. 287 modularity. 270 Pajek (read.separators. 250 scgNormEps (scgExtra). 141.igraph.298 maximum. 223. 241.matching). 182.edges. 238 rewire. 251 permute. 282 plotHierarchy (cohesive. 215 options.game. 51 plot.info). 55. 48. 22.rank. 245 scgGrouping. 121. 256 spinglass.attribute (attributes).merge). 228 palette. 51 similarity. 17.igraph.graph). 184. 26.paths).separators. 258.graph. 255.blocks). 219 Pie charts as vertices. 44 plot.attribute (attributes).size. 204 minimum. 86 read. 249.delim. 21 shortest. 258 set. 189. 32 Spectral coarse graining.hclust. 220 piecewise. 244. 54. 44 print.csv. 24. 240.st.game. 179 neighbors (structure. 153 print. 51 minimal.blocks). 212 radius (eccentricity). 261.nexusDatasetInfoList (nexus). 51 solve. 67. 52 plot. 143 path. 24. 44 power. 226 INDEX print. 288 sizes (communities). 266 minimum.law. 227 page.igraph. 21 remove.fit.game. 79. 212 no.

shapes (Vertex shapes).structure). 44 summary. 143 Vertex shapes. 76 vertex. 265. 267 vertex (graph.info). 46. 29. 195. 141. 75. 279 V. 75–79. 16.community. 202. 271.tree. 76. 268 subgraph.disjoint. 209. 284 vertex. 76.census. 233. 274 transitivity. 222.create.paths (vertex. 275 triad. 228 unfold.igraph (print. 278 UCINET (read. 143 walktrap.disjoint. 280 vertex.pie. 220 vertex. 81. 271 tkplot. 222 topological.cohesiveBlocks (cohesive.connectivity. 7. 54. 226 summary.shape. 271 tkplot. 90. 288 xspline.igraph). 264. 286 watts.structure).(iterators). 240. 24. 287 write. 6 str.connectivity). 196. 43 subcomponent (components).sort.igraph). 85 vertex. 77 tkigraph. 212 text.getcoords.nexusDatasetInfoList (nexus). 6. 57.centrality. 184. 121 vcount (structure. 148 V (iterators). 85. 55. 284 vertex. 226 structure. 266 stMincuts.igraph. 177 V<. 280 vertices (graph.graph. 269 summary. 265 str.strogatz. 210.graph). 189. 7.blocks).info. 222 299 . 177 vcount.INDEX stCuts. 273 traits. 77 tkfont.pie (Pie charts as vertices). 84. 57 subgraph.paths.shape.igraph (print.game. 267 subcomponent.