springer-math / Mathematics-of-Epidemics-on-Networks

Source code accompanying 'Mathematics of Epidemics on Networks' by Kiss, Miller, and Simon http://www.springer.com/us/book/9783319508047 . Documentation for the software package is at https://epidemicsonnetworks.readthedocs.io/en/latest/
MIT License
151 stars 61 forks source link

Adjust node sizes in trees that have large depths? #71

Open rocky opened 3 years ago

rocky commented 3 years ago

Hi - I am using the tree layout portion in an open-source version of the Wolfram Language called Mathics.

Specifically, the use is here so if I have missed something in citation let me know so I can fix.

A problem I noticed is that the nodes meld into one another when the tree is large. Probably it would be good to reduce their size just as is done with line widths.

Here is an example.

When I run:

$ !math
mathicsscript

Mathics 1.1.0dev
on CPython 3.8.6 (default, Nov  3 2020, 05:28:03) 
using SymPy 1.6.2, mpmath 1.1.0

Copyright (C) 2011-2020 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.

Quit by pressing CONTROL-D

In[1]:= LoadModule["pymathics.graph"]
Out[1]= pymathics.graph
In[2]:= BalancedTree[2,8]

I get: full-binary-tree

joelmiller commented 3 years ago

Interesting to see where this is being used.

The layout I've created provides node positions for networkx's drawing methods. So all this method produces is the coordinates of the nodes - it doesn't do the work to draw them. The methods from networkx allow you to specify the node sizes, so check in the methods you're using to see where the drawing actually happens. There's probably a way to set up the node size there.

rocky commented 3 years ago

Ok. Thanks for the information.

If there is a simple way to list positions of a node a given level c it is probably a simple matter to compute the maximum diameter/width of a node as a percentage of the space between nodes.

After understanding a little more context about what's up, it was pretty simple to adjust the code to compute the min separation between nodes at a level in this function so that information can be used to adjust matplotlib's markersize