get_multipartite: Build a properly-structured multipartite graph from raw data.

Description Usage Arguments Value See Also Examples

Description

get_multipartite builds a properly-structured multipartite graph from a file or from a data.frame containing raw data. This object can then be used by the other functions of this package. The structure of the input data and of the resulting structure is detailed below.

Usage

1
get_multipartite(filename = NULL, data = NULL)

Arguments

filename

A character string giving the path to the file containing the raw data.

The input file should contain at least four columns, separated by spaces. Each row gives a link between two nodes belonging to two different parts of the multipartite graph. The first column gives the label of the part of the first node and the second column gives the label of this node (any character string). Similarly, the third and fourth columns give the labels of the second part and of the second node. The file can eventually contain a fifth column giving the weights of the links (any positive integer or float value).

data

A data.frame containing the raw data.

This data.frame should have the same structure than the one described above for the case of an input file: four columns indicating the labels of the parts and of the nodes constituting the link, and an optional fifth column for its weight. At least filename or data should be specified, but not both at the same time.

Value

A properly-structured multipartite graph that can be used by the other functions of the triversity package.

The resulting object encodes the labels of the parts and of the nodes in the multipartite graph, as well as the transition matrices of random walks following different paths between parts (encoded as sparse matrices of floats in [0,1], with all rows summing to 1). These transition matrices are then used by functions such as get_distribution_from_path to compute the probability distributions of such random walks, or such as get_diversity_from_path to compute the diversity of these distributions.

Assuming the object returned by get_multipartite is stored in the graph variable, then:

See Also

Package slam for the sparse encoding of transition matrices and package data.tree for the tree structure storing these matrices.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data (tripartite_example)
graph <- get_multipartite (data=tripartite_example)

graph$parts

part1 <- graph$parts[1]
graph$nodes[[part1]]

part2 <- graph$parts[2]
as.matrix (graph$edges$Climb(part1,part2)$matrix)

Lamarche-Perrin/triversity documentation built on May 22, 2019, 12:36 p.m.