0

我有一个library(network)对象,其中两个节点之间有 5 条边,我想将它展平为只有 1 条边。我怎样才能做到这一点?

奇怪的是,在网络属性中它说不允许多个边(FALSE):

 Network attributes:
  vertices = 2 
  directed = TRUE 
  hyper = FALSE 
  loops = TRUE 
  multiple = FALSE 
  bipartite = FALSE 
  total edges= 5 
    missing edges= 0 
    non-missing edges= 5 

 Vertex attribute names: 
    vertex.names 

这是dput()

> dput(graph_objects$`2115`)
structure(list(mel = list(structure(list(inl = 1L, outl = 2L, 
atl = structure(list(na = FALSE), .Names = "na")), .Names = c("inl", 
"outl", "atl")), structure(list(inl = 2L, outl = 1L, atl = structure(list(
na = FALSE), .Names = "na")), .Names = c("inl", "outl", "atl"
)), structure(list(inl = 2L, outl = 2L, atl = structure(list(
na = FALSE), .Names = "na")), .Names = c("inl", "outl", "atl"
)), structure(list(inl = 2L, outl = 2L, atl = structure(list(
na = FALSE), .Names = "na")), .Names = c("inl", "outl", "atl"
)), structure(list(inl = 1L, outl = 2L, atl = structure(list(
na = FALSE), .Names = "na")), .Names = c("inl", "outl", "atl"
))), gal = structure(list(n = 2, mnext = 6L, directed = TRUE, 
hyper = FALSE, loops = TRUE, multiple = FALSE, bipartite = FALSE), .Names = c("n", 
"mnext", "directed", "hyper", "loops", "multiple", "bipartite"
)), val = list(structure(list(na = FALSE, vertex.names = "dbussink"), .Names = c("na", 
"vertex.names")), structure(list(na = FALSE, vertex.names = "sdaubert"), .Names = c("na", 
"vertex.names"))), iel = list(c(5L, 1L), c(4L, 3L, 2L)), oel = list(
2L, c(4L, 5L, 3L, 1L))), .Names = c("mel", "gal", "val", 
"iel", "oel"), class = "network")
4

1 回答 1

0

使用delete.edges方法按 ID 删除边。

delete.edges(nt2, 2:5)

  #  Network attributes:
  #   vertices = 2
  #   directed = TRUE
  #   hyper = FALSE
  #   loops = TRUE
  #   multiple = FALSE
  #   bipartite = FALSE
  #   total edges= 1
  #     missing edges= 0
  #     non-missing edges= 1
  #
  #  Vertex attribute names:
  #     vertex.names
  #
  # No edge attributes
于 2014-04-03T01:10:00.283 回答