Created
October 13, 2013 22:23
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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