Results 1 to 6 of 6
  1. #1
    Crazeal is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default undirected graph

    can i draw undirected graph when no. of nodes are given and its connection
    data set id:
    FROM TO
    0 5
    4 3
    0 1
    9 12
    6 4
    5 4
    0 2
    11 12
    9 10
    0 6
    7 8
    9 11
    5 3


    i am making gui using swing,,,but how to represent graph using graphics?i want smthing like this
    Attachment 3279

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: undirected graph

    You can use the Java2D classes to draw things. I would imagine you need to come up with an algorithm that creates a layout for all the vertices such that there is minimum overlap of the edges, and then just connect the dots.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: undirected graph

    Quote Originally Posted by quad64bit View Post
    You can use the Java2D classes to draw things. I would imagine you need to come up with an algorithm that creates a layout for all the vertices such that there is minimum overlap of the edges, and then just connect the dots.
    It's quite a fascinating problem to find (x,y) coordinates (in 2D space) for the vertexes such that none of the edges cross each other. (if such a configuration exists).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Crazeal is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: undirected graph

    i have tried alot,,can you pls help me with the code

  5. #5
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default Re: undirected graph

    which code? the attachment is invalid!

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: undirected graph

    Quote Originally Posted by Crazeal View Post
    i have tried alot,,can you pls help me with the code
    It's your problem so you have to solve it; show us the 'lot' you have tried and where you failed.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 16
    Last Post: 03-21-2012, 09:41 AM
  2. ECG Graph
    By bharath333 in forum Java Applets
    Replies: 4
    Last Post: 02-14-2009, 10:26 PM
  3. Bar Graph
    By Zosden in forum Advanced Java
    Replies: 2
    Last Post: 04-28-2008, 06:52 AM
  4. Help with graph's bar
    By coco in forum Java 2D
    Replies: 1
    Last Post: 08-07-2007, 07:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •