Hallo friends i have particular number of nodes in a box. I need to connect all these nodes as a teravalent network. I have no idea how to proceed for this task. Please give me,atleast, idea to proceed.

Thanks for your help,

You need to explain what you mean.

Are you asking for a generic algorithm, is this a GUI application etc?

Yes each node represent an atom and i need to connet all these atoms as a tetravalent nettwork. No GUI involved here i need logic only to write program in C++

thanks,

how can i connect to get tetrvalen network with these nodes. i have idea about linked lists...but i need logic for tetravalent network...

Thanks,

It depends on how you plan to form the bonds.

If you just want to "shake the box" and let atoms connect, then you'll have to use a loop to look through what kinds of atoms you have and connect them by linking nodes.

For example, if one of the nodes identifies itself as a carbon atom, and you can find another four hydrogen atoms, then you can bind them together by linking the carbon node's four links/pointers to a hydrogen node each, and linking each hydrogen node's link/pointer to the carbon node.

Thereafter, examining any one of the linked atoms leads to the entire covalent molecule, and only encountering different atom(s) in the box that could combine for in a more convenient bond would be reason to break up the methane molecule.

Hope this helps.

Hi thanks for ur reply...but i can sure that these are connected as a tetravalent shape....

It depends on the atom.

Carbon is a tetravalent element, so all you have to do is check to see that all four links are not NULL.

For example:
[edit] good grief, sometimes editing is such a pain...

struct atom_t
  {
  std::string   name;
  double        weight;
  vector <atom_t*> bonds;

  atom_t( const std::string& name, double weight, int valence ):
    name( name ), weight( weight ), bonds( valence )
    { }
  };

atom_t* carbon()   { return new atom_t( "carbon",   12.0107, 4 ); }
atom_t* hydrogen() { return new atom_t( "hydrogen", 1.00794, 1 ); }

...
This article has been dead for over six months. Start a new discussion instead.