Scaling node coordinates to a fixed graph size

  • Thread starter mcnkevin
  • Start date
  • #1
6
0
Hi, suppose i have various graphs which each have many nodes. In one graph the nodes x and y values may be within the range 0-1000, in another the x values may range from 100-500 and the y values from 300-800. Basically, the ranges always vary and there is no consistency.

I need a way to scale the values of the x and y coordinates such that they fit inside a fixed graph size (say 500 by 500) such that the graph retains in basic layout and relative distances between nodes.

Probably not that hard a question, i just cant figure it out :). Thx for any help.
 

Answers and Replies

  • #2
HallsofIvy
Science Advisor
Homework Helper
41,833
956
If your graph x and y range from 0 to A and you want it to fit inside 0 to B, multiply all coordinates by B/A.

For example, if you x and y coordinates are always between 0 and 1000 and you want it to fit inside 0 to 500 multiply all coordinates by 500/1000= 1/2. So, for example, the point (900,800) would change to (450, 400).
 

Related Threads on Scaling node coordinates to a fixed graph size

  • Last Post
Replies
1
Views
667
Replies
5
Views
2K
  • Last Post
Replies
1
Views
1K
Replies
5
Views
670
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
3
Views
639
Replies
4
Views
34K
  • Last Post
Replies
10
Views
2K
  • Last Post
Replies
7
Views
1K
Top