Find vertices without any predecessor/ingoing edges in igraph R

Viewed 564

How can I get the vertices that don't have any predecessor in the graph. For example, this is the graph data:

lfs = data.table( from = c('x', 'x', 'y'), to = c('y', 'p', 'z'))
lfs
#  from to
#:    x  y
#:    x  p
#:    y  z
g = graph_from_data_frame(lfs)
g
# IGRAPH DN-- 4 3 --
# + attr: name (v/c)
# + edges (vertex names):
# [1] x->y x->p y->z

In this graph x does not have any predecessor. Is there any query function to get such vertices easily?

1 Answers
Related