+ Reply to Thread
Results 1 to 12 of 12

Need help to solve floyd warshall shortest path with vba

  1. #1
    Registered User
    Join Date
    04-20-2017
    Location
    Southampton, England
    MS-Off Ver
    MS Office 2013
    Posts
    4

    Need help to solve floyd warshall shortest path with vba

    Hi everyone,
    I'm a new vba user and struggling with a problem finding the shortest path by using floyd warshall theory and vba. Basically, I need to find the shortest path between each pairs of the users, then find the diameter which is the greatest length of any .I need to create an userform which can load any provided files (same format of the content with the file attached). I've finished validating data and loading the file. However, I just can do the coding with a specific small number of nodes (6 in this cases). Hereunder is the code I've done. Can you guys please help me to solve this so that I can run the analysis with any provided files no matter how many nodes (users) it has? thank you very much!

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jimnguyen94; 04-22-2017 at 01:00 PM. Reason: Added missing CODE tags, please read and follow the forum rules, link above in the menu bar. Thanks.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need help to solve floyd warshall shortest path with vba

    Hello jimnguyen9,

    Your post caught my interest. This algorithm is used in many different fields and has been translated into many other computer languages. Oddly though, my research has shown no examples of the Floyd-Warshall algorithm in VBA.

    I created an easy to use workbook that displays three matrices: Edge distances, Shortest paths, and Precedents. The user simply enters the input data in columns "A:C" starting at row 2. Column "A" holds the start node labels, Column "B" holds the end node labels and Column "C" holds the node distance (also called weight or cost). Once done, click "Run" and all 3 matrices are computed. Each matrix occupies a worksheet. This allows a maximum of 16384 node values in Excel 2007 and later.

    While this workbook does not directly address all of your concerns, it can serve as a guide to coding what you still need. The code is extensively documented. However, I know there will be questions that are not answered in the code comments. Please fell free to ask me questions that come up.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need help to solve floyd warshall shortest path with vba

    Can this help?

    http://www.blackcreekbedandbreakfast.ca/node/10715
    https://rosettacode.org/wiki/User:Klever

  4. #4
    Registered User
    Join Date
    07-10-2018
    Location
    bogota
    MS-Off Ver
    2018
    Posts
    4

    Re: Need help to solve floyd warshall shortest path with vba

    Hi Leith Ross,

    I was wondering if you could help with the Floyd- Warshall Algorithm. I have already seen your macro and I was wondering if it is possible to change it for 15 nodes (matrix 15x15) I tried to change the code but it has a password.

    Thank you,

    Maria

  5. #5
    Registered User
    Join Date
    07-10-2018
    Location
    bogota
    MS-Off Ver
    2018
    Posts
    4

    Re: Need help to solve floyd warshall shortest path with vba

    Hi,

    I was wondering if you could help with the Floyd- Warshall Algorithm. I have already seen your macro and I was wondering if it is possible to change it for 15 nodes (matrix 15x15) I tried to change the code but it has a password.

    Thank you,

    Maria

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need help to solve floyd warshall shortest path with vba

    Hello Maria ,

    I never password protect workbooks that I post here in the forum. I downloaded the file and there is no protecting. Are you sure Excel is asking for a password and not asking you to enable editing?

  7. #7
    Registered User
    Join Date
    07-10-2018
    Location
    bogota
    MS-Off Ver
    2018
    Posts
    4

    Re: Need help to solve floyd warshall shortest path with vba

    Hi Leith,

    Thank you for your reply. I already found the code, but now I donīt understand how yo define the size of the matrix. Can you please explain me?

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need help to solve floyd warshall shortest path with vba

    Hello Maria,

    Back in Post #2 I said..
    I created an easy to use workbook that displays three matrices: Edge distances, Shortest paths, and Precedents. The user simply enters the input data in columns "A:C" starting at row 2. Column "A" holds the start node labels, Column "B" holds the end node labels and Column "C" holds the node distance (also called weight or cost). Once done, click "Run" and all 3 matrices are computed. Each matrix occupies a worksheet. This allows a maximum of 16384 node values in Excel 2007 and later.
    All matrices are 2 dimensional with an equal number of rows and columns. The algorithm uses the data input into columns A:C. The maximum number of unique start/stop nodes defines the input matrix dimensions. In the examples shown in the workbook I posted, the input matrices vary from 4x4 to 6x6. There is nothing for you to change. Just input data as described and run the algorithm.

  9. #9
    Registered User
    Join Date
    07-10-2018
    Location
    bogota
    MS-Off Ver
    2018
    Posts
    4

    Re: Need help to solve floyd warshall shortest path with vba

    Thank you !

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need help to solve floyd warshall shortest path with vba

    Hello Maria,

    De nada.

  11. #11
    Registered User
    Join Date
    12-14-2017
    Location
    INDIA
    MS-Off Ver
    2017
    Posts
    5

    Re: Need help to solve floyd warshall shortest path with vba

    Hi Leith,
    if i also want to find the full path nodes name with other optional path detail in same sheet then how?

  12. #12
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,601

    Re: Need help to solve floyd warshall shortest path with vba

    sks4444,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Shortest Path Between Cells (VBA)
    By basschmidt in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-18-2018, 06:07 PM
  2. Shortest Path between Locations (without repeating)
    By ciaran3 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-05-2017, 10:43 AM
  3. VBA that calculates the shortest path
    By den_1985 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-05-2016, 05:58 AM
  4. Shortest path problem with excel solver
    By halatehini in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-11-2016, 12:51 PM
  5. A little complex problem (Floyd algorithm path)
    By Kb24 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-09-2009, 11:31 AM
  6. Floyd Algorithm, need help with path Matrix..
    By Kb24 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2009, 03:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1