4

How do I convert an R "network" object to an "igraph" object?

Many formats are discussed in the tutorial and package documentation, but I couldn't find how to import a "network" object.

Michael Bishop
  • 1,875
  • 4
  • 17
  • 23

2 Answers2

6

See the intergraph package.

Note that this package claims to be compatible with the obsolete igraph0 version of igraph, but since the igraph objects are exactly the same in the igraph0 and the igraph packages, objects created with intergraph should work in igraph as well. (I never tried personally.)

You can load the igraph0 and the igraph packages at the same time, just make sure that you are calling the igraph functions and not the igraph0 functions in your code. An easy way is to load igraph0 first, igraph next, and then the igraph0 functions will be masked. Or you can unload the igraph0 package via unloadNamespace() when you don't need it any more.

Gabor Csardi
  • 10,705
  • 1
  • 36
  • 53
0
Net <- network.initialize(10, directed = FALSE) #initialize a graph with 10 nodes

Then run

asIgraph(Net)
Smajl
  • 7,555
  • 29
  • 108
  • 179