This file contains 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
from geventwebsocket.handler import WebSocketHandler | |
from gevent.pywsgi import WSGIServer | |
from flask import Flask, request, render_template | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return render_template('index.html') |
This file contains 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
class RedisCircularBuffer(object): | |
def __init__(self, namespace, size): | |
self.namespace = namespace | |
self.size = size | |
import redis | |
self.redis = redis.Redis() | |
def append(self, item): | |
self.redis.lpush(self.namespace, item) |
This file contains 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
# Serrano, Boguna, Vespigani backbone extractor | |
# from http://www.pnas.org/content/106/16/6483.abstract | |
# Thanks to Michael Conover and Qian Zhang at Indiana with help on earlier versions | |
# Thanks to Clay Davis for pointing out an error | |
import networkx as nx | |
import numpy as np | |
def extract_backbone(g, weight='weight', alpha=.05): | |
backbone_graph = nx.Graph() |