Hide non selected visNetwork nodes in R

257 Views Asked by At

I am struggling with how to hide non selected nodes and edges in my visNetwork. I thought that using the hideColor option in highlightNearest would work. My goal is to hide the nodes and edges that are not connected to the selected node. Is there options or a configuration to hide nodes and edges that are not connected to the selected node based on the degree identified in the options?

visNetwork::visNetwork(table_nodes, table_edges) %>%
  visOptions(highlightNearest = list(enabled = TRUE,
                                     degree = 3,
                                     hover = TRUE,
                                     hideColor = 'rgba(255,255,255,0)'),
    nodesIdSelection = list(enabled = TRUE,
                            values = c(as.character(table_nodes$id)),
                            selected = "2")
    ) %>%
  visLayout(randomSeed = 1999) %>%
  visPhysics(stabilization = FALSE) %>%
  visEdges(smooth = FALSE)

network with selection option

0

There are 0 best solutions below