79659598

Date: 2025-06-09 22:42:31
Score: 1.5
Natty:
Report link

Working off @kaedonkers and @knapply's examples above, as well as @Bryan Shalloway's comment that these didn't work when specifying a base color for edges, I backed into the solution over here, with the key being the algorithm and bidirectional degree specifications within highlightNearest

library(igraph)
g <- graph("Zachary")

library(visNetwork)
vis_g <- toVisNetworkData(g)

visNetwork(vis_g$nodes, vis_g$edges) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visNodes(color = "blue") %>%
  visEdges(color="blue") %>% # this causes prior solutions to not work
  visOptions(highlightNearest = list(enabled = TRUE,
                                     labelOnly = FALSE, hover = TRUE,
                                     # but these two options fix it
                                     algorithm="hierarchical",
                                     degree=list(from=1, to=1)
                                     ),
             nodesIdSelection = list(selected = 6))

Giving us this:

Network with subset of nodes highlighted

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @and
  • User mentioned (0): @Bryan
  • Low reputation (0.5):
Posted by: bcarothers