Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Network nodes simulation using arrays

 
Syed@7
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am try to do a simulation for a computer network.My objective is to interconnect nodes to each other.For e.g node1 is connected to node3,4,5 and so on.I am using an array of 500 elements for this. The nodes are randomly connected to each other.So for e.g. how do i make the elements 3,4,5(nodes) refer to element 1(node).
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a type of LinkedList would work better than an array for that.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe give each Node a collection of connected Nodes. Then your Network could do things like:

Now you can randomly select two Nodes from your array and connect them.

Does that get you started?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic