sigmajs (version 0.1.1)

sg_nodes: Add nodes and edges

Description

Add nodes and edges to a sigmajs graph.

Usage

sg_nodes(sg, data, ...)

sg_edges(sg, data, ...)

sg_edges2(sg, data)

sg_nodes2(sg, data)

Arguments

sg

An object of class sigmajsas intatiated by sigmajs.

data

Data.frame (or list) of nodes or edges.

...

any column.

Functions

  • Functions ending in 2 take a list like the original sigma.js JSON.

  • Other functions take the arguments described above.

Details

Each node must include a unique id, ideally the user passes x and y, if they are not passed then they are randomly generated. Each edge also must include a unique id as well as two columns named source and target.

Examples

Run this code
# NOT RUN {
nodes <- sg_make_nodes()
edges <- sg_make_edges(nodes)

edges$type <- "arrow" # directed

sigmajs() %>%
  sg_nodes(nodes, id, label, size, color) %>%
  sg_edges(edges, id, source, target, type) 

# }

Run the code above in your browser using DataCamp Workspace