0

I am trying to solve a trip assignment problem (transport planning). Available data is this: trips between nodes and links shapefile with 'from' and 'to' (match with those in trips data) codes. The approach i am adopting is this:

  • take each Origin-Destination pair from trip data
  • find all the possible paths between that OD pair
  • sort those paths based on length
  • start with smallest path and assign trips to that path until its capacity is reached
  • then take 2nd smallest and assign the trips...and so on

the problem i am facing is at 2nd step. I am using all_simple_paths() to get all possible paths between two nodes but it is taking too long. Here is that line

paths_between <- all_simple_paths(g_2, from = "240", to = "14")

how to work around this? is there any algorithm that I can use to get all possible paths? any help would be appreciated. thank you.

Satya Pamidi
  • 143
  • 8
  • 3
    You should take the size of your graph into consideration, which determines the complexity. See possible related https://stackoverflow.com/questions/1830607/complexity-of-finding-all-simple-paths-using-depth-first-search – ThomasIsCoding Sep 20 '22 at 09:40
  • 3
    How many nodes do you have? It is unlikely that you will get anything faster than the algorithm for `all_simple_paths`. The problem is that with anything other than a very small graph, you are going to have more simple paths than your computer can hold in memory. Even with 30 nodes, and an average of only 2 edges per node, the number of simple paths between any two nodes can easily exceed 100,000. This rises exponentially, such that much above 30 nodes or more than two edges per node will cause your computer to run out of memory. – Allan Cameron Sep 20 '22 at 09:57
  • `V(g_2)` is telling me that i have 517 vertices. if `all_simple_paths` is the fastest then maybe i need to look for other approaches. is there any other approach that you can think of instead going with the pre-built algorithm? i tried to read it as a df and tried different approaches but couldn't find any satisfactory solution. – Satya Pamidi Sep 20 '22 at 10:30

0 Answers0