GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 12-Nov-2008, 02:00
xlonehats xlonehats is offline
New Member
 
Join Date: Sep 2007
Posts: 20
xlonehats is on a distinguished road
Question

STL lists


i have to add an [edge/vertex], delete, edit of a graph

how do we go about implenting this using STL lists

do we have to create a class to store vetices and edges
any sample code would be really helpful
  #2  
Old 12-Nov-2008, 03:37
cpit cpit is offline
Junior Member
 
Join Date: Jan 2006
Posts: 73
cpit is on a distinguished road

Re: STL lists


Quote:
Originally Posted by xlonehats
i have to add an [edge/vertex], delete, edit of a graph

how do we go about implenting this using STL lists

do we have to create a class to store vetices and edges
any sample code would be really helpful

Please, give us more detail about what you have to do, and what is your doubt.

For now, I can say that you can create a class to hold the adjacency matrix. This may be done as a two-dimension matrix, where the elements are a <vector> (vector<vector<int> > v). However, if you have to add more attributes to an edge (like weight) you have to add another dimension (or change the "int" by a struct.

I hope this help.
  #3  
Old 12-Nov-2008, 07:03
Blake's Avatar
Blake Blake is offline
Member
 
Join Date: Nov 2005
Posts: 255
Blake is a jewel in the roughBlake is a jewel in the rough

Re: STL lists


It sounds like he's trying to use an adjacency list, not an adjacency matrix.

The simplest solution would be to use an slist<int> where each integer in the list is the index of a vertex (assuming that the vertices are stored in an array or vector).
__________________
www.blake-foster.com
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked Lists Database... TS3BxL C++ Forum 10 19-Mar-2008 23:37
How to add select lists dynamically venkib097 MS Visual C++ / MFC Forum 0 31-Aug-2007 01:51
Linked Lists problem kracivi C Programming Language 1 01-May-2007 09:40
Why initialization lists are better? dexter C++ Forum 1 07-Apr-2005 10:48
Help creating lists of pointers The_Kingpin C Programming Language 0 11-Dec-2004 14:49

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:08.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.