plot.gexf: Visualizing GEXF graph files using gexf-js

View source: R/plot.R

gexf_js_configR Documentation

Visualizing GEXF graph files using gexf-js

Description

Using the gexf-js, a JavaScript GEXF viewer, this function allows you to visualize your GEXF on the browser. The function essentially copies a template website, the GEXF file, and sets up a configuration file. By default, the function then starts a webserver using the servr R package.

Usage

gexf_js_config(
  dir,
  graphFile = "network.gexf",
  showEdges = TRUE,
  useLens = FALSE,
  zoomLevel = 0,
  curvedEdges = TRUE,
  edgeWidthFactor = 1,
  minEdgeWidth = 1,
  maxEdgeWidth = 50,
  textDisplayThreshold = 9,
  nodeSizeFactor = 1,
  replaceUrls = TRUE,
  showEdgeWeight = TRUE,
  showEdgeLabel = TRUE,
  sortNodeAttributes = TRUE,
  showId = TRUE,
  showEdgeArrow = TRUE,
  language = FALSE
)

## S3 method for class 'gexf'
plot(
  x,
  y = NULL,
  graphFile = "network.gexf",
  dir = tempdir(),
  overwrite = TRUE,
  httd.args = list(),
  copy.only = FALSE,
  ...
)

Arguments

dir

Directory where the files will be copied (tempdir() by default).

graphFile

Name of the gexf file.

showEdges

Logical scalar. Default state of the "show edges" button (nullable).

useLens

Logical scalar. Default state of the "use lens" button (nullable).

zoomLevel

Numeric scalar. Default zoom level. At zoom = 0, the graph should fill a 800x700px zone

curvedEdges

Logical scalar. False for curved edges, true for straight edges this setting can't be changed from the User Interface.

edgeWidthFactor

Numeric scalar. Change this parameter for wider or narrower edges this setting can't be changed from the User Interface.

minEdgeWidth

Numeric scalar.

maxEdgeWidth

Numeric scalar.

textDisplayThreshold

Numeric scalar.

nodeSizeFactor

Numeric scalar. Change this parameter for smaller or larger nodes this setting can't be changed from the User Interface.

replaceUrls

Logical scalar. Enable the replacement of Urls by Hyperlinks this setting can't be changed from the User Interface.

showEdgeWeight

Logical scalar. Show the weight of edges in the list this setting can't be changed from the User Interface.

showEdgeLabel

Logical scalar.

sortNodeAttributes

Logical scalar. Alphabetically sort node attributes.

showId

Logical scalar. Show the id of the node in the list this setting can't be changed from the User Interface.

showEdgeArrow

Logical scalar. Show the edge arrows when the edge is directed this setting can't be changed from the User Interface.

language

Either FALSE, or a character scalar with any of the supported languages.

x

An object of class gexf.

y

Ignored.

overwrite

Logical scalar. When TRUE, the default, the function will overwrite all files copied from the template on the destination directory as specified by dir.

httd.args

Further arguments to be passed to servr::httd from the servr package.

copy.only

Logical scalar. When FALSE, the default, the function will make a call to servr::httd.

...

Further arguments passed to gexf_js_config

Details

Currently, the only languages supported are: German (de), English (en), French (fr), Spanish (es), Italian (it), Finnish (fi), Turkish (tr), Greek (el), Dutch (nl)

An important thing for the user to consider is the fact that the function only works if there are viz attributes, this is, color, size, and position. If the gexf object's XML document does not have viz attributes, users can use the following hack:

# Turn the object ot igraph and go back
x <- igraph.to.gexf(gexf.to.igraph(x))

# And you are ready to plot!
plot(x)

More details on this in the igraph.to.gexf function.

The files are copied directly from the path indicated by system.file("gexf-js", package="rgexf"). And the parameters are set up by modifying the following template file stored under the gexf-js/config.js.template (see the output from system.file("gexf-js/config.js.template", package="rgexf") to see the path to the template file).

The server is lunched if and only if interactive() == TRUE.

References

gexf-js project website https://github.com/raphv/gexf-js.

Examples

if (interactive()) {

path <- system.file("gexf-graphs/lesmiserables.gexf", package="rgexf")
graph <- read.gexf(path)
plot(graph)

}


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