Examples for 'igraph::ego_size'


Neighborhood of graph vertices

Aliases: ego_size ego neighborhood neighborhood.size graph.neighborhood ego_graph connect.neighborhood connect make_ego_graph

Keywords: graphs

### ** Examples


g <- make_ring(10)
ego_size(g, order = 0, 1:3)
[1] 1 1 1
ego_size(g, order = 1, 1:3)
[1] 3 3 3
ego_size(g, order = 2, 1:3)
[1] 5 5 5
ego(g, order = 0, 1:3)
[[1]]
+ 1/10 vertex, from cbed391:
[1] 1

[[2]]
+ 1/10 vertex, from cbed391:
[1] 2

[[3]]
+ 1/10 vertex, from cbed391:
[1] 3
ego(g, order = 1, 1:3)
[[1]]
+ 3/10 vertices, from cbed391:
[1]  1  2 10

[[2]]
+ 3/10 vertices, from cbed391:
[1] 2 1 3

[[3]]
+ 3/10 vertices, from cbed391:
[1] 3 2 4
ego(g, order = 2, 1:3)
[[1]]
+ 5/10 vertices, from cbed391:
[1]  1  2 10  3  9

[[2]]
+ 5/10 vertices, from cbed391:
[1]  2  1  3 10  4

[[3]]
+ 5/10 vertices, from cbed391:
[1] 3 2 4 1 5
# attributes are preserved
V(g)$name <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")
make_ego_graph(g, order = 2, 1:3)
[[1]]
IGRAPH 8a6e260 UN-- 5 4 -- Ring graph
+ attr: name (g/c), mutual (g/l), circular (g/l), name (v/c)
+ edges from 8a6e260 (vertex names):
[1] a--b b--c a--j i--j

[[2]]
IGRAPH dda0fc9 UN-- 5 4 -- Ring graph
+ attr: name (g/c), mutual (g/l), circular (g/l), name (v/c)
+ edges from dda0fc9 (vertex names):
[1] a--b b--c c--d a--j

[[3]]
IGRAPH 5fd42c1 UN-- 5 4 -- Ring graph
+ attr: name (g/c), mutual (g/l), circular (g/l), name (v/c)
+ edges from 5fd42c1 (vertex names):
[1] a--b b--c c--d d--e
# connecting to the neighborhood
g <- make_ring(10)
g <- connect(g, 2)

[Package igraph version 1.3.1 Index]