1################################################################################ 2# Demo of gexf function 3# Author: Jorge Fabrega 4################################################################################ 5 6pause <- function() { 7 invisible(readline("\nPress <return> to continue: ")) 8} 9 10## Demos for rgexf - Nodes and edges with attributes. 11## 1. A matrix of nodes 12## 2. A matrix of edges 13## 3. A matrix indicating the active period of each node 14## 4. A matrix indicating the active period of each edge 15pause() 16 17# Defining a matrix of nodes 18pause() 19people <- matrix(c(1:4, 'juan', 'pedro', 'matthew', 'carlos'),ncol=2) 20people 21 22# Defining a matrix of edges 23pause() 24relations <- matrix(c(1,4,1,2,1,3,2,3,3,4,4,2,2,4,4,1,4,1), ncol=2, byrow=T) 25relations 26 27# Defining a matrix of dynamics (start, end) for nodes and edges 28pause() 29time.nodes<-matrix(c(10.0,13.3,2.5,2.0,12.0,rep(NA,3)), nrow=4, ncol=2) 30time.edges<-matrix(c(10.0,13.0,2.0,2.0,12.0,1,5,rep(NA,5),rep(c(0,1),3)), ncol=2) 31 32# In this example, the active period of each node is: 33pause() 34time.nodes 35 36# And for the edges are: 37time.edges 38 39################################################################################ 40# Dynamic network in gexf: 41# you create a .gexf archive by adding the expression: 42# 43# ,output="yourgraph.gexf" 44# 45# before the last closing 46# parenthesis in the following function 47pause() 48gexf(nodes=people, edges=relations, nodeDynamic=time.nodes) 49 50