I need to produce a network graph where (A) some nodes are a subcategory of other nodes, (B) some nodes are considered equivalent to other nodes, and (C) some nodes are specifically highlighted as being especially distinct from other nodes. Edges showing relationship A might have a uni-directional arrow (i.e., an arrowhead at only one end of the edge). Edges showing relationship B might have bi-directional arrows (i.e., an arrowhead at each end of the edge), or might have no arrowheads at all. Edges showing relationship C might be shown in a distinct color, or might be dashed, or might have opposing arrowheads along the edge, etc. For the sake of argument, let’s say that for relationships of type B I wanted an arrowhead at each end of the relevant edge. How would I go about doing that with visNetwork
?
Simon Larson previously answered a similar question in the sole response to this post. He proposed setting individual arrow types in the edges
data frame by adding columns arrows.to.type
and arrows.from.type
, as shown in the following example:
library(visNetwork)
library(magrittr)
nodes <- data.frame(id=c("a","b","c","d"), label=c("a","b","c","d"))
edges <- data.frame(
from = c("a","a","a"),
to = c("b","c","d"),
arrows.from.type = c(NA,"circle","circle"),
arrows.to.type = c("arrow","circle",NA)
)
visNetwork(nodes, edges)
In his response, the above code produced this network graph, which has the expected arrows and circles at the edge end-points:
enter image description here
When I run the above code, I get the following network graph, which has no arrows or circles at the edge end-points:
enter image description here
Any idea why I’m not getting the desired result? Additionally, I’d be open to hearing other means of graphing the types of relationships I described, though I’d still be grateful to figure out how to show the bi-directional edge.
jbowerbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.