Changing attribute values of nodes in a network during breadth first search in R

倾然丶 夕夏残阳落幕 提交于 2019-12-04 19:53:33

Try this:

for (i in 1:100) {
    if (is.nan(bfs$dist[i]) == FALSE) {
        V(graph)$value[i] = 1 - V(graph)$value[i]
    }
}

It basically just checks if a node is connected to the root node. If it is, its attribute value is changed to 1, and if it isn't, then its attribute value remains unchanged.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!