Dynamic Edges from .csv import

Evolution and dynamics on networks in Gephi: UI, data formats, algorithms...
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
godot90
Posts:3
Joined:05 May 2017 21:25
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Dynamic Edges from .csv import

Post by godot90 » 05 Jun 2019 16:18

I have an incoming dataset for a co-inventor network. My data is in a spreadsheet (.csv) and it has a column for "InventionID", "Inventor" and "DIsclosure Date".

Each inventor has his or her own line meaning that in order to create an edgelist I need to first create an incidence matrix and then an adjacency matrix, which I'm doing in R using igraph and rgexf packages.

Here's what the incoming data looks like, you can see the multiple inventors for some inventions are given their own line for the same inventionID:

InventionId,DisclosureDate,InventorEMail,InventorCity,EndDate
81455383, 3/7/2000, david.k, Beaverton, 11/1/2017
81455383, 3/7/2000, ronald.s, Vancouver, 11/1/2017
81455383, 3/7/2000, vladek.k, Beaverton, 11/1/2017
81455805, 3/21/2000,howard.d, San Dimas, 11/1/2017
81455805, 3/21/2000,paul.br, San Dimas, 11/1/2017
81456232, 4/25/2000,alexey.k, San Dimas, 11/1/2017
81456285, 4/27/2000,joan.v, San Dimas, 11/1/2017
81456347, 5/1/2000, vladek.k, Beaverton, 11/1/2017
81456347, 5/1/2000, will.al, Beaverton, 11/1/2017


I want to get to a DYNAMIC graph of co-inventor nodes wherein the edges are the inventions but I cannot figure out how to attach the DISCLOSURE DATE to the EDGE rather than to the inventor.

Here's the R script I'm using to pre-process the data. Right now it is set to attach the DisclosureDate and the EndDate to the INVENTOR (node) rather than the inventionID (Edge).

``library(igraph)
library(rgexf)
options(stringsAsFactors=FALSE) #make sure that countries shows up as characters for the nodes
dat<-read.csv(file.choose(),header=TRUE,encoding="UTF-8") #read in the raw data
incidence_matrix<-xtabs(~InventorEMail+InventionId,dat)
adjacency_matrix<-tcrossprod(incidence_matrix)
g<-graph.adjacency(adjacency_matrix,mode="undirected") #creates graph object for undirected graph
#Time to Link "City" to "Inventor"
ix<-match(V(g)$name,dat$InventorEMail)
V(g)$city<-dat$InventorCity[ix]
set.vertex.attribute(graph=g,name='city',value=dat$InventorCity[ix])
#TimeStamps
V(g)$start_date2<-dat$DisclosureDate[ix]
set.vertex.attribute(graph=g,name='start_date2',value=dat$DisclosureDate[ix])
V(g)$end_date2<-dat$EndDate[ix]
set.vertex.attribute(graph=g,name='end_date2',value=dat$EndDate[ix])
#Process for Gephi
g2<-simplify(g,remove.loops=TRUE,remove.multiple = FALSE) #Remove Loops from Dataset, keep duplicates
network.gexf<-igraph.to.gexf(g2)
f<-file("network.gexf")
writeLines(network.gexf$graph,con=f)``

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable