Skip to content

Instantly share code, notes, and snippets.

'''
@author: Michael Bommarito
@contact [email protected]
@date Jul 1, 2009
'''
import urllib2, re, time, pprint, csv
# This regular expression extracts links to team rosters.
reTeamData = re.compile('/players/search\?category=team&filter=([0-9]+)&playerType=current">([^<]+)')
'''
@author: Michael Bommarito
@contact [email protected]
@date Jul 21, 2009
'''
"""
# Go to the NFL website and find the page that lists all teams: http://www.nfl.com/teams/
# Pick your favorite team and select the team roster.
# Now, pick a few of your favorite players and check out their profile page.
# Install SCMs
apt-get install subversion git-core bzr
# Install build chain tools
apt-get install build-essential autoconf automake libtool flex bison fortran77-compiler gfortran tcl tcl-dev tk tk-dev
# Install important libraries
apt-get install libxml2 libxml2-dev libgmp3-dev libgmp3c2 liblapack3gf liblapack-dev libarpack2 libarpack2-dev libblas3gf libblas-dev libgsl0-dev
# Install python friends
> A
V1 V2 V3 V4 V5 V6 V7
[1,] 0 1 1 1 0 0 0
[2,] 1 0 0 1 1 0 0
[3,] 0 1 0 0 0 1 0
[4,] 0 1 0 0 1 0 0
[5,] 0 1 0 0 0 0 0
[6,] 0 1 0 0 0 0 1
[7,] 0 0 0 0 0 0 0
'''
Created on Aug 6, 2009
@author: Michael Bommarito II
@contact: [email protected]
'''
import igraph
def igraph2sonia(graph, soniaFile):
'''
Generate a Sonia .son file from an igraph Graph object
'''
Created on Aug 8, 2009
@author: Michael Bommarito II
@contact: [email protected]
'''
import igraph
from igraph2sonia import igraph2sonia
g = igraph.Graph.Lattice([20,20])
'''
@date Aug 8, 2009
@author: Michael Bommarito
@contact [email protected]
'''
import igraph, random
from igraph2sonia import igraph2sonia
g = igraph.Graph.Lattice([20,20])
//Calculate merge matrix
igraph_community_edge_betweenness(&graph, &result, NULL, &M, NULL, IGRAPH_DIRECTED);
// Initialize max modularity
maxmod = 0.0;
// Determine max number of steps to merge
maxsteps = igraph_matrix_nrow(&M) < igraph_vcount(&graph) - 1) ? igraph_matrix_nrow(&M) : igraph_vcount(&graph) - 1;
// Compare merge modularities and keep only the best
/* V is the set<string> of vertices.
E is the set<int> of edges.
vA and vB are the vertex labels for the current edge.
*/
E.push_back(pair<int, int> (distance(V.begin(), (V.insert(vA)).first),
distance(V.begin(), (V.insert(vB)).first));
dend2newick <- function(d) {
leftLeaf <- attributes(d[[1]])$leaf
rightLeaf <- attributes(d[[2]])$leaf
if(length(leftLeaf) > 0) {
leftStr <- sprintf("%s:%f", attributes(d[[1]])$label, attributes(d)$height);
} else {
leftStr <- dend2newick(d[[1]])
}