The degree of a vertex is its most basic structural property, the number of its adjacent edges.
The graph to analyze.
The ids of vertices of which the degree will be calculated.
Character string, “out” for out-degree, “in” for in-degree or “total” for the sum of the two. For undirected graphs this argument is ignored. “all” is a synonym of “total”.
Logical; whether the loop edges are also counted.
Logical scalar, whether to normalize the degree. If
TRUE
then the result is divided by \(n-1\), where \(n\) is the
number of vertices in the graph.
These dots are for future extensions and must be empty.
Logical; whether the cumulative degree distribution is to be calculated.
For degree()
a numeric vector of the same length as argument
v
.
For degree_distribution()
a numeric vector of the same length as the
maximum degree plus one. The first element is the relative frequency zero
degree vertices, the second vertices with degree one, etc.
For max_degree()
, the largest degree in the graph. When no vertices are
selected, or when the input is the null graph, zero is returned as this
is the smallest possible degree.
Other structural.properties:
bfs()
,
component_distribution()
,
connect()
,
constraint()
,
coreness()
,
dfs()
,
distance_table()
,
edge_density()
,
feedback_arc_set()
,
girth()
,
is_acyclic()
,
is_dag()
,
is_matching()
,
k_shortest_paths()
,
knn()
,
reciprocity()
,
subcomponent()
,
subgraph()
,
topo_sort()
,
transitivity()
,
unfold_tree()
,
which_multiple()
,
which_mutual()
g <- make_ring(10)
degree(g)
#> [1] 2 2 2 2 2 2 2 2 2 2
g2 <- sample_gnp(1000, 10 / 1000)
max_degree(g2)
#> [1] 22
degree_distribution(g2)
#> [1] 0.001 0.000 0.002 0.005 0.026 0.038 0.058 0.101 0.118 0.117 0.118 0.113
#> [13] 0.098 0.081 0.057 0.027 0.019 0.010 0.004 0.004 0.000 0.002 0.001