<jupyter_start><jupyter_text>* Traveling Salesman* Complete Binary tree* Spanning Tree* Bipartite Graph* Shortest Path Tree<jupyter_code>import pygraphviz as pgv
from IPython.display import Image
from IPython.display import display
def random_alphabet(N=20, first_letter='A'):
    """Generates unique strings to be used as index_names"""
    if N<27:
        alphabet = [chr(i+ord(first_letter)) for i in range(N)]
    else:
        alphabet = ['X'+str(i) for i in range(N)]    
    return alphabet

def random_parents(alphabet, max_indeg=3):
    """Random DAG generation"""
    N = len(alphabet)
    print(alphabet)
    indeg = lambda: np.random.choice(range(1,max_indeg+1))
    parents = {a:[b for b in np.random.choice(alphabet[0:(1 if i==0 else i)], replace=False, size=min(indeg(),i))] for i,a in enumerate(alphabet)}
    return parents

def show_dag_image(index_names, parents, imstr='_BJN_tempfile.png', prog='dot'):
    name2idx = {name: i for i,name in enumerate(index_names)}
    A = pgv.AGraph(directed=True)
    for i_n in index_names:
        A.add_node(name2idx[i_n], label=i_n)
        for j_n in parents[i_n]:
            A.add_edge(name2idx[j_n], name2idx[i_n])
    A.layout(prog=prog)
    A.draw(imstr)
    display(Image(imstr))
    return 

index_names = random_alphabet(9)
parents = random_parents(index_names, 3)
show_dag_image(index_names, parents, prog='circo')
%connect_info<jupyter_output>{
  "stdin_port": 57484, 
  "ip": "127.0.0.1", 
  "control_port": 57485, 
  "hb_port": 57486, 
  "signature_scheme": "hmac-sha256", 
  "key": "<KEY>", 
  "shell_port": 57482, 
  "transport": "tcp", 
  "iopub_port": 57483
}

Paste the above JSON into a file, and connect with:
    $> ipython <app> --existing <file>
or, if you are local, you can connect with just:
    $> ipython <app> --existing /Users/cemgil/Library/Jupyter/runtime/kernel-28aae665-e995-49c2-a35c-c1740b4d8c4f.json 
or even just:
    $> ipython <app> --existing 
if this is the most recent IPython session you have started.
{'fraction_non_alphanumeric': 0.13316708229426433, 'fraction_numerical': 0.034912718204488775, 'mean_word_length': 4.104325699745547, 'pattern_counts': {'":': 9, '<': 10, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '514853', 'license': 'MIT', 'n_tokens_mistral': 801, 'n_tokens_neox': 743, 'n_words': 184, 'path': 'DrawGraphs.ipynb', 'repo_name': 'onurboyar/notes', 'size': '2036'}