0

I'm attempting to construct a model of an open-source software development network in R using igraph. The graph is meant to be bipartite, with developers being one set of nodes and projects being the second set.

Each project may have zero or more known environments associated with it, as well as zero or more programming languages associated with it. Currently I have both of these fields in the form of a list of lists, representing how a list of projects has a list of environments/languages. Some of the values in either list may be null due to a lack of data provided.

I would like both the project environments and languages to be attributes of the graph, hoping that later I can filter out all projects except those of a specific environment/language. but I can't find any way to allow an attribute to have a list as its value. Is there a way to allow attributes to be complex values like lists, and if not, how else could I go about filtering the graph based on specific environments/languages?

I've included my source code so far below:

library(igraph)
library(RMySQL)
# second library?

#Extracting data from the server
con <- dbConnect(dbDriver("MySQL"), user = "root", password = "root", dbname = "ow")
edgeList <- dbGetQuery(con, "SELECT dev_loginname, proj_unixname FROM ow_developer_projects")
people <- dbGetQuery(con, "SELECT DISTINCT dev_loginname FROM ow_developer_projects")[,1]
projects <- dbGetQuery(con, "SELECT DISTINCT proj_unixname FROM ow_developer_projects")[,1]

#Data Cleaning/Prep
edgeListPeople = edgeList[,1]
edgeListProjects = edgeList[,2]

envVector = NULL
langVector = NULL
for (i in seq(1, length(people))) {
  #Note that the first length(people) vertices are people, and have no associated environment or language
  envVector <- c(envVector, list(NULL))
  langVector <- c(langVector, list(NULL))
  edgeListPeople[edgeListPeople==people[i]] <- i
}


for (i in seq(1, length(projects))) {
  edgeListProjects[edgeListProjects==projects[i]] <- i+length(people)
  envVector <- c(envVector, dbGetQuery(con, paste("SELECT description FROM ow_project_environment WHERE proj_unixname =", "'", projects[i], "'", sep="")))
  langVector <- c(langVector, dbGetQuery(con, paste("SELECT description FROM ow_project_programming_language WHERE proj_unixname = ", "'", projects[i], "'", sep="")))
}
dbDisconnect(con)

edgeList = data.frame(edgeListPeople, edgeListProjects)

g <- graph_from_data_frame(edgeList, directed = FALSE)
V(g)$type <- V(g)$name %in% edgeList[,1]
V(g)$color <- V(g)$type + 1

# Here is where I'd like to set the environment and language attributes, but can't.
g <- set_vertex_attr(g, "environment", envVector)
g <- set_vertex_attr(g, "language", langVector)

l <- layout.fruchterman.reingold(g)*0.08
plot(g, 
     layout=l, 
     vertex.size=5,
     edge.arrow.size=.2,
     vertex.label=NA, 
     rescale=F)
  • Please see how to make a reproducible example. What you have presented is not reproducible - you need some data - thanks. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – B Williams Apr 16 '17 at 17:26
  • I just answered a question yesterday that supplied lists of attributes to a plot task for igraph objects: http://stackoverflow.com/questions/43402827/r-igraph-is-it-possible-to-fill-vertex-with-pattern/43434215#43434215 (I do remember trying to add these attributes to the vertices first and not coming up with a solution.) Your code is not reproducible since it depends on an external database. You might try simplifying it by extracting from your objects and posting as an [edit] the output of dput(obj). – IRTFM Apr 16 '17 at 17:27

0 Answers0