473,396 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

linked list issue

momotaro
357 100+
originaly am using these structers to impliment my graph:

Expand|Select|Wrap|Line Numbers
  1.  typedef struct _edge edge; 
  2.  
  3. typedef struct _vertex vertex;
  4.  
  5.  
  6.  
  7. struct _edge
  8.  
  9. {
  10.  
  11. char CarId[10];
  12.  
  13. int distance;
  14.  
  15. edge *NextEdge;
  16.  
  17. };
  18.  
  19. struct _vertex
  20.  
  21. {
  22.  
  23. char CarId[10];
  24.  
  25. int x,
  26.  
  27. y;
  28.  
  29. vertex *NextVertex;
  30.  
  31. edge *NextEdge;
  32.  
  33. };
  34.  
  35.  
how should i buil my 2D linked list to build the graph ?
Nov 23 '07 #1
3 1315
Ganon11
3,652 Expert 2GB
I would have each vertex have a set of edges (maybe in a linked list of edges?) that lead away from that vertex, and have each edge hold a Vertex *to, Vertex *from, and int weight variable. Your current implementation looks like it will be messy.
Nov 23 '07 #2
momotaro
357 100+
my ides is to read the first vertex and then its adjacency list then link the previous vertex to the next and redo the work...
basicaly the code will lay out like:

for(vertices)
{
add vertex
for(adjacency list starting from the next vertex in the file)
{
add edge
}
}

what do you think is it possible?
Nov 23 '07 #3
momotaro
357 100+
what about this one:

Expand|Select|Wrap|Line Numbers
  1.  struct edge 
  2. {
  3.  
  4.  
  5. CarID[10]; 
  6.  
  7. int distance; 
  8.  
  9. edge *NextEdge; 
  10. }; 
  11.  
  12. struct vertex 
  13.  
  14.  
  15.  
  16. CarID[10]; 
  17.  
  18. int x, 
  19.  
  20. y; 
  21.  
  22. edge *E; 
  23.  
  24. vertex *NextVertex; };
  25.  
Nov 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chris Ritchey | last post by:
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am...
11
by: fighterman19 | last post by:
because in linked list each node contains only one digit like curr->nodevalue_1= 0 curr->nodevalue_2=1 sum->nodevalue = curr->nodevalue_1 + curr->nodevalue_2 so when the number go up to >10...
33
by: junky_fellow | last post by:
Consider a singly-linked list. Each node has a structure, struct node { char c; struct node *next; }; Each of the nodes contain an alphabetic character. Can anybody suggest a way to print...
4
by: dssuresh6 | last post by:
Whether browsing forward or backward can be done using a singly linked list. Is there any specific case where a doubly linked list is needed? For people who say that singly linked list allows...
4
by: JS | last post by:
I have a file called test.c. There I create a pointer to a pcb struct: struct pcb {   void *(*start_routine) (void *);   void *arg;   jmp_buf state;   int    stack; }; ...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
17
by: darrell.blake | last post by:
I've just written a doubly linked list but when I tell the iterator to move forward in the list it removes all the previous elements in the list. i.e. If I were to do: List list; ...
9
by: gamehack | last post by:
Hello all again, Sorry for troubling you with my problems. I've tried to implement simple double linked lists, here's my structure: struct DResult { double val; char* title; struct DResult*...
17
by: 2005 | last post by:
Hi In C++, are the following considered best practices or not? - passing aguments to functions (ie functions do not take any arguments ) - returning values using return statement Anything...
6
by: mattmao | last post by:
Okay, this is just my exercise in order to prepare for the coming assignment regarding the damned Linked List issue... The task is simple and I am about to finish it. However, I couldn't go around...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.