Skip to content

Instantly share code, notes, and snippets.

View drewbuschhorn's full-sized avatar

Drew drewbuschhorn

  • VeerWest
  • Bloomington, IN
View GitHub Profile
@drewconway
drewconway / networkx_d3_example.py
Created July 25, 2011 16:47
A short example for using the D3 export feature. Using Mike Dewar (@mikedewar) Twitter social graph :)
import networkx as nx
from networkx.readwrite import d3_js
mikedewar = nx.read_graphml('mikedewar_rec.graphml')
# We need to relabel nodes as Twitter name if we want to show the names in the plot
label_dict = dict(map(lambda i : (mikedewar.nodes()[i], mikedewar.nodes(data=True)[i][1]['Label']), xrange(mikedewar.number_of_nodes())))
mikedewar_d3 = nx.relabel_nodes(mikedewar, label_dict)
# Export
@drewbuschhorn
drewbuschhorn / plos_sunburnt_demo.py
Created July 12, 2011 03:06
PLOS API code for use with SunBurnt
#Sample PLOS api code for use with python Solr library Sunburnt
#( https://github.com/tow/sunburnt )
#!Note! requires sunburnt's external libraries: httplib2,lxml
#https://groups.google.com/d/topic/plos-api-developers/zv591sFz6TM/discussion
import sunburnt,urllib2
class PlosInterface(sunburnt.SolrInterface):
def __init__(self,api_key):
plos_url = "http://api.plos.org/search"
#either