Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge Labels in VisNetwork? #460

Open
swaheera opened this issue Apr 28, 2023 · 0 comments
Open

Edge Labels in VisNetwork? #460

swaheera opened this issue Apr 28, 2023 · 0 comments

Comments

@swaheera
Copy link

I am working with the R programming language.

I generated this random network graph and matrix:

library(tidyverse)
library(visNetwork)
library(htmlwidgets)


set.seed(123)
mat <- matrix(runif(19*20), nrow = 19, ncol = 20)
mat <- t(apply(mat, 1, function(x) x/sum(x)))
mat <- rbind(mat, c(rep(0, 19), 1))


nodes <- data.frame(id = 1:20)
edges <- data.frame(from = sample(1:20, 100, replace = TRUE), to = sample(1:20, 100, replace = TRUE))

nodes$shape <- 'circle'
edges$weight <- apply(edges, 1, function(x) mat[x["from"], x["to"]])

# create the network graph
network <- visNetwork(nodes, edges) %>%
    visEdges(arrows = list(to = list(enabled = TRUE))) %>%
    visIgraphLayout(layout = "layout_in_circle")

Now, I am trying to add the labels (i.e. the decimal numbers) from this matrix to each corresponding edge on this graph (i.e. edges$weight)

Can someone please show me how to do this?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant