跳到内容

在加权图中,每个(有向或无向)边都会分配一个实数。

用法

is_weighted(graph)

参数

graph

输入图。

一个逻辑标量。

详细信息

在igraph中,边的权重通过一个名为“weight”的边属性来表示。is_weighted()函数仅检查是否存在这样的属性。(它甚至不检查它是否是一个数值边属性。)

边的权重被不同的函数用于不同的目的。例如,最短路径函数将其用作路径的成本;社群发现方法将其用作两个顶点之间关系的强度,等等。有关详细信息,请查看处理加权图的函数的手册页。

作者

Gabor Csardi csardi.gabor@gmail.com

示例


g <- make_ring(10)
shortest_paths(g, 8, 2)
#> $vpath
#> $vpath[[1]]
#> + 5/10 vertices, from 2f7edba:
#> [1]  8  9 10  1  2
#> 
#> 
#> $epath
#> NULL
#> 
#> $predecessors
#> NULL
#> 
#> $inbound_edges
#> NULL
#> 
E(g)$weight <- seq_len(ecount(g))
shortest_paths(g, 8, 2)
#> $vpath
#> $vpath[[1]]
#> + 7/10 vertices, from 2f7edba:
#> [1] 8 7 6 5 4 3 2
#> 
#> 
#> $epath
#> NULL
#> 
#> $predecessors
#> NULL
#> 
#> $inbound_edges
#> NULL
#>