code | Publication network

Retrieving data from ADS

We can take the list on the PHANGS website, extract the bibcodes and then run the following code to get the BibTeX entry for each article.

import requests

API_TOKEN = 'XXX'
bibcodes  = ['2025ApJ...983..137R']

response = requests.post(
    "https://api.adsabs.harvard.edu/v1/export/bibtex",
    headers = {
        "Authorization": f"Bearer {API_TOKEN}",
        "Content-Type": "application/json"
        },
    json = {
        "bibcode": bibcodes
        }
)

These are saved as phangs.bib. I used jabref to convert this to a csv file and read it in python with pandas as publications.

import pandas as pd
import networkx as nx

G = nx.Graph()
publication_nodes = publication_list.keys() 
author_nodes = set()
for publication in publication_nodes:
    G.add_node(publication,type='publication',
               title=publications.loc[publication,'Title'],
               year=publications.loc[publication,'Year'])

    for author in publication_list[publication]:
        author_nodes.add(author)

        if G.has_node(author):
            G.add_edge(publication,author)
        else:
            G.add_node(author,type='author')
            G.add_edge(publication,author)

The we use pyvis to display this as an interactive html page.

from pyvis.network import Network
net = Network()

for node, data in G.nodes(data=True):
    if data["type"] == "author":
        net.add_node(
            node,
            physics=False,
            x=x,
            y=y,
            label=node, 
            color="#d75556", 
            shape="box"
            )
    elif data["type"] == "publication":
        row = publications.loc[node]
        title = f"{row['Title']}"
        author = f'{row['Author'].split(',')[0]} et al. ({row['Year']})'
        net.add_node(
            node,
            physics=False,
            x=x,
            y=y,
            label=f'{author:^30}',
            title=title,
            color="#7db5b0", 
            shape="box"
            )

for u, v in G.edges():
    net.add_edge(u, v,color="#999999")

net.save_graph("phangs.html")

Below is the output, but it is easier to look at in a new tab.