Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

does `as.sna.edgelist = TRUE` argument to `as.edgelist` behave as intended?

Open
#71 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by running the supplied R example and inspect as.edgelist.matrix and as.matrix.network.edgelist, focusing on how as.sna.edgelist is handled. Done when as.edgelist(..., TRUE) produces the intended SNA edge representation while the FALSE behavior remains unchanged.

Written by the indexing model from the issue text.

Description

e.g.

require(network)
nw <- network.initialize(2, directed = FALSE)
nw[1,2] <- 1
as.matrix.network.edgelist(nw, as.sna.edgelist = FALSE)
as.matrix.network.edgelist(nw, as.sna.edgelist = TRUE)
as.edgelist(nw, as.sna.edgelist = FALSE)
as.edgelist(nw, as.sna.edgelist = TRUE)

produces

> as.matrix.network.edgelist(nw, as.sna.edgelist = FALSE)
     [,1] [,2]
[1,]    1    2
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
> as.matrix.network.edgelist(nw, as.sna.edgelist = TRUE)
     [,1] [,2] [,3]
[1,]    1    2    1
[2,]    2    1    1
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
> as.edgelist(nw, as.sna.edgelist = FALSE)
     [,1] [,2]
[1,]    1    2
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
attr(,"directed")
[1] FALSE
attr(,"bipartite")
[1] FALSE
attr(,"loops")
[1] FALSE
attr(,"class")
[1] "matrix_edgelist" "edgelist"        "matrix"          "array"          
> as.edgelist(nw, as.sna.edgelist = TRUE)
     [,1] [,2] [,3]
[1,]    1    2    1
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
attr(,"directed")
[1] FALSE
attr(,"bipartite")
[1] FALSE
attr(,"loops")
[1] FALSE
attr(,"class")
[1] "matrix_edgelist" "edgelist"        "matrix"          "array"          

i.e. the screening of edges in as.edgelist.matrix (which does not receive or recognize as.sna.edgelist in the current implementation) is dropping the "reversed" edge 2 1 from the output when as.sna.edgelist = TRUE is passed to as.edgelist, which seems like not what we want for sna (based on the behavior of as.matrix.network.edgelist).

Dominant language
R
Stars
20
Forks
7
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from statnet/network

All issues in statnet/network

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.