Thread: Still working on my graphs program - need help with efficiency

  1. #1
    Registered User Lost__Soul's Avatar
    Join Date
    Mar 2003
    Posts
    82

    Question Still working on my graphs program - need help with efficiency

    Well,this post is related to my last one(that program to calculate the maximum flow along a directed graph: Post - "segmentation fault")
    I have been quite occupied in the last few days so only looked again to my program today.After analysing it carefully,i realized that the effience problem was due to the somador function.It has to see the peso of an element of the list,but the element could be far away in the list,which takes a lot of time if we consider the big files.So,this is what i´m trying to do now:
    1.compute the first flow
    2.then start moving backwards
    3.in the next sum only add the new nodes

    For example,if i have the path 1234567 and i have a new transition only from 5 to 7,the path becomes 123457 but i dont need to calculate the 12345 path again,because it has been calculated before.So,when i move backwards one node,the flow is subbed the peso from the last transition. The problem is getting to somador and knowing the number of new nodes.I'm using a variable but dont know exactly where it sould be dec and incremented...Can anyone help me with this?2 more days left for the delivery of the project...

  2. #2
    Registered User Lost__Soul's Avatar
    Join Date
    Mar 2003
    Posts
    82
    yep,but i wanted the longest path one...i tried to reduce the number of calculations in my algoritm,but still too much time.do u know where i can find an implementation of the longest path algorithm(or the shortest,i guess the only thing i have to change is sum the highest value instead of the lowest)...I read some of the pages in google,but dont understand very wel that algorhitm...

    My problem is that every change i made in my code to make it more efficient,could be usefull,but not enough...I heard that that paths algorhitms check every path simultaneously,in order to compute the longest (or the shortest) one.But that would implie too many changes in my code,and i obviously dont have time for that.So i need sugestions.Things i can do that really affect effiency..
    Last edited by Lost__Soul; 04-30-2003 at 11:57 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. my serial port data reading program isn't working
    By gnychis in forum C Programming
    Replies: 5
    Last Post: 06-02-2005, 08:40 AM
  2. Replies: 5
    Last Post: 02-02-2003, 10:56 AM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  4. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 08:04 AM
  5. Simple Program not working right (in C)
    By DruzeTito in forum C Programming
    Replies: 5
    Last Post: 06-01-2002, 10:14 PM