Title: | Work with Hypergraphs in R |
---|---|
Description: | Create and manipulate hypergraph objects. This early version of rhype allows for the output of matrices associated with the hypergraphs themselves. It also uses these matrices to calculate hypergraph spectra and perform spectral comparison. Functionality coming soon includes calculation of hyperpaths and hypergraph centrality measures. |
Authors: | Hugh Warden [aut, cre] |
Maintainer: | Hugh Warden <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3.0.9000 |
Built: | 2025-02-19 03:44:07 UTC |
Source: | https://github.com/hwarden162/rhype |
An adjacency matrix is a square matrix with both rows and columns being indexed by vertices. For each entry, the number is proportional to the strength of the connection going from the vertex represented as the row and the vertex represented by the column. For undirected hypergraphs, this matrix is symmetric but this is usually not the case for directed.
adjacency_matrix(hype, normalise = FALSE, self_adj = FALSE, as_matrix = TRUE)
adjacency_matrix(hype, normalise = FALSE, self_adj = FALSE, as_matrix = TRUE)
hype |
A hypergraph object |
normalise |
Whether the matrix should be normalised to either 1 or 0 |
self_adj |
Whether self adjacency should be represented |
as_matrix |
Whether the output should be coerced into a simple matrix |
Great care should be taken when using a hypergraph with mixed positive and negative real coefficients as there is a chance no adjacency will be registered for two adjacenct vertices. rhype does not check for these cases and they must be checked for by the user.
A matrix of adjacencies between vertices of a hypergraph.
h1 <- example_hype() adjacency_matrix(h1) h2 <- example_hype(oriented = TRUE, directed = TRUE) adjacency_matrix(h2)
h1 <- example_hype() adjacency_matrix(h1) h2 <- example_hype(oriented = TRUE, directed = TRUE) adjacency_matrix(h2)
Bootstrapping is a common statistical technique used to quantify
uncertainty of calculations. This is an approximation of the
bootstrap algorithm for hypergraphs. Bootstrapping is achieved
by creating a new hypergraph where the vertices, hyperedges or
both have themselves been bootstrapped, achieved using the
"vertex"
, "hyperedge"
or "both"
methods.
bootstrap_hype(hype, n = 1, method = "both")
bootstrap_hype(hype, n = 1, method = "both")
hype |
A hypergraph object. |
n |
The number of bootstrapped hypergraphs required. |
method |
What method to use to calculate the bootstrapped hypergraphs |
A list of bootstrapped hypergraphs.
hype <- example_hype() resamples <- bootstrap_hype(hype, n = 5) lapply(resamples, incidence_matrix)
hype <- example_hype() resamples <- bootstrap_hype(hype, n = 5) lapply(resamples, incidence_matrix)
The cardinality of a hyperedge is the number of vertices that it contains.
cardinality(hype)
cardinality(hype)
hype |
A hypergraph object. |
A vector of the cardinality of the hyperedges.
hype <- example_hype() cardinality(hype)
hype <- example_hype() cardinality(hype)
The connectivity graph is a graphical representation of a hypergraph, it has a vertex for each vertex and hyperedge in the hypergraph. Two hyperedges are connected in the connectivity graph if they both have a vertex in common, a vertex is connected to a hyperedge if the vertex is contained in the hyperedge and no vertices are connected by edges.
connectivity_graph(hype)
connectivity_graph(hype)
hype |
A hypergraph object. |
A graph object representing the hyperedge connectivity graph.
hype <- example_hype() g <- connectivity_graph(hype) print(g) plot(g)
hype <- example_hype() g <- connectivity_graph(hype) print(g) plot(g)
The degree of a vertex is a way of expressing how many connections there are from a vertex to the rest of the hypergraph. The current version of rhype has three methods for computing degree.
degree(hype, method = NA)
degree(hype, method = NA)
hype |
A hypergraph object |
method |
The method for calculating degree. Out of |
"vertex"
counts the number of ways it is possible to move to another
vertex. If there are multiple hyperedges connecting two vertices, then each
of these hyperedges will be counted as a new way to move between these two
vertices. For weighted hypergraphs or hypergraphs with real coefficients,
the strength of connection between two vertices is a functions of the weights
and real coefficients.
"vertex_simple"
just counts the number of vertices it is possible to reach
in one step from the given vertex, no matter how many hyperedges connect them.
"hyperedge"
represents the strength with which a vertex connects with
itself through the hyperedges it is a member of. This is taken from the work
of Jurgen Jost and Raffaella Mulas doi:10.1016/j.aim.2019.05.025. For
unweighted hypergraphs without real coefficients this is equivalent to
"hyperedge_simple"
.
"hyperedge_simple"
just counts the number of hyperedges a vertex is a
member of.
A vector representing the degree of each vertex with respect to the given method.
h1 <- example_hype() degree(h1)
h1 <- example_hype() degree(h1)
The dual of a hypergraph has a vertex for each original hyperedge and a hyperedge for each original vertex. A vertex is a member of a hyperedge if the original hyperedge has the original vertex as a member.
dual_hype(hype)
dual_hype(hype)
hype |
A hypergraph object. |
A hypergraph object representing the dual of the hypergraph.
hype <- example_hype() dual_hype(hype)
hype <- example_hype() dual_hype(hype)
To calculate the eigenvector centrality of a hypergraph, each vertex is assigned a value that is proportional to the sum of the value of its neighbours.
eigenvector_centrality(hype)
eigenvector_centrality(hype)
hype |
A hypergraph object |
A vector of values representing the eigenvector centrality of each node
h1 <- example_hype() eigenvector_centrality(h1)
h1 <- example_hype() eigenvector_centrality(h1)
To calculate the eigenvector centrality of a hypergraph, each vertex is assigned a value that is proportional to the sum of the value of its neighbours. This function gives the scaling factor relating the value of each node to the sum of the value of its neighbours.
eigenvector_centrality_factor(hype)
eigenvector_centrality_factor(hype)
hype |
A hypergraph object |
A number representing the scaling factor relating the value of each node to the sum of the value of its neighbours
h1 <- example_hype() eigenvector_centrality_factor(h1)
h1 <- example_hype() eigenvector_centrality_factor(h1)
Quickly generate an example hypergraph. Can be used for quickly testing and trialing examples.
example_hype( oriented = FALSE, directed = FALSE, vertex_weighted = FALSE, edge_weighted = FALSE, real_coef = FALSE )
example_hype( oriented = FALSE, directed = FALSE, vertex_weighted = FALSE, edge_weighted = FALSE, real_coef = FALSE )
oriented |
Logical value representing whether the example hypergraph should be oriented |
directed |
Logical value representing whether the example hypergraph should be directed |
vertex_weighted |
Logical value representing whether the example hypergraph should have vertex weights |
edge_weighted |
Logical value representing whether the example hypergraph should have hyperedge weights |
real_coef |
Logical value representing whether the example hypergraph should have real coefficients relating vertices to hyperedges |
An example hypergraph with the given properties
h1 <- example_hype() h2 <- example_hype(oriented = TRUE) h3 <- example_hype(oriented = TRUE, directed = TRUE) h4 <- example_hype(oriented = TRUE, directed = TRUE, real_coef = TRUE)
h1 <- example_hype() h2 <- example_hype(oriented = TRUE) h3 <- example_hype(oriented = TRUE, directed = TRUE) h4 <- example_hype(oriented = TRUE, directed = TRUE, real_coef = TRUE)
Takes a hypergraph object and returns whether there are real coefficients associating vertices to hyperedges.
has_real_coef(hype)
has_real_coef(hype)
hype |
A hypergraph object. |
A logical value indicating whether there are real cofficients associating vertices to hyperedges.
h <- example_hype() has_real_coef(h)
h <- example_hype() has_real_coef(h)
Create a Hypergraph From a Hyperedge List
hype_from_edge_list(elist, directed = FALSE)
hype_from_edge_list(elist, directed = FALSE)
elist |
A hyperedge list. For an unoriented hypergraph, a hyperedge is
just a vector of the vertices contained within the hyperedge. Each vertex is
represented as a string. For an oriented hypergraph, each hyperedge is
itself a list of two vectors. Each of these vectors contains strings
representing the vertices contained in one end of the hyperedge. For a
directed hypergraph, each hyperedge is also a list of two vectors. In the
directed case, the first vector represents the vertices contained in the
tail of the hyperedge and the second the vertices contained in the head.
These two entries are also named |
directed |
A logical value representing whether the hypergraph should be directed. |
A hypergraph object with the given hyperedge structure.
l1 <- list( h1 = c("a", "b", "c"), h2 = c("c", "d", "e"), h3 = c("a", "e") ) hype1 <- hype_from_edge_list(l1) l2 <- list( h1 = list( c("a", "b"), c("b", "c") ), h2 = list( c("b", "c", "d"), c("e", "f") ), h3 = list( "f", "a" ) ) hype2 <- hype_from_edge_list(l2) hype3 <- hype_from_edge_list(l2, directed = TRUE)
l1 <- list( h1 = c("a", "b", "c"), h2 = c("c", "d", "e"), h3 = c("a", "e") ) hype1 <- hype_from_edge_list(l1) l2 <- list( h1 = list( c("a", "b"), c("b", "c") ), h2 = list( c("b", "c", "d"), c("e", "f") ), h3 = list( "f", "a" ) ) hype2 <- hype_from_edge_list(l2) hype3 <- hype_from_edge_list(l2, directed = TRUE)
Create a Hypergraph From an Incidence Matrix
hype_from_inc_mat(inc_mat, directed = FALSE, real_coef = FALSE)
hype_from_inc_mat(inc_mat, directed = FALSE, real_coef = FALSE)
inc_mat |
An incidence matrix or, for an oriented hypergraph, a list of two incidence matrices. |
directed |
A logical value representing whether the hypergraph should be directed. |
real_coef |
A logical value representing whether the hypergraph should have real coefficients associating vertices to hyperedges. |
A hypergraph object with the given incidence structure.
i1 <- matrix( c(1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0), nrow = 5, ncol = 3, dimnames = list( paste0("v", 1:5), paste0("h", 1:3) ) ) hype1 <- hype_from_inc_mat(i1) i2 <- list( matrix( c(1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0), nrow = 4, ncol = 3, dimnames = list( paste0("v", 1:4), paste0("h", 1:3) ) ), matrix( c(0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0), nrow = 4, ncol = 3, dimnames = list( paste0("v", 1:4), paste0("h", 1:3) ) ) ) hype2 <- hype_from_inc_mat(i2) hype3 <- hype_from_inc_mat(i2, directed = TRUE)
i1 <- matrix( c(1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0), nrow = 5, ncol = 3, dimnames = list( paste0("v", 1:5), paste0("h", 1:3) ) ) hype1 <- hype_from_inc_mat(i1) i2 <- list( matrix( c(1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0), nrow = 4, ncol = 3, dimnames = list( paste0("v", 1:4), paste0("h", 1:3) ) ), matrix( c(0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0), nrow = 4, ncol = 3, dimnames = list( paste0("v", 1:4), paste0("h", 1:3) ) ) ) hype2 <- hype_from_inc_mat(i2) hype3 <- hype_from_inc_mat(i2, directed = TRUE)
Get a more detailed printout of what is contained within a hypergraph object to understand more about its structure as a whole without having to repeatedly call other functions.
hype_info( hype, numv = TRUE, elist = TRUE, vnames = TRUE, vweights = TRUE, enames = TRUE, eweights = TRUE, weighted = TRUE, oriented = TRUE, directed = TRUE, real_coef = TRUE, inc_mat = TRUE )
hype_info( hype, numv = TRUE, elist = TRUE, vnames = TRUE, vweights = TRUE, enames = TRUE, eweights = TRUE, weighted = TRUE, oriented = TRUE, directed = TRUE, real_coef = TRUE, inc_mat = TRUE )
hype |
A hypergraph object |
numv |
A logical variable indicating whether information about the number of vertices should be printed |
elist |
A logical variable indicating whether information about the hyperedge list should be printed |
vnames |
A logical variable indicating whether information about the vertex names should be printed |
vweights |
A logical variable indicating whether information about the vertex weights should be printed |
enames |
A logical variable indicating whether information about the hyperedge names should be printed |
eweights |
A logical variable indicating whether information about the hyperedge weights should be printed |
weighted |
A logical variable indicating whether information about the hypergraph weighting should be printed |
oriented |
A logical variable indicating whether information about the hypergraph orientation should be printed |
directed |
A logical variable indicating whether information about the hypergraph direction should be printed |
real_coef |
A logical variable indicating whether information about the hypergraph real coefficients should be printed |
inc_mat |
A logical variable indicating whether information about the hypergraph incidence matrix should be printed |
This gives a more detailed look at the whole hypegraph object. It is intended solely to aid the user when using rhype and generally should not be included in final scripts. If a user wants to include this in their final script it is instead heavily encouraged that they use other rhype functions to generate their own bespoke messages.
hype1 <- example_hype() hype_info(hype1) hype2 <- example_hype(vertex_weighted = TRUE, edge_weighted = TRUE) hype_info(hype2) hype3 <- example_hype(oriented = TRUE, directed = TRUE, real_coef = TRUE) hype_info(hype3)
hype1 <- example_hype() hype_info(hype1) hype2 <- example_hype(vertex_weighted = TRUE, edge_weighted = TRUE) hype_info(hype2) hype3 <- example_hype(oriented = TRUE, directed = TRUE, real_coef = TRUE) hype_info(hype3)
As defined by Jurgen Jost and Raffaella Mulas doi:10.1016/j.aim.2019.05.025
hype_norm_lap_mat(hype, as_matrix = TRUE)
hype_norm_lap_mat(hype, as_matrix = TRUE)
hype |
A hypergraph object |
as_matrix |
Whether to coerce the result to a simple matrix |
The hyperedge normalised laplacian matrix of the hypergraph
h1 <- example_hype() hype_norm_lap_mat(h1)
h1 <- example_hype() hype_norm_lap_mat(h1)
The order of a hypergraph is the number of vertices it has
hype_order(hype)
hype_order(hype)
hype |
A hypergraph object |
A number representing the number of vertices in the hypergraph
hype <- example_hype() hype_order(hype)
hype <- example_hype() hype_order(hype)
The size of a hypergraph is the number of hyperedges it contains
hype_size(hype)
hype_size(hype)
hype |
A hypergraph object |
A number representing the number of hyperedges in a hypergraph
h1 <- example_hype() hype_size(h1)
h1 <- example_hype() hype_size(h1)
Take a hypergraph object and return its hyperedge list.
hyperedge_list(hype)
hyperedge_list(hype)
hype |
A hypergraph object |
A hyperedge list. See main documentation for more details on its structure
h <- example_hype() hyperedge_list(h)
h <- example_hype() hyperedge_list(h)
Takes a hypergraph object and returns the names of the hyperedges.
hyperedge_names(hype)
hyperedge_names(hype)
hype |
A hypergraph object. |
A vector of strings representing the names of the the hyperedges. If
the hyperedges have no names assocaited with them it will return NULL
instead.
h <- example_hype() hyperedge_names(h)
h <- example_hype() hyperedge_names(h)
Takes a hypergraph object and returns the weights associated with each hyperedge
hyperedge_weights(hype)
hyperedge_weights(hype)
hype |
A hypergraph object. |
A vector of weights asssociated with the hyperedges. If the are no
weights assicated with the hyperedges then NULL
is returned instead.
h <- example_hype() hyperedge_weights(h)
h <- example_hype() hyperedge_weights(h)
An incidence matrix has rows indexed by vertices and columns indexed by hyperedges. Each entry is non-zero if the associated vertex is a member of the associated hyperedge. For an oriented hypergraph, this returns a list of two matrices with the first representing incidence to one end of the hyperedges and the second representing incidence to the other end. For a directed hypergraph the first represents incidence to the tail of a hyperedge and the second represents incidence to the head.
incidence_matrix(hype, augment_oriented = TRUE, as_matrix = TRUE)
incidence_matrix(hype, augment_oriented = TRUE, as_matrix = TRUE)
hype |
A hypergraph object |
augment_oriented |
Whether to augment an oriented hypergraph |
as_matrix |
Whether to coerce the result to a simple matrix |
It is hard to use the incidence matrices of oriented undirected hypergraphs
in calculations. The augment_oriented
option turns the hypergraph into a
directed hypergraph, but each hyperedge is represented twice, once pointing
in each direction. This is much easier to use for further calculations.
An incidence matrix or a list of two incidence matrices.
h1 <- example_hype() incidence_matrix(h1) h2 <- example_hype(oriented = TRUE, directed = TRUE) incidence_matrix(h2)
h1 <- example_hype() incidence_matrix(h1) h2 <- example_hype(oriented = TRUE, directed = TRUE) incidence_matrix(h2)
Takes a hypergraph object and returns whether the hyperedges are directed.
is_directed(hype)
is_directed(hype)
hype |
A hyeprgraph object. |
A logical value indicating whether the hyperedges are directed.
h <- example_hype() is_directed(h)
h <- example_hype() is_directed(h)
Takes a hypergraph object and returns whether the hyperedges are oriented.
is_oriented(hype)
is_oriented(hype)
hype |
A hypergraph object. |
A logical value indicating whether the hyperedges are oriented.
h <- example_hype() is_oriented(h)
h <- example_hype() is_oriented(h)
Takes a hypergraph object and returns whether a hypergraph has weights associated with its vertices or hyperedges.
is_weighted(hype)
is_weighted(hype)
hype |
A hypergraph object. |
A logical value indicating whether the hypergraph has weights associated with its vertices or hyperedges.
h <- example_hype() is_weighted(h)
h <- example_hype() is_weighted(h)
Jackknifing is a resampling technique similar to bootstrapping, where many
resamples are taken, each time leaving out one observation. For the abstraction
to hypergraphs, the "vertex"
method recreates the hypergraph leaving out one
vertex, the "hyperedge"
method recreates the hypergraph leaving out one hyperedge
and the "both"
method leaves out one of each.
jackknife_hype(hype, n = 1, method = "both")
jackknife_hype(hype, n = 1, method = "both")
hype |
A hypergraph object. |
n |
The number of hypergraphs to create. |
method |
The method to use to jackknife the hypergraphs. |
A list of jackknifed hypergraphs.
hype <- example_hype() resamples <- jackknife_hype(hype, n = 5) lapply(resamples, incidence_matrix)
hype <- example_hype() resamples <- jackknife_hype(hype, n = 5) lapply(resamples, incidence_matrix)
Find the Laplacian Matrix of a Hypergraph
laplacian_matrix(hype, as_matrix = TRUE)
laplacian_matrix(hype, as_matrix = TRUE)
hype |
A hypergraph object |
as_matrix |
Whether to coerce the result to a simple matrix |
The laplacian matrix of the hypergraph
h1 <- example_hype() laplacian_matrix(h1)
h1 <- example_hype() laplacian_matrix(h1)
The cardinality of a hyperedge is the number of vertices that it contains.
max_cardinality(hype)
max_cardinality(hype)
hype |
A hypergraph object. |
The value of the maximum cardinality of a hyperedge in the hypergraph.
hype <- example_hype() max_cardinality(hype)
hype <- example_hype() max_cardinality(hype)
The degree of a vertex is a way of expressing how many connections there
are from a vertex to the rest of the hypergraph. See the degree
help
documentation for more details.
max_degree(hype, method = NA)
max_degree(hype, method = NA)
hype |
A hypergraph object. |
method |
The method by which to calculate the degree, see |
The maximum value for the chosen degree among vertices of the hypergraph.
h <- example_hype() max_degree(h)
h <- example_hype() max_degree(h)
The cardinality of a hyperedge is the number of vertices that it contains.
min_cardinality(hype)
min_cardinality(hype)
hype |
A hypergraph object. |
The value of the minimum cardinality of a hyperedge in the hypergraph.
hype <- example_hype() min_cardinality(hype)
hype <- example_hype() min_cardinality(hype)
The degree of a vertex is a way of expressing how many connections there
are from a vertex to the rest of the hypergraph. See the degree
help
documentation for more details.
min_degree(hype, method = NA)
min_degree(hype, method = NA)
hype |
A hypergraph object. |
method |
The method by which to calculate the degree, see |
The maximum value for the chosen degree among vertices of the hypergraph.
h <- example_hype() min_degree(h)
h <- example_hype() min_degree(h)
A partial hypergraph can be induced from a set of hyperedges. The partial hypergraph has all of the original vertices, but only the hyperedges used to induce it.
partial_hype(hype, hyperedges)
partial_hype(hype, hyperedges)
hype |
A hypergraph object. |
hyperedges |
A vector of the names of the hyperedges to be used to induce the partial hypergraph. |
A hypergraph object of the partial hypergraph.
hype <- example_hype() partial_hype(hype, c("h1", "h2"))
hype <- example_hype() partial_hype(hype, c("h1", "h2"))
Pseudo-inversion is where a vector has each non-zero element inverted and each zero element remains untouched. This is useful for pseudoinverting matrices that only have non-zero entries on the leading diagonal.
pseudo_invert(vec)
pseudo_invert(vec)
vec |
A vector of numbers |
A vector of pseudo-inverted numbers
A hyperpath is a set of hyperedges such that each consecutive pair of hyperedges contain at least vertex in common. A shortest hyperpath between two vertices is the smallest set of hyperedges that form a hyperpath such that one vertex is in the first hyperpath and the other vertex is in the last hyperpath.
shortest_hyperpaths(hype, from, to)
shortest_hyperpaths(hype, from, to)
hype |
A hypergraph object. |
from |
The vertex that is the start of the hyperpath. |
to |
The vertex that is the end of the hyperpath, |
A list of shortest hyperpaths between the given vertices.
hype <- example_hype() shortest_hyperpaths(hype, "v1", "v4")
hype <- example_hype() shortest_hyperpaths(hype, "v1", "v4")
A hypergraph can be shuffled to slightly perturb its structure. These shuffled hypergraphs can then be used to estimate the uncertainty of calculations on the original hypergraph.
shuffle_hype(hype, n = 1, method = "hyperedge")
shuffle_hype(hype, n = 1, method = "hyperedge")
hype |
A hypergraph object. |
n |
The number of shuffled hypergraphs to calculate. |
method |
The method to use to shuffle the hypergraph. |
Two methods are used to shuffle a hypergraph, the "vertex"
method keeps the
degree of each vertex the same, randomly reassigning the hyperedges they are
members of. The "hyperedge"
method keeps the cardinality of each hyperedge
the same, randomly reassigning the vertices that are members.
A list of shuffled hypergraphs.
hype <- example_hype() resamples <- shuffle_hype(hype, n = 5) lapply(resamples, incidence_matrix)
hype <- example_hype() resamples <- shuffle_hype(hype, n = 5) lapply(resamples, incidence_matrix)
Find the Spectra of a Hypergraph
spectra(hype, matrix = "laplacian", n = NULL)
spectra(hype, matrix = "laplacian", n = NULL)
hype |
A hypergraph object |
matrix |
The matrix to calculate the spectra with respect to. Out of
|
n |
The number of eigenvalues or eigenvectors to calculate. If left empty or
as |
The eigen decomposition of the given matrix of the given hypergraph
h <- example_hype() spectra(h)
h <- example_hype() spectra(h)
Find the Spectral Distance Between Two Hypergraphs
spectral_distance(hype1, hype2, matrix = "laplacian")
spectral_distance(hype1, hype2, matrix = "laplacian")
hype1 |
A hypergraph object |
hype2 |
A hypergraph object |
matrix |
The matrix to calculate the spectral distance with respect to.
Out of |
A number representing the spectral distance between the two hypergraphs with respect to the given matrix
h1 <- example_hype() h2 <- example_hype() spectral_distance(h1, h2)
h1 <- example_hype() h2 <- example_hype() spectral_distance(h1, h2)
Find the Spectral Distance From the Fully Disconnected Hypergraph
spectral_distance_disc(hype, matrix = "vert_norm_lap_mat")
spectral_distance_disc(hype, matrix = "vert_norm_lap_mat")
hype |
A hypergraph object |
matrix |
The matrix to calculate the spectra with respect to. Out of
|
The spectral distance from the disconnected hypergraph
h <- example_hype() spectral_distance_disc(h)
h <- example_hype() spectral_distance_disc(h)
The support graph of a hypergraph is a graph that has a vertex for every vertex in the hypergraph. Two vertices are connected in the support graph if there is a hyperedge that connects them.
support_graph(hype, simple = TRUE)
support_graph(hype, simple = TRUE)
hype |
A hypergraph object. |
simple |
Whether a simplified support graph should be created. |
If simple
is set to FALSE
then for unweighted hypergraphs without real coefficients
the support graph has an edge connected vertices for each hyperedge connecting them
in the hypergraph.
The support graph of the hypergraph
hype <- example_hype() g <- support_graph(hype) print(g) plot(g)
hype <- example_hype() g <- support_graph(hype) print(g) plot(g)
When using the rhype functions, the integrity of a hypergraph object should remain intact. However, as the properties of a hypergraph object are dependent on one another, it is possible in the case of an error or direct object manipulation by the user that a hypergraph object's integrity is corrupted. This will cause other rhype functions to either throw errors or to calculate incorrect answers. This function is not exhaustive but will perform multiple sanity checks on hypergraph objects and is a good place to start when debugging.
validate_hypergraph(hype, return = FALSE, verbose = TRUE)
validate_hypergraph(hype, return = FALSE, verbose = TRUE)
hype |
A hypergraph object |
return |
A logical variable stating whether any output should be returned from the function |
verbose |
A logical variable indicating whether the function should output text to the screen |
Outputs text to screen of any problems found within the hypergraph
object. If return
is set to TRUE
then a logical output will be
returned. This logical output will be TRUE
if it passed all of the
tests, FALSE
if it failed any test that proves the structure of the
hypergraph is broken or NULL
if it failed a test that most hypergraphs
used practically should pass, but doesn't necessarily mean the
hypergraph is broken, see text output for more details.
h <- example_hype() validate_hypergraph(h)
h <- example_hype() validate_hypergraph(h)
As defined by Jurgen Jost and Raffaella Mulas doi:10.1016/j.aim.2019.05.025
vert_norm_lap_mat(hype, as_matrix = TRUE)
vert_norm_lap_mat(hype, as_matrix = TRUE)
hype |
A hypergraph object |
as_matrix |
Whether to coerce the result to a simple matrix |
The vertex normalised laplacian matrix of the hypergraph
h1 <- example_hype() vert_norm_lap_mat(h1)
h1 <- example_hype() vert_norm_lap_mat(h1)
Takes a hypergraph object and returns the names of its vertices.
vertex_names(hype)
vertex_names(hype)
hype |
A hypergraph object. |
A vector of strings of vertex names
h <- example_hype() vertex_names(h)
h <- example_hype() vertex_names(h)
Takes a hypergraph object and returns the weights associated with its vertices.
vertex_weights(hype)
vertex_weights(hype)
hype |
A hypergraph object. |
A vector of weights associated with each vertex. If the hypergraph
has no weights associated with its vertices it will return NULL
instead.
h <- example_hype() vertex_weights(h)
h <- example_hype() vertex_weights(h)