Skip to content

is_symmetric() trips graph_from_adjacency_matrix() on a matrix with dimnames #2671

@mbojan

Description

@mbojan

What happens, and what did you expect instead?

graph_from_adjacency_matrix() trips if matrix has dimnames. I think they could be safely ignored. In other words, is_symmetric() might be too strict.

To reproduce

library(igraph)

m <- matrix(
  c(0, 1, 1, 0),
  2, 2,
  dimnames=list(r=1:2, c=1:2)
)

graph_from_adjacency_matrix(m, mode = "undirected") # warning because this is FALSE:
isSymmetric(m)

# I believe atrtibutes could be safely ignored:
isSymmetric(m, check.attributes = FALSE) # Uses all.equal() internally

System information

─ Session info ─────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.6.0 (2026-04-24)
 os       Ubuntu 24.04.4 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language en
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Warsaw
 date     2026-05-26
 rstudio  2026.04.0+526 Globemaster Allium (desktop)
 pandoc   3.1.3 @ /usr/bin/pandoc
 quarto   1.9.37 @ /usr/local/bin/quarto

─ Packages ─────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 cli           3.6.6   2026-04-09 [1] CRAN (R 4.6.0)
 igraph      * 2.3.1   2026-05-04 [1] CRAN (R 4.6.0)
 lifecycle     1.0.5   2026-01-08 [1] CRAN (R 4.6.0)
 magrittr      2.0.5   2026-04-04 [1] CRAN (R 4.6.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.6.0)
 rlang         1.2.0   2026-04-06 [1] CRAN (R 4.6.0)
 rstudioapi    0.18.0  2026-01-16 [1] CRAN (R 4.6.0)
 sessioninfo   1.2.3   2025-02-05 [1] CRAN (R 4.6.0)

 [1] /home/mbojan/R/library/4.6
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library
 * ── Packages attached to the search path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions