图的密度是指图中实际边数与图中可能的最大边数之比,假设不存在多重边。
参考文献
Wasserman, S., and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge: Cambridge University Press.
参见
vcount()
, ecount()
, simplify()
用于消除多重边和/或环边。
其他结构属性:bfs()
, component_distribution()
, connect()
, constraint()
, coreness()
, degree()
, dfs()
, distance_table()
, feedback_arc_set()
, feedback_vertex_set()
, girth()
, is_acyclic()
, is_dag()
, is_matching()
, k_shortest_paths()
, knn()
, reciprocity()
, subcomponent()
, subgraph()
, topo_sort()
, transitivity()
, unfold_tree()
, which_multiple()
, which_mutual()
作者
Gabor Csardi csardi.gabor@gmail.com
示例
edge_density(make_empty_graph(n = 10)) # empty graphs have density 0
#> [1] 0
edge_density(make_full_graph(n = 10)) # complete graphs have density 1
#> [1] 1
edge_density(sample_gnp(n = 100, p = 0.4)) # density will be close to p
#> [1] 0.3935354
# loop edges
g <- make_graph(c(1, 2, 2, 2, 2, 3)) # graph with a self-loop
edge_density(g, loops = FALSE) # this is wrong!!!
#> [1] 0.5
edge_density(g, loops = TRUE) # this is right!!!
#> [1] 0.3333333
edge_density(simplify(g), loops = FALSE) # this is also right, but different
#> [1] 0.3333333