<jupyter_start><jupyter_text>We use [Gephi](https://gephi.org/) to make fancy pics so we need to convert co-author network into `.gml` format<jupyter_code>%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import scipy as sp
import matplotlib.pyplot as plt
import seaborn as sns
import gensim
import networkx as nx
df = pd.read_csv('seven_topconf_papers.csv')
def generate_coauthor_gml(field):
    print field
    selected_df = df[df.field == field]
    temp = []
    for i in selected_df.author.values:
        temp.extend(i.split(', '))
    unique_authors = np.unique(temp)
    print 'authors:', len(unique_authors)
    
    G = nx.Graph()
    for i in selected_df.index:
        authors = selected_df.loc[i].author.split(', ')
        for j in range(len(authors)):
            for k in range(j+1, len(authors)):
                try:
                    G.add_edge(authors[j], authors[k])
                    if G[authors[j]][authors[k]].has_key('weight'):
                        G[authors[j]][authors[k]]['weight'] += 1
                    else:
                        G[authors[j]][authors[k]]['weight'] = 1
                except:
                    print authors[j], authors[k], 'not added!'
    print 'Nodes:', len(G.nodes())
    print 'Edges:', len(G.edges())
    nx.write_gml(G, field + '.gml')
    print 
for field in ['DM', 'DP', 'ED', 'ML', 'NC', 'NL', 'OS']:
    generate_coauthor_gml(field)<jupyter_output>DM
authors: 11541
Nodes: 11280
Edges: 30877

DP
authors: 11916
Nodes: 11656
Edges: 29176

ED
authors: 7958
Nodes: 7714
Edges: 16962

ML
authors: 21225
Nodes: 20269
Edges: 47912

NC
authors: 11954
Nodes: 11695
Edges: 30797

NL
authors: 7893
Nodes: 7219
Edges: 16202

OS
authors: 3649
Nodes: 3550
Edges: 8370
{'fraction_non_alphanumeric': 0.12955692652832304, 'fraction_numerical': 0.056646102075154234, 'mean_word_length': 2.795744680851064, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '609491', 'license': 'MIT', 'n_tokens_mistral': 729, 'n_tokens_neox': 619, 'n_words': 169, 'path': 'generate_field_gml.ipynb', 'repo_name': 'TianxiaoHu/Polar', 'size': '1783'}