
Last chance! 50% off unlimited learning
Sale ends in
graph.intersection(..., byname = "auto", keep.all.vertices = TRUE)
auto
. Whether to perform the operation based on symbolic
vertex names. If it is auto
, that means TRUE
if all
graphs are named and FALSE
otherwise. A graph.intersection
creates the intersection of two or more
graphs: only edges present in all graphs will be included.
The corresponding operator is %s%. If the byname
argument is TRUE
(or auto
and all
graphs are named), then the operation is performed on symbolic vertex
names instead of the internal numeric vertex ids.
graph.intersection
keeps the attributes of all graphs. All
graph, vertex and edge attributes are copied to the result. If an
attribute is present in multiple graphs and would result a name clash,
then this attribute is renamed by adding suffixes: _1, _2, etc.
The name
vertex attribute is treated specially if the operation
is performed based on symbolic vertex names. In this case name
must be present in all graphs, and it is not renamed in the result
graph.
An error is generated if some input graphs are directed and others are undirected.
## Common part of two social networks
net1 <- graph.formula(D-A:B:F:G, A-C-F-A, B-E-G-B, A-B, F-G,
H-F:G, H-I-J)
net2 <- graph.formula(D-A:F:Y, B-A-X-F-H-Z, F-Y)
str(net1 %s% net2)
Run the code above in your browser using DataLab