as.hypergraph {HyperG}R Documentation

Convert between hypergraphs and graphs.

Description

Convert a hypergraph to a graph or a graph to a hypergraph.

Usage

as.graph(h)
hypergraph2graph(h)
as.hypergraph(x,n, ...)
graph2hypergraph(g, method = c("incidence", "adjacency", 
                               "neighborhood", "ego",  "spectral"), ...)

Arguments

h

a hypergraph.

g

a graph.

method

see Details.

x

a matrix, list or graph. See details.

n

number of vertices if x is missing.

...

arguments passed to various functions. See Details.

Details

For as.graph and hypergraph2graph, create a graph from the incidence matrix using the product of the transpose of the incidence matrix with the incidence matrix. as.graph is an alias of hypergraph2graph. This computes the 2-section of the hypergraph, in the terminology of Bretto.

The function as.hypergraph() returns a hypergraph defined by a graph, matrix (or edgelist). If a matrix is given, it is viewed as the incidence matrix of the hypergraph. If a list is given, it is interpreted as the hyper-edge list. If a graph is given, graph2hypergraph is called with the graph and the arguments passed in .... If x is NULL or missing, and n>0 is given, an empty hypergraph on n nodes is returned. If all else fails, an empty hypergraph on no nodes is returned.

The method variable controls the method used for turning a graph into a hypergraph:

incidence - use the incidence matrix of the graph.

adjacency - treat the adjacency matrix as the incidence matrix.

neighborhood,ego - Use the neighborhoods of the vertices. The arguments to ego are passed in the dotted arguments.

spectral - The spectral embedding is performed, followed by Mclust. The arguments are passed to hypergraph_from_spectral_clustering.

Value

An undirected igraph graph object.

Author(s)

David J. Marchette dmarchette@gmail.com

References

Bretto, Alain, Hypergraph theory, An introduction. Springer, 2013.

See Also

as.hypergraph, graph2hypergraph, hypergraph_from_spectral_clustering, ego, Mclust,

Examples

   h <- hypergraph_from_edgelist(list(1:4,1:2,c(2,3,5),c(3,5:7)))
	g <- as.graph(h)

[Package HyperG version 1.0.0 Index]