As others have said, you need to ponder what “shape” means to you. Then, I suggest that you consider generating a simple list of (start_node, end_node) tuples. Sort this list, thus placing the identical node-names conveniently next to one another, and count them. Or, stuff the data into an SQLite database (file...) and let it do the dirty work for you. (They are fast, they are “just files,” and yet you can query them.)
You might decide, for instance, that the “shape” of a node is defined by the number of nodes that connect to or from it. You might calculate the “depth” of each node and then count the number of connections at the same depth. Or, whatever you decide is right for you.