Skip to content

Assigning a symmetric sociomatrix valued edges to an undriected network creates bidirectional edges. #92

@krivit

Description

@krivit
library(network)

nwu <- network.initialize(4, directed=FALSE)
nwu[,,names.eval="w",add.edges=TRUE] <-
  matrix(c(0,1,2,0,
           1,0,1,3,
           2,1,0,0,
           0,3,0,0),
         4,4,
         byrow=TRUE)
nwu
#>  Network attributes:
#>   vertices = 4 
#>   directed = FALSE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 8 
#>     missing edges= 0 
#>     non-missing edges= 8 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#>  Edge attribute names: 
#>     w
as.matrix(nwu, matrix.type = "edgelist")
#>      [,1] [,2]
#> [1,]    2    1
#> [2,]    3    1
#> [3,]    1    2
#> [4,]    3    2
#> [5,]    4    2
#> [6,]    1    3
#> [7,]    2    3
#> [8,]    2    4
#> attr(,"n")
#> [1] 4
#> attr(,"vnames")
#> [1] 1 2 3 4

Created on 2025-03-03 with reprex v2.1.1

Without names.eval, only 4 edges are created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions