Add support for SONIA file format

Bug #663959 reported by Gábor Csárdi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
igraph
Confirmed
Wishlist
Unassigned

Bug Description

Quite simple format, so it is easy:

http://sourceforge.net/apps/mediawiki/sonia/index.php?title=Son_format
http://www.stanford.edu/group/sonia/exampleFiles/

Here is a quick and dirty R function for the sonia -> igraph conversion:

sonia2igraph <- function(filename, directed=TRUE) {
  lines <- readLines(filename)
  lines <- grep("^//", lines, value=TRUE, invert=TRUE)
  fromid <- grep("^FromId", lines)[1]
  nodes <- lines[1:(fromid-1)]
  edges <- lines[fromid:length(lines)]

  nodes <- strsplit(split="\t", nodes)
  nodesnames <- nodes[[1]]
  nodes <- data.frame(do.call(rbind, nodes[-1]))
  colnames(nodes) <- nodesnames
  colnames(nodes)[1] <- "name"

  edges <- strsplit(split="\t", edges)
  edgesnames <- edges[[1]]
  edges <- data.frame(do.call(rbind, edges[-1]))
  colnames(edges) <- edgesnames

  graph.data.frame(edges, directed=directed, vertices=nodes)
}

Revision history for this message
Gábor Csárdi (gabor.csardi) wrote : Continue on github

The development of igraph has moved to github, so please do not comment on this bug here. You are of course welcome to comment on github, here:
https://github.com/igraph/igraph/issues/340

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.