def internal_directed_cites_matrix( w ) : """ returns a directed citations graph; this only involves papers listed in the data, and is a DIRECTED graph adgacency matrix such that cell (row,col) means "node row points to node col" """ row_dois = w.dois() result = zeros( (len(row_dois), len(row_dois)), dtype=int8 ) for paper in w.reader() : if paper['DI'] != '' : for doi in cited_dois(paper) : if row_dois.count( doi ) : result[ row_dois.index(paper['DI']), row_dois.index(doi)] = 1 return (result, row_dois, row_dois )
def cites_matrix( w ) : """ Returns an occurrence matrix; the rows represent the papers in the corpus; the columns the cited papers. The entries are the intersections where a corpus paper cites a column paper """ column_dois = w.set_cited_dois() row_dois = w.dois() result = zeros( (len(row_dois), len(column_dois)), dtype = int8 ) for paper in w.reader() : if paper['DI'] != '' : for doi in cited_dois( paper ) : result[row_dois.index( paper['DI'] )][column_dois.index( doi )] = 1 return ( result, row_dois, column_dois )
def internal_directed_authorcite_matrix( w ) : """ returns a directed citations graph; this only involves authors such that cell (row,col) means "node row cites node col" """ authordict = authors_by_doi( w ) authors = list(w.set_authors()) result = zeros( (len(authors), len(authors)), dtype=int32 ) for paper in w.reader() : for node_author in authorlist_from_authorfield( paper['AU'] ) : for doi in cited_dois(paper) : if authordict.has_key(doi) : for cited_author in authordict[doi] : result[ authors.index( node_author ), authors.index( cited_author )] += 1 return (result, authors, authors)