Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 25 lines (19 sloc) 0.851 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#Piece of python that takes a graph in the form produced by the MR job and creates GML out of it (readable by Cytoscape)
import fileinput
import sys

nodes = {}
edges = []
for line in fileinput.input(sys.argv[1]):
parts = line.strip().split('\t')
nodes[parts[1]] = parts[0]
for node in parts[2].split(','):
edges.append( (parts[1], node) )

print 'graph [\n\tcomment "Generated from adjaceny list file."\n\tdirected 1\n\tlabel "from: ' + sys.argv[1] + '"\n'

for node in nodes:
print 'node [\n\tid ' + node + '\n\tlabel N' + node + '\n\tpartition ' + nodes[node] + '\n]\n'

for edge in edges:
if (not edge[1] in nodes):
nodes[edge[1]] = nodes[edge[0]]
print 'node [\n\tid ' + edge[1] + '\n\tlabel N' + edge[1] + '\n\tpartition ' + nodes[edge[0]] + '\n]\n'
print 'edge [\n\tsource ' + edge[0] + '\n\ttarget ' + edge[1] + '\n]\n'

print ']'
Something went wrong with that request. Please try again.