Title: | Write graph objects to a file format that gephi understands |
---|---|
Description: | Sometimes you want to visualize your graph information in 'gephi'. 'Gephi' needs certain column names to make sense of the file. This package writes edge and node information to csv files with correct names so you can read it in easily with gephi. You can also read the files in with igraph/tidygraph. It makes it much easier to switch between R and 'gephi'. This R-package does not interface with the open source network visualisation tool 'gephi' but it writes and reads csv files in a way that 'gephi' expects, reducing the friction when switching between tools. |
Authors: | Roel M. Hogervorst [cre, aut] |
Maintainer: | Roel M. Hogervorst <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2025-01-20 02:54:42 UTC |
Source: | https://github.com/RMHogervorst/gephi |
Make your workflow with network data easier. The gephi package does not interface with the open source network visualisiation software 'gephi' but only writes csv files in a format that can be easily read by 'gephi'.
Network science is a broad field with many practicitioners who, unfortunately don't use the same languge to describe the same things. A graph is a network, not to be confused with graphics, or a graph like a scatterplot or line chart. A network (known as graph) consists of points (known as vertices or nodes ) and connections between them (known as vertices, links or edges). The gephi network visualisation tool uses edges and nodes as description, igraph talks about graphs G(), vertices V() and edges E(), tidygraph talks about edges and nodes. We don't care as long as we can work with it.
This function reads in an edges csv file exported from gephi into igraph.
gephi_read_edges_csv( path, source = "Source", target = "Target", directed = TRUE )
gephi_read_edges_csv( path, source = "Source", target = "Target", directed = TRUE )
path |
The file where to read from e.g.: edges.csv or data/edges.csv |
source |
What column is the source, defaults to 'Source'. |
target |
What column is the target, defaults to 'Target'. |
directed |
is the graph directed or not? defaults to TRUE. |
If you have a dataframe that represents a graph and you don't want to turn it into an igraph/tidygraph object first, this function will turn it into a csv. Give the column name where the edges start and the column name of the edge end. If you don't specify it, this function expects the first column to be a the start and second column the end point of an edge.
gephi_write_edges_from_df( dataframe, from = NULL, to = NULL, path, na = "", verbose = TRUE )
gephi_write_edges_from_df( dataframe, from = NULL, to = NULL, path, na = "", verbose = TRUE )
dataframe |
which dataframe |
from |
which column does the edge start |
to |
which column does the edge end |
path |
The file where to save to e.g.: edges.csv or data/edges.csv |
na |
How to record missing values, defaults to "", nothing / empty values |
verbose |
by default these functions are chatty and will tell you what they do if you do not want that, set to FALSE |
invisible original object so you could continue using it in a pipe if you want to
Other write_graphs:
gephi_write_nodes()
write_nodes will write the nodes, and write_edges will write the edges to a csv file. You will alway want to use the write_edges function, the write nodes function has only added value if the nodes have attributes, such as Label, Age, color etc.
gephi_write_nodes(graph, path, na = "", verbose = TRUE) gephi_write_edges(graph, path, na = "", verbose = TRUE) gephi_write_both(graph, pathedges, pathnodes, na = "", verbose = TRUE)
gephi_write_nodes(graph, path, na = "", verbose = TRUE) gephi_write_edges(graph, path, na = "", verbose = TRUE) gephi_write_both(graph, pathedges, pathnodes, na = "", verbose = TRUE)
graph |
The igraph or tidygraph object your work with |
path |
The file where to save to e.g.: edges.csv or data/edges.csv |
na |
How to record missing values, defaults to "", nothing / empty values |
verbose |
by default these functions are chatty and will tell you what they do if you do not want that, set to FALSE |
pathedges |
where to save the edges file e.g.: 'edges.csv' |
pathnodes |
where to save the nodes file e.g.: 'nodes.csv' |
If the file is not an igraph / tidygraph object, but a dataframe you could use the write_*_from_df functions. This function will assume the edges are between the first and second column, but you can specify if that is not the case.
invisible original object so you could continue using it in a pipe if you want to
gephi_write_edges
: Write nodes data to csv
gephi_write_both
: Write both node and edge data away
Other write_graphs:
gephi_write_edges_from_df()
I created this file to show off and test some functions.
graphexample
graphexample
An object of class igraph
of length 5.