Basic query operations to get adjacency
Usage
edge(graph, eid)
neighbors(graph, vid, mode = 3L)
incident(graph, vid, mode = 3L)
degree(graph, vids = integer(0), mode = 3L, loops = TRUE)
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}.
- vids
An integer vector of vertex IDs.
- loops
whether self-loop should be counted.
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