In [1]:
%matplotlib inline

In [2]:
import networkx as nx
import numpy as np
import pandas as pd
import projx as px
import matplotlib.pyplot as plt

In [5]:
g = nx.read_gexf("projections/onemode.gexf")

In [6]:
authors = [n for (n, a) in g.nodes(data=True) if a.get("role") == "author"]
patrons = [n for (n, a) in g.nodes(data=True) if a.get("role") == "patron"]
printers = [n for (n, a) in g.nodes(data=True) if a.get("role") == "printer/editor"]
signatories = [n for (n, a) in g.nodes(data=True) if a.get("role") == "signatory"]

In [19]:
def patrons_per_author(authors, patrons):
    out = {}
    for a in authors:
        out.setdefault(a, 0)
        nbrs = set(g[a])
        for n in nbrs:
            if n in patrons:
                out[a] += 1
    return out

In [20]:
patrons_per_author(authors, patrons)


Out[20]:
{'140': 1,
 '143': 1,
 '148': 1,
 '170': 1,
 '183': 1,
 '189': 1,
 '198': 1,
 '208': 3,
 '25': 1,
 '252': 1,
 '264': 1,
 '295': 2,
 '310': 2,
 '331': 3,
 '336': 2,
 '34': 0,
 '357': 0,
 '358': 0,
 '368': 2,
 '372': 1,
 '380': 0,
 '381': 0,
 '382': 0,
 '385': 0,
 '386': 0,
 '387': 0,
 '388': 0,
 '399': 2,
 '412': 0,
 '43': 1,
 '431': 3,
 '434': 2,
 '438': 3,
 '440': 17,
 '441': 1,
 '70': 4}

In [25]:
g.node["208"]


Out[25]:
{'author': u"{'true': 5}",
 'avg_date': u'1612',
 'doc_type': u"{u'Obra': 5, u'Privilegio/Licencia': 6}",
 'fecha': u"{'1604-09-26': 1, '1614-05-10': 1, '1616-02-04': 1, '1617-01-27': 1, '1614-10-18': 1, '1615-03-30': 1, '1617-01-21': 1, '1612-11-22': 1, '1617-06-04': 1, '1617-11-17': 1, '1605-03-29': 1, '1617-01-01': 4, '1605-07-18': 1, '1613-08-09': 1, '1614-11-17': 1, '1605-03-01': 1, '1607-03-07': 1, '1605-02-09': 2, '1617-09-24': 1, '1615-01-01': 2, '1614-01-11': 1, '1618-01-01': 1, '1615-11-05': 1, '1617-01-17': 1, '1613-08-12': 1, '1608-06-25': 1, '1605-01-01': 1}",
 'genero': u"{'Ficcion': 25, 'Poesia': 1}",
 'label': 'Miguel de Cervantes Saavedra',
 'lugar': u"{u'Pamplona': 4, u'Madrid': 12, u'Bruselas': 5, u'Barcelona': 3, u'Milan': 1, u'Valladolid': 2, u'Lisboa': 4, u'Valencia': 1}",
 'real': u"{'True': 1}",
 'role': u'author',
 'second_genre': u'Poesia',
 'second_place': u'Bruselas',
 'top_genre': u'Ficcion',
 'top_place': u'Madrid',
 'type': u'Persona'}

In [ ]:


In [ ]:


In [ ]: