Skip to content

Instantly share code, notes, and snippets.

@jdmoore7
Last active April 3, 2020 15:41
Show Gist options
  • Save jdmoore7/074bc5adec23d2291cab945ab62c8a01 to your computer and use it in GitHub Desktop.
Save jdmoore7/074bc5adec23d2291cab945ab62c8a01 to your computer and use it in GitHub Desktop.
TweetGraph
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