Created
November 17, 2011 17:50
-
-
Save fnielsen/1373887 to your computer and use it in GitHub Desktop.
Co-author mining for papers in the Brede Wiki
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
import matplotlib.pyplot as plt | |
import networkx as nx | |
from pysqlite2 import dbapi2 | |
connection = dbapi2.Connection('bredewiki-templates.sqlite3') | |
sql = "SELECT DISTINCT pid FROM brede WHERE (template='paper' OR template='conference_paper');" | |
cursor = connection.cursor() | |
cursor.execute(sql) | |
pids = [ row[0] for row in cursor.fetchall() ] | |
g = nx.Graph() | |
sql = "SELECT value FROM brede WHERE pid=? AND field='author'"; | |
for pid in pids: | |
cursor.execute(sql, (pid,)) | |
authors = [ row[0] for row in cursor.fetchall() ] | |
for n in range(len(authors)): | |
for m in range(len(authors)): | |
g.add_edge(authors[n], authors[m]) | |
nx.draw(nx.connected_component_subgraphs(g)[3]) | |
plt.show() | |
plt.savefig('coauthors.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment