R igraph write.graph() edgelist if graph is empty

Using in R the package 'igraph' and calling the function:

graph <- graph.empty(10,directed=FALSE)
write.graph(graph,"some/path/graph.txt",format="edgelist")

If I recall the graph by using

g <- as.undirected(read.graph("some/path/graph.txt",format="edgelist"))

the graph is empty but has also NO vertices!

Answers


An edgelist is a matrix with 2 columns with a row for each edge, first column indicating the source node and second column the node of destination. Since you have no edges the edgelist is empty and hence the file you write is empty.

Usually the edgelist is the simplest way of storing a graph, and the number of nodes can be inferred from the number of unique node names in the edgelist (or highest integer if nodes are numbered, which I think is what igraph does), but it goes wrong if there are nodes with no edges,

You can try another format that also stores information on the nodes. e.g.,

library("igraph")

graph <- graph.empty(10,directed=FALSE)
write.graph(graph,"graph.txt",format="pajek")


g <- as.undirected(read.graph("graph.txt",format="pajek"))

Need Your Help

Haskell: Can you use the filter function to display a whole list by filtering nothing?

haskell

If I wanted to display the whole contents of a list, could you 'cheat' and use the filter function to filter nothing?

ApplicationPoolIdentity user cannot modify files in shared folder in Windows Server 2008

iis-7 permissions folder shared

I am creating directories, and writing files to a shared folder within my web application that is being hosted on Windows Server 2008. I am running the application pool with an identity of

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.