Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3678972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:24:16+00:00 2026-05-19T03:24:16+00:00

I need to draw a circle around a vertex in JUNG . The circle

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:24:16+00:00Added an answer on May 19, 2026 at 3:24 am

    Something like this, I guess. This will give you points for circle with given radius. To adjust resolution of points change x+=0.01 to a bigger/smaller value as needed. To move circle centre to an arbitrary point (p,q), just add it to (x,y), that is plot(x+p,y+q);.

    double radius = 3;
    for (double x = -radius; x <= radius; x += 0.01) {
        double y = Math.sqrt(radius * radius - x * x);
        plot(x, y);//top half of the circle
        plot(x, -y);//bottom half of the circle
    }
    

    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. CircleLayout and KKLayout seem to do the trick, though CircleLayout gives strange results for when there are many nodes. Here’s complete sample code:

    //Graph holder
    Graph<Integer, String> graph = new SparseMultigraph<Integer, String>();
    
    //Create graph with this many nodes and edges
    int nodes = 30;
    for (int i = 1; i <= nodes; i++) {
        graph.addVertex(i);
        //connect this vertext to vertex+1 to create an edge between them.
        //Last vertex is connected to the first one, hence the i%nodes
        graph.addEdge("Edge-" + i, i, (i % nodes) + 1);
    }
    
    //This will automatically layout nodes into a circle.
    //You can also try CircleLayout class
    Layout<Integer, String> layout = new KKLayout<Integer, String>(graph);
    layout.setSize(new Dimension(300, 300)); 
    
    //Thing that draws the graph onto JFrame
    BasicVisualizationServer<Integer, String> vv = new BasicVisualizationServer<Integer, String>(layout);
    vv.setPreferredSize(new Dimension(350, 350)); // Set graph dimensions
    
    JFrame frame = new JFrame("Circle Graph");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(vv);
    frame.pack();
    frame.setVisible(true);
    

    I have picked SparseMultiGraph because 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 StaticLayout that 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to draw a circle onto a bitmap in a specific colour given
I need to draw a circle to display the distance around a point that
I need to draw a rectange,circle and line and then animate them(press left ->
I need to have all point coordinates for a given circle one after another,
So I've been messing around with http://processingjs.org/ . I want to draw a circle
I need to draw Line, Circle, and rectangle by mouse drag on canvas and
I need draw rectangle with two circle holes inside. The problem is in circles
I need to draw a circle as per my finger move so i have
I need to draw a circle in google Maps V3 but I have 2
Please see the code below. I am trying to draw a circle around a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.