Skip to contents

Basic query operations to get adjacency

Usage

edge(graph, eid)

neighbors(graph, vid, mode = 3L, loops = 1L, multiple = TRUE)

incident(graph, vid, mode = 3L, loops = 1L)

degree(graph, vids = integer(0), mode = 3L, loops = 1L)

Arguments

graph

An igraph_ptr object.

eid

An integer value of edge ID.

vid

An integer value of vertex ID.

mode

An integer value of edge type to count; {1: OUT, 2: IN, 3: ALL}.

loops

whether self-loop should be counted.

multiple

A logical value, whether to keep multiple (parallel) edges.

vids

An integer vector of vertex IDs.

Value

edge() returns the head and tail vertices of an edge.

neighbors() returns the adjacent vertices to a vertex.

incident() returns the incident edges of a vertex.

degree() returns the degrees of vertices in a graph.

See also

as_adjlist() and as_inclist() for the all-vertices version of neighbors() and incident().

is_sink(), is_source(), Vsink(), Vsource() for shortcuts to get zero-degree vertices.

Examples

g = graph_tree(5L)
edge(g, 1L)
#> [1] 1 2
neighbors(g, 1L)
#> [1] 2 3
incident(g, 1L)
#> [1] 1 2
degree(g, mode = 1L)
#> [1] 2 2 0 0 0
degree(g, mode = 2L)
#> [1] 0 1 1 1 1
degree(g, mode = 3L)
#> [1] 2 3 1 1 1