Scientific collaborations in network science (2006)

I first tried using R

library(igraph)
setwd("C:/Users/batagelj/data/icon/astro")
g <- read_graph("astro-ph.gml",format="gml")
write_graph(g,"astro-ph.net",format="pajek")

The problem is that the labels are lost in conversion.

Then I tried with python

import networkx as nx
import os
os.chdir("C:/Users/batagelj/data/icon/astro")
G = nx.read_gml('astro-phX.gml')
nx.write_pajek(G,"astro-phX.net")

There were problems with the original file astro-ph.gml. It turned out that [ shouldn't be in a separate line. Using Textpad I replaced

  node
  [

into

  node [

read_gml was now “happy” with the input file and I obtained a Pajek file - but with lines such as

27 "KLEIN, U" 0.0 0.0 ellipse

for nodes, and

52 4416 1.0 value 0.642857 value 0.642857

for edges.

Again using Textpad I replaced everywhere the string “0.0 0.0 ellipse” with the empty string, the string “1.0 value ” with the empty string. Afterward I replaced everywhere the string “value” with the string ” ” to move the unwanted information right. Finally I marked it in the Block Select Mode and deleted.

notes/data/pajek/astro.txt · Last modified: 2017/04/20 09:31 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki