Add nodes and edges to a
sg_nodes(sg, data, ...) sg_edges(sg, data, ...) sg_edges2(sg, data) sg_nodes2(sg, data)
An object of class
Data.frame (or list) of nodes or edges.
Any column name, see details.
color is omitted than specify
sg_settings otherwise nodes will be transparent. Ideally nodes
if they are not passed then they are randomly generated, you can either get these coordinates with
Each edge also must include a unique
id as well as two columns named
target which correspond to
ids. If an edges goes from or to an
id that is not in node
node also takes a SharedData.
Functions ending in
2 take a list like the original sigma.js JSON.
Other functions take the arguments described above.
nodes <- sg_make_nodes() edges <- sg_make_edges(nodes) sigmajs() %>% sg_nodes(nodes, id, label, size, color) %>% sg_edges(edges, id, source, target) # directed graph edges$type <- "arrow" # directed # omit color sigmajs() %>% sg_nodes(nodes, id, label, size) %>% sg_edges(edges, id, source, target, type) %>% sg_settings(defaultNodeColor = "#141414") # all source and target are present in node ids all(c(edges$source, edges$target) %in% nodes$id)#>  TRUE