1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/manipulation.R 3\name{add.gexf.node} 4\alias{add.gexf.node} 5\alias{add.gexf.edge} 6\alias{rm.gexf.node} 7\alias{rm.gexf.edge} 8\alias{add.node.spell} 9\alias{add.edge.spell} 10\title{Adding and removing nodes/edges from \code{gexf} objects} 11\usage{ 12add.gexf.node( 13 graph, 14 id = NA, 15 label = NA, 16 start = NULL, 17 end = NULL, 18 vizAtt = list(color = NULL, position = NULL, size = NULL, shape = NULL, image = NULL), 19 atts = NULL 20) 21 22add.gexf.edge( 23 graph, 24 source, 25 target, 26 id = NULL, 27 type = NULL, 28 label = NULL, 29 start = NULL, 30 end = NULL, 31 weight = 1, 32 vizAtt = list(color = NULL, thickness = NULL, shape = NULL), 33 atts = NULL, 34 digits = getOption("digits") 35) 36 37rm.gexf.node(graph, id = NULL, number = NULL, rm.edges = TRUE) 38 39rm.gexf.edge(graph, id = NULL, number = NULL) 40 41add.node.spell( 42 graph, 43 id = NULL, 44 number = NULL, 45 start = NULL, 46 end = NULL, 47 digits = getOption("digits") 48) 49 50add.edge.spell( 51 graph, 52 id = NULL, 53 number = NULL, 54 start = NULL, 55 end = NULL, 56 digits = getOption("digits") 57) 58} 59\arguments{ 60\item{graph}{A gexf-class object.} 61 62\item{id}{A node/edge id (normally numeric value).} 63 64\item{label}{A node/edge label.} 65 66\item{start}{Starting time period} 67 68\item{end}{Ending time period} 69 70\item{vizAtt}{A list of node/edge viz attributes (see 71\code{\link[=write.gexf]{write.gexf()}}).} 72 73\item{atts}{List of attributes, currently ignored.} 74 75\item{source}{Source node's id.} 76 77\item{target}{Target node's id.} 78 79\item{type}{Type of connection (edge).} 80 81\item{weight}{Edge weight.} 82 83\item{digits}{Integer. Number of decimals to keep for nodes/edges sizes. See 84\code{\link[=print.default]{print.default()}}} 85 86\item{number}{Index number(s) of a single or a group of nodes or edges.} 87 88\item{rm.edges}{Whether to remove or not existing edges.} 89} 90\value{ 91A \code{gexf} object (see \code{\link[=write.gexf]{write.gexf()}}). 92} 93\description{ 94Manipulates \code{gexf} objects adding and removing nodes and edges from 95both, its dataframe representation and its XML representation. 96} 97\details{ 98\code{new.gexf.graph} Creates a new \code{gexf} empty object (0 nodes 0 99edges). 100 101\code{add.gexf.node} and \code{add.gexf.edge} allow adding nodes and edges 102to a \code{gexf} object (graph) one at a time. \code{rm.gexf.node} and 103\code{rm.gexf.edges} remove nodes and edges respectively. 104 105In the case of \code{rm.gexf.node}, by default every edge linked to the node 106that is been removed will also be removed (\code{rm.edges = TRUE}). 107} 108\section{Spells}{ 109 110While the \code{start} and \code{end} attributes can be included in nodes and edges, 111spells provide a way to represent presence and absence of elements throughout 112time. 113 114We can use spells to indicate windows during which the element is present 115or not. For example, a node that shows up from time 1 to time two and 116re-appears after time four can have two spells:\preformatted{<spell start="1.0" end="2.0"> 117<spell start="4.0"> 118} 119 120In the case of the functions \code{add.edge.spell} and \code{add.node.spell}, edges and 121nodes to which you want to add spells should already exist. 122} 123 124\examples{ 125 126if (interactive()) { 127 demo(gexfbuildfromscratch) 128} 129 130# Creating spells ------------------------------------------------------ 131g <- new.gexf.graph() 132 133# Adding a few nodes + edges 134g <- add.gexf.node(g, id = 0, label = "A") 135g <- add.gexf.node(g, id = 1, label = "B") 136g <- add.gexf.node(g, id = 2, label = "C") 137 138g <- add.gexf.edge(g, source = 0, target = 1) 139g <- add.gexf.edge(g, source = 0, target = 2) 140 141# Now we add spells: 142# - Node 0: 1.0 -> 2.0, 3.0 -> Inf 143# - edge 1: 1.0 -> 2.0, 3.5 -> Inf 144g <- add.node.spell(g, 0, start = 1, end = 2) 145g <- add.node.spell(g, 0, start = 3) 146 147g <- add.edge.spell(g, 1, start = 1, end = 2) 148g <- add.edge.spell(g, 1, start = 3.5) 149 150g 151 152} 153\references{ 154The GEXF project website: https://gephi.org/gexf/format/ 155} 156\author{ 157George Vega Yon 158 159Jorge Fabrega Lacoa 160} 161\keyword{manip} 162