The giRaph package for graph representation in R
Luca La Rocca, Jens Henrik Badsberg, Claus Dethlefsen · VBN Forskningsportal (Aalborg Universitet) · 2006
The giRaph package provides formal classes and methods to represent and manipulate graphs in the R language and environment for statistical computing and graphics. It is intended as a contribution to the gR project described by Lauritzen (2002). We consider a broad notion of graph, including graphs with loops, multiple edges and hyper-edges (i.e. edges involving more than two vertifces) both directed and undirected. In particular, hyper-graphs and simple graphs (as defined by Lauritzen, 1996) fall within the scope of our definition. Since there is no unique way to represent a graph which is optimal for all computations, we consider four different representations: incidence list, incidence matrix, adjacency list and adjacency matrix; see for example Ahuja et al. (1993). We provide classes for these representations, suitable to store graphs of different families, and classes for such families, handling alternative representations transparently with respect to the user. For each class we furnish a robust initialize method, that takes care of producing valid output from varied input, a nice show method, adopting typical graph notation, and methods to set and retrieve information. In addition, we implement conversions between graph representations, and between graphs of different families, by means of coerce methods. We also provide classes for directed and undirected edges, as well as for vertex sets, so that simple graph operations such as adding/removing an edge, or extracting an induced subgraph, can be performed via overloaded +, and * operators. Finally, we provide an interface to other graph packages such as the interactive graphical tool dynamicGraph by Badsberg (2005) which is also part of the gR project. Ahuja, R.K., Magnanti, T.L. and Orlin J.B. (1993) “Network Flows”, Prentice-Hall, NJ. Badsberg, J.H. (2005) “dynamicGraph”, R package, version 0.2.0.1, available on CRAN. Lauritzen, S.L. (1996) “Graphical Models”, Clarendon Press, Oxford, UK. Lauritzen, S.L. (2002) “gRaphical Models in R”, R News, 2, 39.