![]() |
|
#1
|
|||
|
|||
STL listsi 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
|
|||
|
|||
Re: STL listsQuote:
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
|
||||
|
||||
Re: STL listsIt 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 GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
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