neighbors | R Documentation |

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

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

`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. |

A vertex sequence containing the neighbors of the input vertex.

Other structural queries:
`[.igraph()`

,
`[[.igraph()`

,
`adjacent_vertices()`

,
`are_adjacent()`

,
`ends()`

,
`get.edge.ids()`

,
`gorder()`

,
`gsize()`

,
`head_of()`

,
`incident_edges()`

,
`incident()`

,
`is_directed()`

,
`tail_of()`

```
g <- make_graph("Zachary")
n1 <- neighbors(g, 1)
n34 <- neighbors(g, 34)
intersection(n1, n34)
```

igraph documentation built on Aug. 10, 2023, 9:08 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.