Gaining information about graph structure
Functions for exploring the basic structure of a network: number of vertices and edges, the neighbors of a node, test whether two vertices are connected by an edge.
vcount(graph) ecount(graph) neighbors(graph, v, mode = 1) is.directed(graph) are.connected(graph, v1, v2) get.edge(graph, id) get.edges(graph, es)
- The graph.
- The vertex of which the neighbors are queried.
- Character string, specifying the type of neighboring
vertices to list in a directed graph. If
outthe vertices to which an edge exist are listed, if inthe vertices from which an edge is dire
- The id of the first vertex. For directed graphs only edges
- The id of the second vertex. For directed graphs only edges
- A numeric edge id.
- An edge sequence.
These functions provide the basic structural information of a graph.
vcount gives the number of vertices in the graph.
ecount gives the number of edges in the graph.
neighbors gives the neighbors of a vertex. The vertices
connected by multiple edges are listed as many times as the number of
is.directed gives whether the graph is directed or not. It just
are.connected decides whether there is an edge from
get.edge returns the end points of the edge with the supplied
edge id. For directed graph the source vertex comes first, for
undirected graphs, the order is arbitrary.
get.edges returns a matrix with the endpoints of the edges in
the edge sequence argument.
ecountreturn integer constants.
neighborsreturns an integer vector.
are.connectedreturn boolean constants.
get.edgereturns a numeric vector of length two.
get.edgesreturns a two-column matrix.
g <- graph.ring(10) vcount(g) ecount(g) neighbors(g, 5) are.connected(g, 1, 2) are.connected(g, 2, 4) get.edges(g, 0:5)