Graph
Description
Initialise a grapher graph.
Usage
graph(
  data = NULL,
  directed = TRUE,
  draw = TRUE,
  width = "100%",
  height = NULL,
  elementId = NULL
)
Arguments
| Argument | Description | 
|---|---|
| data | A named listcontainingnodesandlinkswhere the former's first column are the node ids and the latter's first and second columns are source and target, every other column is added as respective meta-data. Can also be an object of classigraphfrom the igraph package or an object of classtbl_graphfrom the tidygraph package. If a character string is passed the string is assumed to be the path to either a.gexffile or a.gvdot file . The thrid file type acceted is JSON, it must be the output ofsave_graph_json. If adata.frameis passed it is assumed to be links where the first column indicates the source, and the second the target of the links. This argument can also be of classgraphframefrom the https://spark.rstudio.com/graphframes/ package. IfNULLdata must be later supplied withgraph_nodesandgraph_links. | 
| directed | Whether the graph is directed, if passing an object of class igraphtodatathen this is inferred from the object. | 
| draw | If FALSEthe graph is not rendered. | 
| width, height | Must be a valid CSS unit (like '100%','400px','auto') or a number, which will be coerced to a string and have'px'appended. | 
| elementId | Id of element. | 
Details
if the variables x , y , and z
are included in the nodes the rendered visualisation
is stable 2/3 dimensional and the force layout algorithm is not run.
See Also
graph_nodes and graph_links to add nodes and links.
Examples
g <- make_data() # mock data
# from a list
graph(g)
# from igraph
ig <- igraph::make_ring(10)
graph(ig)
# from tidygraph
tbl_graph <- tidygraph::create_ring(20)
graph(tbl_graph)
# from gexf
graph("http://gephi.org/datasets/LesMiserables.gexf")
# from dot file
fl <- system.file("example/dotfile.gv", package = "grapher")
graph(fl)
# from single data.frame
# assumes edges
graph(g$links)
# from data.frames
# pass only links
graph() %>%
graph_links(g$links, source, target)
# pass nodes and links
graph() %>%
graph_nodes(g$nodes, id) %>%
graph_links(g$links, source, target)