### Seeking A Scaling Equation

by jthalhammer (Friar)
 on Jul 25, 2013 at 16:41 UTC Need Help??
jthalhammer has asked for the wisdom of the Perl Monks concerning the following question:

This has more to do with math than Perl, but there is a connection...

I'm trying to figure out an equation for scaling the dependency graphs on Stratopan such as the one seen here. I need to compute the inner and outer radius (in pixels) of the graph based on the number of nodes. As the number of nodes increases, the inner and outer radius need to be larger to accommodate them all.

Also, suppose I want to impose some boundaries. As the number of nodes approaches 200, the outer radius must asymptotically reach 600 to fit on a typical screen. At the same time, the inner radius must asymptotically reach about 200 (so the nodes are not too close together). Going in the other direction, The outer radius must not get any smaller than about 300 and the inner radius must not get any smaller than about 100. There could be 1 or 1000 nodes, but the dimensions must stay within those boundaries.

So that is the basic problem. I looked into using a logarithm, but it has been a long time since I sat in a math class so I couldn't figure out how to apply them. I can figure out how to tune the constants if you can point me in the right direction.

-Jeff

Replies are listed 'Best First'.
Re: Seeking A Scaling Equation
by BrowserUk (Pope) on Jul 25, 2013 at 17:02 UTC

In the example, there are 40 nodes. Assuming a font with a maximum height of 10 pixels, and a 10 pixel gap between, you need a circumference of:

40 * ( 10 + 10 ) == 800. So the inner radius is 800 / 2 π == 127.

The outer radius will be a function of the font size and the string lengths.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Very clever. I didn't think in terms of how much space each node occupied along the circumference. That approach will give me the radius that minimizes the circumference whilst keeping the nodes legible. Which is definitely better than what I had.

But what I really want is non-linear scaling. So as the number of nodes becomes smaller, the space between them bigger. And the opposite is true when the number of nodes gets larger.

I can easily cap the upper limit on the radius so that the graph doesn't go off the screen (although the nodes may start to overlap, which is ok at that point). But I need the lower limit on the radius to converge on some constant so that a small number of nodes aren't packed together so tightly.

Does that make sense?

But I need the lower limit on the radius to converge on some constant so that a small number of nodes aren't packed together so tightly.

Calculate the radius per above and then if its less than 100 (or whatever you settle on ) set it to 100.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Create A New User
Node Status?
node history
Node Type: perlquestion [id://1046387]
Approved by BrowserUk
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2017-08-19 19:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (312 votes). Check out past polls.

Notices?