Last active
April 3, 2020 15:41
-
-
Save jdmoore7/074bc5adec23d2291cab945ab62c8a01 to your computer and use it in GitHub Desktop.
TweetGraph
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 TweetGraph(): | |
def __init__(self,edge_list): | |
import igraph | |
import pandas as pd | |
data = pd.read_csv(edge_list).to_records(index=False) | |
self.graph = igraph.Graph.TupleList(data, weights=True, directed=False) | |
def e_centrality(self): | |
import operator | |
vectors = self.graph.eigenvector_centrality() | |
e = {name:cen for cen, name in zip([v for v in vectors],self.graph.vs['name'])} | |
return sorted(e.items(), key=operator.itemgetter(1),reverse=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment