This tutorial and the package documentation describe how to do it for pajek files of the .net format, but I need to import .paj files. I don’t expect there is code that will import all .paj files, but perhaps someone has code that will work for some simpler ones that I could then modify for my purposes?
This tutorial and the package documentation describe how to do it for pajek files
Share
I would start with the following approach:
readLines().%‘.*‘) mark the start of a new piece.In Step 4 you may have several types of pieces:
*Networkis the start of a network.*Verticesdefines vertices and belongs to the previous network.*Edgesdefines undirected edges, it belongs to the previous network.*Arcsdefines directed edges, it belongs to the previous network.*Partitionis the start of a partition.*Vectoris the start of a vector.For converting a
*Networkpiece into an igraph graph, glue it together with the*Vertices,*Edgesand/or*Arcspieces that come right after it, and then callread.graph(..., format="pajek")via atextConnection(). This way you don’t need to create temporary files.The
*Partitionand*Vectorpieces are simple, just convert them to R vectors, usingscan()andtextConnection().I haven’t tried all this, but I think it is not too difficult and should work fine. Tell me if you have any difficulties.
Also, Pajek file formats are poorly documented, so I might be wrong, there might be other piece types, etc.
You may also consider adding a bug report at the igraph bug tracker to request this feature.