neighbors: Neighboring (adjacent) vertices in a graph

Description Usage Arguments Value See Also Examples

View source: R/interface.R

Description

A vertex is a neighbor of another one (in other words, the two vertices are adjacent), if they are incident to the same edge.

Usage

1
neighbors(graph, v, mode = c("out", "in", "all", "total"))

Arguments

graph

The input graph.

v

The vertex of which the adjacent vertices are queried.

mode

Whether to query outgoing (‘out’), incoming (‘in’) edges, or both types (‘all’). This is ignored for undirected graphs.

Value

A vertex sequence containing the neighbors of the input vertex.

See Also

Other structural queries: [.igraph(), [[.igraph(), adjacent_vertices(), are_adjacent(), ends(), get.edge.ids(), gorder(), gsize(), head_of(), incident_edges(), incident(), is_directed(), tail_of()

Examples

1
2
3
4
g <- make_graph("Zachary")
n1 <- neighbors(g, 1)
n34 <- neighbors(g, 34)
intersection(n1, n34)

Example output

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

+ 4/34 vertices, from 0000000:
[1]  9 14 20 32

igraph documentation built on Nov. 24, 2021, 1:06 a.m.

Related to neighbors in igraph...