Compare commits
3 Commits
b209faf01d
...
f0338ce128
| Author | SHA1 | Date | |
|---|---|---|---|
| f0338ce128 | |||
| 505a8d2da2 | |||
| 835e658d91 |
13
MathGen.py
13
MathGen.py
@@ -12,10 +12,6 @@ import logging
|
||||
from subprocess import call
|
||||
|
||||
|
||||
#logging.warning('Watch out!') # will print a message to the console
|
||||
#logging.info('I told you so') # will not print anything
|
||||
|
||||
|
||||
class mathPage:
|
||||
def __init__(self, mathID, verbose=False):
|
||||
"""
|
||||
@@ -809,8 +805,11 @@ class mathGenealogy(Graph):
|
||||
adv = []
|
||||
for a in res:
|
||||
if a > 0:
|
||||
cur.execute(query, (a,))
|
||||
advID = cur.fetchall()[0][0]
|
||||
try:
|
||||
cur.execute(query, (a,))
|
||||
advID = cur.fetchall()[0][0]
|
||||
except IndexError:
|
||||
logging.warning(f"No entry for {a}")
|
||||
adv.append(advID)
|
||||
return(tuple(adv))
|
||||
|
||||
@@ -1196,7 +1195,7 @@ class mathGenealogy(Graph):
|
||||
else:
|
||||
fn = filename
|
||||
if bgcolor != "white":
|
||||
self.__backColor = bgcolor
|
||||
self.__graphOptions['bgcolor'] = bgcolor
|
||||
if not filename:
|
||||
filename = "tmp_"+str(random.randint(1,9999999))
|
||||
self.save(fn+".dot")
|
||||
|
||||
@@ -4,4 +4,4 @@ Python Project to generate genealogical graphs using the data from the Mathemati
|
||||
This is a completely new implementation of a project I did in 2019 to generate a poster of a friend's academic family tree as a present for his defense.
|
||||
|
||||
## Status
|
||||
At the moment only the basic functionality of downloading info from the Mathematics Genealogy Project from their website and storing this data in a SQLite3 database is implemented.
|
||||
Documentation is missing.
|
||||
|
||||
BIN
example.db
Normal file
BIN
example.db
Normal file
Binary file not shown.
BIN
example.pdf
Normal file
BIN
example.pdf
Normal file
Binary file not shown.
50
example.py
Normal file
50
example.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from MathGen import *
|
||||
|
||||
"""
|
||||
Generate the genealogical graph of the four Fields medalists of 2022:
|
||||
- Hugo Duminil-Copin
|
||||
- June Huh
|
||||
- James Maynard
|
||||
- Maryna Viazovska
|
||||
"""
|
||||
|
||||
|
||||
DuminilCopin_ID = 168435
|
||||
Huh_ID = 185855
|
||||
Maynard_ID = 178890
|
||||
Viazovska_ID = 201884
|
||||
|
||||
IDs = [DuminilCopin_ID, Huh_ID, Maynard_ID, Viazovska_ID]
|
||||
|
||||
# Define different color pallettes for graph drawing
|
||||
cols = ["#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#fbb4ae"]
|
||||
cols2 = ["#00202e","#003f5c","#2c4875","#8a508f","#bc5090","#ff6361","#ff8531","#ffa600","#ffd380"]
|
||||
cols3 = ["#ffadad","#ffd6a5","#fdffb6","#caffbf","#9bf6ff","#a0c4ff","#bdb2ff","#ffc6ff"]
|
||||
cols4 = ['#8dd3c7','#ffffb3','#bebada','#fb8072','#80b1d3','#fdb462','#b3de69','#fccde5','#d9d9d9']
|
||||
|
||||
def test():
|
||||
# initialize the genealogy
|
||||
G = mathGenealogy("example.db")
|
||||
|
||||
# add all ancestors and descendants of the starting vertices to the graph
|
||||
|
||||
for ID in IDs:
|
||||
G.add_ancestors(ID)
|
||||
G.add_descendants(ID)
|
||||
|
||||
# pin all starting vertices at the same level
|
||||
G.fixed_level(IDs)
|
||||
|
||||
# Color the graph
|
||||
G.color_graph_CSS(cols1)
|
||||
# Draw the graph
|
||||
G.draw_graph("example.dot", "pdf", clean=False)
|
||||
return(G)
|
||||
|
||||
def redraw(color, graph):
|
||||
graph.color_graph_CSS(color)
|
||||
graph.draw_graph("example.dot")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# testDB = mathDB("test.db")
|
||||
G = test()
|
||||
Reference in New Issue
Block a user