Created
March 4, 2010 13:56
-
-
Save mjbommar/321715 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 J Bommarito II | |
@date Mar 4, 2010 | |
''' | |
import igraph | |
from pairwiseStability import * | |
''' | |
Create G, the list of graphs over time. | |
''' | |
G = [] | |
G.append(igraph.Graph([(0,1),(1,2),(2,3)], directed = True)) | |
G.append(igraph.Graph([(0,1),(1,2),(2,3),(4,3),(5,3),(5,4)], directed = True)) | |
G.append(igraph.Graph([(0,1),(1,2),(2,3),(4,3),(5,3),(5,4), (6,0), (6,1), (2,0)], directed = True)) | |
G.append(igraph.Graph([(0,1),(1,2),(2,3),(4,3),(5,3),(5,4), (2,0), (7,5), (7,4), (7,3), (7,6), (6,5), (6,4), (6,3)], directed = True)) | |
''' | |
Because we want to support graphs with VERTEX REMOVAL, | |
we need to explicitly label each vertex. This could be | |
a string or a number, so long as it is unique! In this | |
case, no removal occurs and so the vertex index is used | |
as the label. | |
''' | |
for g in G: | |
for i,v in enumerate(g.vs): | |
v['label'] = i | |
''' | |
This calculates the corresponding stabilities. | |
''' | |
print 'Edge Betweenness: ', pairwiseStability_Betweenness(G) | |
print 'Fast Greedy: ', pairwiseStability_FastGreedy(G) | |
print 'Label Propagation: ', pairwiseStability_LabelPropagation(G) | |
print 'Leading Eigenvector: ', pairwiseStability_Eigenvector(G) | |
print 'Walktrap: ', pairwiseStability_Walktrap(G) | |
''' | |
Here are the results: | |
Edge Betweenness: 0.430555555556 | |
Fast Greedy: 0.6 | |
Label Propagation: 0.466666666667 | |
Leading Eigenvector: 0.6 | |
Walktrap: 0.6 | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment