| | |
Finding path in a graph using linked list
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
•
•
Hi everyone,
I've been working on this for days, but just can't get it. I have a linked-list containing edges of a weighted directed graph, and my goal is to find a path from vertex A to vertex B going through exactly n nodes. Anyone has suggestions, or links with examples? Thank you!!!
•
•
Join Date: Dec 2006
Posts: 14
Reputation:
Solved Threads: 0
I'm thinking of using something like BFS, that would just go out and label nodes by degree of closeness to given node, but thats not too efficient, I've also tried Dijkstra approach, because my other priority is to minimize that path in terms of length, but I don't think I can use it. My current plan is to use greedy approach starting at node A and go to a node n-1 far from it, then seeing if that node is directly connected to B. If it is - good, but if not then I'd have to roll back to n-2, and try to go to B from there via another node. If that fails, roll back to n-3...etc. Should I use recursion for this approach?
![]() |
Similar Threads
- Removing an item from head of linked list (C)
- Minimal element in a linked list? (Computer Science)
- Cannot figure out how to implement linked list and rbtree for a project! (Java)
- Linked List (C++)
- help by sorting a simply linked list (C)
Other Threads in the C Forum
- Previous Thread: setting port in linux and windows
- Next Thread: Beep the PC internal speaker
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez graphics gtkgcurlcompiling gtkwinlinux hardware highest homework i/o ide inches initialization intmain() iso km license linked linkedlist linux linuxsegmentationfault list logical_drives loopinsideloop. lowest match matrix microsoft motherboard mqqueue multi mysql oddnumber odf open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string strings suggestions test testautomation unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi





