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

Description Usage Arguments Details References Examples

View source: R/plot.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
gexf_js_config(
  dir,
  graphFile = "network.gexf",
  showEdges = TRUE,
  useLens = FALSE,
  zoomLevel = 0,
  curvedEdges = TRUE,
  edgeWidthFactor = 1,
  minEdgeWidth = 1,
  maxEdgeWidth = 2,
  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: \Sexpr{paste(names(rgexf:::gexf_js_languages), " (", rgexf:::gexf_js_languages, ")", sep="", collapse=", ")}.

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:

1
2
3
4
5
# 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 \Sexpr{system.file("gexf-js", package="rgexf")}. And the parameters are set up by modifying the following template file:

\Sexpr{system.file("gexf-js/config.js.template", package="rgexf")}

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

References

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

Examples

1
2
3
4
5
6
7
if (interactive()) {

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

}

rgexf documentation built on Aug. 13, 2021, 1:06 a.m.