add.gexf.node: Adding and removing nodes/edges from 'gexf' objects

View source: R/manipulation.R

add.gexf.nodeR Documentation

Adding and removing nodes/edges from gexf objects

Description

Manipulates gexf objects adding and removing nodes and edges from both, its dataframe representation and its XML representation.

Usage

add.gexf.node(
  graph,
  id = NA,
  label = NA,
  start = NULL,
  end = NULL,
  vizAtt = list(color = NULL, position = NULL, size = NULL, shape = NULL, image = NULL),
  atts = NULL
)

add.gexf.edge(
  graph,
  source,
  target,
  id = NULL,
  type = NULL,
  label = NULL,
  start = NULL,
  end = NULL,
  weight = 1,
  vizAtt = list(color = NULL, thickness = NULL, shape = NULL),
  atts = NULL,
  digits = getOption("digits")
)

rm.gexf.node(graph, id = NULL, number = NULL, rm.edges = TRUE)

rm.gexf.edge(graph, id = NULL, number = NULL)

add.node.spell(
  graph,
  id = NULL,
  number = NULL,
  start = NULL,
  end = NULL,
  digits = getOption("digits")
)

add.edge.spell(
  graph,
  id = NULL,
  number = NULL,
  start = NULL,
  end = NULL,
  digits = getOption("digits")
)

Arguments

graph

A gexf-class object.

id

A node/edge id (normally numeric value).

label

A node/edge label.

start

Starting time period

end

Ending time period

vizAtt

A list of node/edge viz attributes (see write.gexf()).

atts

List of attributes, currently ignored.

source

Source node's id.

target

Target node's id.

type

Type of connection (edge).

weight

Edge weight.

digits

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

number

Index number(s) of a single or a group of nodes or edges.

rm.edges

Whether to remove or not existing edges.

Details

new.gexf.graph Creates a new gexf empty object (0 nodes 0 edges).

add.gexf.node and add.gexf.edge allow adding nodes and edges to a gexf object (graph) one at a time. rm.gexf.node and rm.gexf.edges remove nodes and edges respectively.

In the case of rm.gexf.node, by default every edge linked to the node that is been removed will also be removed (rm.edges = TRUE).

Value

A gexf object (see write.gexf()).

Spells

While the start and end attributes can be included in nodes and edges, spells provide a way to represent presence and absence of elements throughout time.

We can use spells to indicate windows during which the element is present or not. For example, a node that shows up from time 1 to time two and re-appears after time four can have two spells:

<spell start="1.0" end="2.0">
<spell start="4.0">

In the case of the functions add.edge.spell and add.node.spell, edges and nodes to which you want to add spells should already exist.

Author(s)

George Vega Yon

Jorge Fabrega Lacoa

References

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

Examples


if (interactive()) {
  demo(gexfbuildfromscratch)
}

# Creating spells ------------------------------------------------------
g <- new.gexf.graph()

# Adding a few nodes + edges
g <- add.gexf.node(g, id = 0, label = "A")
g <- add.gexf.node(g, id = 1, label = "B")
g <- add.gexf.node(g, id = 2, label = "C")

g <- add.gexf.edge(g, source = 0, target = 1)
g <- add.gexf.edge(g, source = 0, target = 2)

# Now we add spells:
# - Node 0: 1.0 -> 2.0, 3.0 -> Inf
# - edge 1: 1.0 -> 2.0, 3.5 -> Inf
g <- add.node.spell(g, 0, start = 1, end = 2)
g <- add.node.spell(g, 0, start = 3)

g <- add.edge.spell(g, 1, start = 1, end = 2)
g <- add.edge.spell(g, 1, start = 3.5)

g


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