Diff of /man/combine_layers.Rd [000000] .. [73f552]

Switch to unified view

a b/man/combine_layers.Rd
1
% Generated by roxygen2: do not edit by hand
2
% Please edit documentation in R/combine_layers.R
3
\name{combine_layers}
4
\alias{combine_layers}
5
\title{Combine layers}
6
\usage{
7
combine_layers(graph1, graph2 = NULL, interaction.df = NULL)
8
}
9
\arguments{
10
\item{graph1}{an igraph object or list of igraph (\code{list.igraph}).}
11
12
\item{graph2}{an igraph object or list of igraph (\code{list.igraph}) with
13
the same length as \code{graph1}.}
14
15
\item{interaction.df}{(optional) a 2 colomns data.frame (from, to)
16
describing the edges between vertices from both graphs.}
17
}
18
\value{
19
a merged graph with both vertex attributes from graph1 and graph2.
20
}
21
\description{
22
Return a merged graph from two graph layers.
23
}
24
\details{
25
If \code{graph2} is a single graph, it will be merged to each element of
26
\code{graph1} (\code{igraph} or \code{list.igraph}).
27
28
If \code{graph2} is a list of graph (\code{list.igraph}), each element of
29
\code{graph1} and each element of \code{graph2} are merged in pairs.
30
31
Optionally, \code{interaction.df} should be provide if any vertex are shared
32
between graphs. It can also be used to extend the first graph.
33
34
In both scenarios, vertex attributes are kept. If a vertex attribute is
35
missing from graph1 or graph2, NULL value is added.
36
Otherwise, if there is an overlap between attribute values for the same
37
vertex, attribute from graph2 is dropped.
38
}
39
\examples{
40
# with single graphs
41
graph1 <- igraph::graph_from_data_frame(list(from = c('A', 'B'),
42
                                             to = c('B', 'C')),
43
                                        directed = FALSE)
44
graph2 <- igraph::graph_from_data_frame(list(from = c(1), 
45
                                             to = c(2)),
46
                                        directed = FALSE)
47
res <- combine_layers(graph1 = graph1,
48
                      graph2 = graph2)
49
50
# with list of graphs
51
graph1.list <- list(graph1, graph1)
52
graph2.list <- list(graph2, graph2)
53
class(graph1.list) <- class(graph2.list) <- 'list.igraph'
54
55
res <- combine_layers(graph1 = graph1.list, 
56
                      graph2 = graph2)
57
res <- combine_layers(graph1 = graph1.list, 
58
                      graph2 = graph2.list)
59
60
# with interaction dataframe
61
interaction.df1 <- as.data.frame(list(from = c('C', 'B'), to = c(1, 2)))
62
res <- combine_layers(graph1 = graph1.list, 
63
                      graph2 = graph2, 
64
                      interaction.df = interaction.df1)
65
66
67
}