adj <- matrix(c(0, 1, 1, 1, 0, 1, 1, 1, 0), nrow = 3)
# Apply palette to nodes
cograph(adj) |> sn_palette("viridis") |> splot()
# Apply to edges
cograph(adj) |> sn_palette("colorblind", target = "edges") |> splot()
# Apply to both
cograph(adj) |> sn_palette("pastel", target = "both") |> splot()
# Custom palette function
my_pal <- function(n) rainbow(n, s = 0.7)
cograph(adj) |> sn_palette(my_pal) |> splot()
# Direct matrix input
adj |> sn_palette("viridis")
Run the code above in your browser using DataLab