I need to draw a circle around a vertex in JUNG. The circle is defined by the vertex as center and a given radius r.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Something like this, I guess. This will give you points for circle with given
radius. To adjust resolution of points changex+=0.01to a bigger/smaller value as needed. To move circle centre to an arbitrary point(p,q), just add it to(x,y), that isplot(x+p,y+q);.EDIT: It appears that JUNG is not really an XY-plot but a network/graph framework. So all you need is to layout your points in a circle using one of provided layouts.
CircleLayoutandKKLayoutseem to do the trick, thoughCircleLayoutgives strange results for when there are many nodes. Here’s complete sample code:I have picked
SparseMultiGraphbecause that’s what was in JUNG tutorial. There are other types of graphs, but I am not sure what the difference is.You could also use a
StaticLayoutthat can take(x,y)vertices, then use my original code to plot the points, but that would not be as elegant for JUNG framework. Depends on what your requirements are, however.