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
''' | |
@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">([^<]+)') |
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
''' | |
@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. |
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
# 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 |
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
> 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 |
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
''' | |
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 |
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
''' | |
Created on Aug 8, 2009 | |
@author: Michael Bommarito II | |
@contact: [email protected] | |
''' | |
import igraph | |
from igraph2sonia import igraph2sonia | |
g = igraph.Graph.Lattice([20,20]) |
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
''' | |
@date Aug 8, 2009 | |
@author: Michael Bommarito | |
@contact [email protected] | |
''' | |
import igraph, random | |
from igraph2sonia import igraph2sonia | |
g = igraph.Graph.Lattice([20,20]) |
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
//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 |
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
/* 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)); |
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
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]]) | |
} |
OlderNewer