Sunday, 14 January 2018

Representations for Graphs in igraph

Cited from the Book "Statistical Analysis of Network Data with R"

An adjacency list representation of a graph G is simply an array of size Nv, ordered with respect to the ordering of the vertices in V, each element of which is a list, where the ith list contains the set of all vertices j for which there is an edge from i to j. This is the representation usually used by igraph, evident in printing the output from the structure function str.

An edge list is a simple two-column list of all vertex pairs that are joined by a edge. In igraph, edge lists are used, for example, when printing the edge set E.

The function get.edgelist returns an edge list as a two-column R matrix.

Finally, graphs can also be stored in matrix form. The Nv × Nv adjacency matrix for a graph G = (V,E), say A, is defined so that A_{ij} = 1, if i, j} ∈ E, or A_{ij} = 0, otherwise.

In words, A is non-zero for entries whose row-column indices (i, j) correspond to vertices in G joined by an edge, from i to j, and zero, for those that are not. The matrix A will be symmetric for undirected graphs.

get.adjacency(g)

In igraph, network data already loaded into R in these specific formats can be used to generate graphs using the functions graph.adjlist, graph.edgelist, and graph.adjacency, respectively.

For data stored in a file, the function read.graph can be used. In fact, this latter function not only supports the three formats discussed above, but also a number of other formats (e.g., such as GraphML, Pajek, etc.). Conversely, the function write.graph can be used to save graphs in various formats.



No comments:

Post a Comment