[SOLVED] Graphviz doesn't draw all dependencies


I’m coding a neural network with Python (v3.9.10) in NumPy (v1.19.5) and want to draw a graph of all the dependencies using GraphViz(v latest) for JupyterLab (v3.2.8). Like what’s seen in ML papers! I’m having issues showing all the functional dependencies, however. My output graph has width but not depth, and I’d like to know what can be done to fix this. I think it may be due to for loops, but I’d prefer knowing something more general.


from fn_graph import Composer
import pygraphviz

def alpha(a, b, c):
    empty_list = []
    q = []
    for j in range(len(a)):
        q.append(f2(a, b, c))
    return q, empty_list

def beta(a, b, c):
    p = gamma(a, b, c)
    return a + b, p

def gamma(a, b, c):
    return alpha(a, b, c)

composer5 = Composer().update(alpha, beta, gamma)


generated graphviz

Expected output:

A link from alpha to gamma, and another from gamma to beta; something that looks more hierarchical. Can I have some tips?


This appears to be working as designed:

That principle idea behind Fn Graph is to use the names of a functions arguments to find that functions dependencies, and hence wire up the graph.

You aren’t providing alpha, beta, or gamma as arguments to each other. Do you mean to do something like this instead?

composer = Composer().update(a=alpha, b=beta, c=gamma)

Or to pass the functions into each other, like this?

def gamma(alpha, a, b, c):
    return alpha(a, b, c)

Answered By – Chris

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *