Skip to content

Instantly share code, notes, and snippets.

@fernandobrito
Created October 13, 2013 22:23
Show Gist options
  • Select an option

  • Save fernandobrito/6968034 to your computer and use it in GitHub Desktop.

Select an option

Save fernandobrito/6968034 to your computer and use it in GitHub Desktop.
Add unique id's to edges on a .gexf file. Gephi 0.8.2 did not add them.
require "rexml/document"
INPUT = "/tmp/facebook.gexf"
OUTPUT = "/tmp/output.gexf"
xml = File.read(INPUT)
doc = REXML::Document.new(xml)
doc.root.elements.each_with_index("graph/edges/edge") { |e, i| e.attributes["id"] = i }
File.open(OUTPUT, 'w') { |file| file.write(doc) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment