A network-aware select_point() preset for vgraph() plots: pointing at (or
clicking) a node selects its neighbourhood — the node, its incident edges,
and its adjacent nodes — so a host spotlights them and dims the rest. Pointing
at an edge highlights the edge and its two endpoint nodes. It builds on the
node/edge identity vgraph() emits for an interactive plot (each node keyed by
its vertex name, each edge carrying its endpoint names); the host
reconstructs the adjacency and projects the gesture across it.
Usage
select_neighbours(
plot,
name = "neighbours",
on = c("hover", "click"),
degree = 1L,
edges = TRUE,
empty = TRUE
)Arguments
- plot
A PlotSpec, normally from
vgraph()(piped form), or a selection name string (free-standing form).- name
The selection name. Defaults to
"neighbours".- on
The gesture:
"hover"(default) or"click".- degree
How many hops out from the pointed node to include (
1, the default, is the immediate neighbourhood;2adds neighbours-of-neighbours).- edges
Whether to include the incident edges in the highlight (
TRUE, default) or only the nodes.- empty
Whether an empty selection matches all elements (
TRUE, default — an un-hovered graph shows its full self) or none.
Value
A PlotSpec (piped form) or a SelectionSpec (free-standing form).
Details
Like the other selections it is inert on a static render and enacted by a
capable host (vellumwidget). On its own it spotlights the neighbourhood; pair
it with condition() to restyle members explicitly, or filter_by() to show
only the neighbourhood.
Examples
if (FALSE) { # \dontrun{
g <- igraph::make_graph("Zachary")
vgraph(g) |>
mark_edges() |>
mark_nodes(size = 3) |>
select_neighbours(on = "hover")
} # }
