ego

0th

Percentile

Neighborhood of graph vertices

These functions find the vertices not farther than a given limit from another fixed vertex, these are called the neighborhood of the vertex.

Keywords
graphs
Usage
ego(graph, order, nodes = V(graph), mode = c("all", "out", "in"),
  mindist = 0)

make_ego_graph(graph, order, nodes = V(graph), mode = c("all", "out", "in"), mindist = 0)

Arguments
graph
The input graph.
order
Integer giving the order of the neighborhood.
nodes
The vertices for which the calculation is performed.
mode
Character constatnt, it specifies how to use the direction of the edges if a directed graph is analyzed. For out only the outgoing edges are followed, so all vertices reachable from the source vertex in at most order steps ar
mindist
The minimum distance to include the vertex in the result.
Details

The neighborhood of a given order o of a vertex v includes all vertices which are closer to v than the order. Ie. order 0 is always v itself, order 1 is v plus its immediate neighbors, order 2 is order 1 plus the immediate neighbors of the vertices in order 1, etc.

ego_size calculates the size of the neighborhoods for the given vertices with the given order.

ego calculates the neighborhoods of the given vertices with the given order parameter.

make_ego_graph is creates (sub)graphs from all neighborhoods of the given vertices with the given order parameter. This function preserves the vertex, edge and graph attributes.

connect creates a new graph by connecting each vertex to all other vertices in its neighborhood.

Value

  • ego_size returns with an integer vector.

    ego returns with a list of integer vectors.

    make_ego_graph returns with a list of graphs.

    connect returns with a new graph object.

Aliases
  • connect
  • connect.neighborhood
  • ego
  • ego_graph
  • ego_size
  • graph.neighborhood
  • make_ego_graph
  • neighborhood
  • neighborhood.size
Examples
g <- make_ring(10)
ego_size(g, 0, 1:3)
ego_size(g, 1, 1:3)
ego_size(g, 2, 1:3)
ego(g, 0, 1:3)
ego(g, 1, 1:3)
ego(g, 2, 1:3)

# attributes are preserved
V(g)$name <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")
make_ego_graph(g, 2, 1:3)

# connecting to the neighborhood
g <- make_ring(10)
g <- connect(g, 2)
Documentation reproduced from package igraph, version 1.0.0, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.