gexf-class: Creates an object of class 'gexf'

gexf-classR Documentation

Creates an object of class gexf

Description

Takes a node matrix (or dataframe) and an edge matrix (or dataframe) and creates a gexf object containing a data-frame representation and a gexf representation of a graph.

Usage

gexf(
  nodes,
  edges,
  edgesLabel = NULL,
  edgesId = NULL,
  edgesAtt = NULL,
  edgesWeight = NULL,
  edgesVizAtt = list(color = NULL, size = NULL, shape = NULL),
  nodesAtt = NULL,
  nodesVizAtt = list(color = NULL, position = NULL, size = NULL, shape = NULL, image =
    NULL),
  nodeDynamic = NULL,
  edgeDynamic = NULL,
  digits = getOption("digits"),
  output = NA,
  tFormat = "double",
  defaultedgetype = "undirected",
  meta = list(creator = "NodosChile", description =
    "A GEXF file written in R with \"rgexf\"", keywords =
    "GEXF, NodosChile, R, rgexf, Gephi"),
  keepFactors = FALSE,
  encoding = "UTF-8",
  vers = "1.3",
  rescale.node.size = TRUE,
  relsize = max(0.01, 1/nrow(nodes)),
  radius = 500
)

write.gexf(nodes, ...)

Arguments

nodes

A two-column data-frame or matrix of “id”s and “label”s representing nodes.

edges

A two-column data-frame or matrix containing “source” and “target” for each edge. Source and target values are based on the nodes ids.

edgesLabel

A one-column data-frame, matrix or vector.

edgesId

A one-column data-frame, matrix or vector.

edgesAtt

A data-frame with one or more columns representing edges' attributes.

edgesWeight

A numeric vector containing edges' weights.

edgesVizAtt

List of three or less viz attributes such as color, size (thickness) and shape of the edges (see details)

nodesAtt

A data-frame with one or more columns representing nodes' attributes

nodesVizAtt

List of four or less viz attributes such as color, position, size and shape of the nodes (see details)

nodeDynamic

A two-column matrix or data-frame. The first column indicates the time at which a given node starts; the second one shows when it ends. The matrix or data-frame must have the same number of rows than the number of nodes in the graph.

edgeDynamic

A two-column matrix or data-frame. The fist column indicates the time at which a given edge stars; the second one shows when it ends. The matrix or dataframe must have the same number of rows than the number of edges in the graph.

digits

Integer. Number of decimals to keep for nodes/edges sizes. See print.default()

output

String. The complete path (including filename) where to export the graph as a GEXF file.

tFormat

String. Time format for dynamic graphs (see details)

defaultedgetype

“directed”, “undirected”, “mutual”

meta

A List. Meta data describing the graph

keepFactors

Logical, whether to handle factors as numeric values (TRUE) or as strings (FALSE) by using as.character.

encoding

Encoding of the graph.

vers

Character scalar. Version of the GEXF format to generate. By default "1.3".

rescale.node.size

Logical scalar. When TRUE it rescales the size of the vertices such that the largest one is about \ region.

relsize

Numeric scalar. Relative size of the largest node in terms of the layout.

radius

Numeric scalar. Radius of the plotting area.

...

Passed to gexf.

Details

Just like nodesVizAtt and edgesVizAtt, nodesAtt and edgesAtt must have the same number of rows as nodes and edges, respectively. Using data frames is necessary as in this way data types are preserved.

nodesVizAtt and edgesVizAtt allow using visual attributes such as color, position (nodes only), size (nodes only), thickness (edges only) shape and image (nodes only).

  • Color is defined by the RGBA color model, thus for every node/edge the color should be specified through a data-frame with columns r (red), g (green), b (blue) with integers between 0 and 256 and a last column with alpha values as a float between 0.0 and 1.0.

  • Position, for every node, it is a three-column data-frame including x, y and z coordinates. The three components must be float.

  • Size as a numeric colvector (float values).

  • Thickness (see size).

  • Node Shape (string), currently unsupported by Gephi, can take the values of disk, square, triangle, diamond and image.

  • Edge Shape (string), currently unsupported by Gephi, can take the values of solid, dotted, dashed and double.

  • Image (string), currently unsupported by Gephi, consists on a vector of strings representing URIs.

nodeDynamic and edgeDynamic allow to draw dynamic graphs. It should contain two columns start and end, both allowing NA value. It can be use jointly with tFormat which by default is set as “double”. Currently accepted time formats are:

  • Integer or double.

  • International standard date yyyy-mm-dd.

  • dateTime W3 XSD (http://www.w3.org/TR/xmlschema-2/#dateTime).

NA values in the first column are filled with the min of c(nodeDynamic, edgeDynamic), whereas if in the second column is replaces with the max.

More complex time sequences like present/absent nodes and edges can be added with add.node.spell and add.edge.spell respectively.

Value

A gexf class object (list). Contains the following:

  • meta : (list) Meta data describing the graph.

  • mode : (list) Sets the default edge type and the graph mode.

  • atts.definitions: (list) Two data-frames describing nodes and edges attributes.

  • nodesVizAtt : (data-frame) A multi-column data-frame with the nodes' visual attributes.

  • edgesVizAtt : (data-frame) A multi-column data-frame with the edges' visual attributes.

  • nodes : (data-frame) A two-column data-frame with nodes' ids and labels.

  • edges : (data-frame) A five-column data-frame with edges' ids, labels, sources, targets and weights.

  • graph : (String) GEXF (XML) representation of the graph.

Author(s)

George Vega Yon

Jorge Fabrega Lacoa

References

The GEXF project website: https://gexf.net

See Also

new.gexf.graph()

Examples


if (interactive()) {
  demo(gexf) # Example of gexf command using fictional data.
  demo(gexfattributes) # Working with attributes.
  demo(gexfbasic) # Basic net.
  demo(gexfdynamic) # Dynamic net.
  demo(edge.list) # Working with edges lists.
  demo(gexffull) # All the package.
  demo(gexftwitter) # Example with real data of chilean twitter accounts.
  demo(gexfdynamicandatt) # Dynamic net with static attributes.
  demo(gexfbuildfromscratch) # Example building a net from scratch.
  demo(gexfrandom)
}


rgexf documentation built on July 3, 2024, 5:11 p.m.