I am looking at a Twitter network of United States senators. I am looking to be able to select a senator (with nodeIdSelection) and only highlight the nodes connected to that selected node AND highlight only these connected edges (this is what I cannot figure out). I do not want edges between other connected nodes shown. When I set degree = 0, this gives me the result I am looking for in terms of only highlighting the connected edges, but the connected nodes (circles) are not shown.
visNetwork(nodes, edges) %>%
visIgraphLayout(layout = "layout_with_fr") %>%
visOptions(highlightNearest = list(enabled = TRUE, algorithm = "all",
degree = 0, hideColor = "rgba(0,0,0,0)"),
nodesIdSelection = TRUE) %>%
visInteraction(navigationButtons = TRUE)
This code gives me:
When I set degree = 1, the correct connected nodes are shown, but there are also secondary connected edges between other nodes NOT connected to the selected node also shown. Since there are 100 senators and over 2,000 connections, the plot is far too "busy" to visualize with these secondary connections shown.
visNetwork(nodes, edges) %>%
visIgraphLayout(layout = "layout_with_fr") %>%
visOptions(highlightNearest = list(enabled = TRUE, algorithm = "all",
degree = 1, hideColor = "rgba(0,0,0,0)"),
nodesIdSelection = TRUE) %>%
visInteraction(navigationButtons = TRUE)
This code gives me:
As you can see, the plot becomes far too busy. Is there a way to get the result shown with degree = 0 in terms of only showing edges connected to the selected node but also showing the connected nodes, too?
Thank you so much for any help. Sorry if the images are a bit hard to read. Thanks again.