| export_graph | R Documentation |
Exports a PageRank result and its edge list as a graph file suitable for visualization in external tools (Gephi, yEd, Graphviz, etc.). Supports GraphML, GEXF (via GraphML with attributes), DOT, and edge list CSV formats.
export_graph(
pagerank_df,
edge_list_df,
file,
format = c("graphml", "dot", "edgelist", "pajek"),
edge_from_col = "from",
edge_to_col = "to",
pr_url_col = "node_name",
pr_score_col = "pagerank",
node_attrs = NULL,
edge_attrs = NULL
)
pagerank_df |
A data frame with at least |
edge_list_df |
A data frame of edges with from/to columns. |
file |
Character, path to the output file. |
format |
Character, output format. One of |
edge_from_col, edge_to_col |
Names of from/to columns in
|
pr_url_col |
Name of the URL column in |
pr_score_col |
Name of the PageRank score column. Default
|
node_attrs |
Optional named list of additional vertex attribute columns
from |
edge_attrs |
Optional character vector of additional columns from
|
The file path (invisibly). Called for its side effect of writing a file.
edges <- data.frame(
from = c("A", "B", "C"),
to = c("B", "C", "A")
)
pr <- pagerank(edges, clean_edge_urls = FALSE)
# Export to GraphML (for Gephi)
tmp <- tempfile(fileext = ".graphml")
export_graph(pr, edges, file = tmp, format = "graphml")
# Export as DOT (for Graphviz)
tmp_dot <- tempfile(fileext = ".dot")
export_graph(pr, edges, file = tmp_dot, format = "dot")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.