The focus()
/unfocus()
idiom allow you to temporarily tell tidygraph
algorithms to only calculate on a subset of the data, while keeping the full
graph intact. The purpose of this is to avoid having to calculate time
costly measures etc on all nodes or edges of a graph if only a few is needed.
E.g. you might only be interested in the shortest distance from one node to
another so rather than calculating this for all nodes you apply a focus on
one node and perform the calculation. It should be made clear that not all
algorithms will see a performance boost by being applied to a few nodes/edges
since their calculation is applied globally and the result for all
nodes/edges are provided in unison.
focus(.data, ...)# S3 method for tbl_graph
focus(.data, ...)
# S3 method for morphed_tbl_graph
focus(.data, ...)
unfocus(.data, ...)
# S3 method for tbl_graph
unfocus(.data, ...)
# S3 method for focused_tbl_graph
unfocus(.data, ...)
# S3 method for morphed_tbl_graph
unfocus(.data, ...)
A graph with focus applied
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details.
<data-masking
> Expressions that
return a logical value, and are defined in terms of the variables in
.data
. If multiple expressions are included, they are combined with the
&
operator. Only rows for which all conditions evaluate to TRUE
are
kept.