Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: neighbourlist

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    68
    My Mood
    Cool
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default neighbourlist

    Hey

    i jst developed a basic model for finding neighbours.

    the program runs a for loop to generate x,y arrays randomly .
    x[] has x coordinates
    y[] has y coordinates

    of the nodes.

    then using two for loops i calculate the distance between two nodes for each node.
    if the dist< range i want to put the other node in my neigboutlist.

    Since i have the coordinates of a node and its neighbours ,please suggest me how can i store and reference them in an organized way??

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: neighbourlist

    Since i have the coordinates of a node and its neighbours ,please suggest me how can i store and reference them in an organized way??
    Java is object-oriented, so I'd suggest created classes that define the data structure you need. For what its worth, there may be other methods to more efficiently accomplish what you need, for example a kd-tree.

  3. #3
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: neighbourlist

    The java.awt.geom.Point2D class can do all this for you, but assuming you want to write the algorithms yourself, why not start with a Node class containing the X & Y ordinates?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: neighbourlist

    See posts at Flag and data passing

    Looks like the same topic