2

I want to compare several routing algorithms in terms of time needed to find the shortest path between two nodes in directed acyclic graph (DAG).

I wrote code for the algorithms, but I am having problem to generate DAG for which it is computationally complex to find the shortest path. For example, when I generated 100-node DAG by following this approach, the graph was very connected and for any combination of source and destination nodes I got three-hop long route in the "best" case.

Any idea how to overcome this problem?

Community
  • 1
  • 1
user2683229
  • 67
  • 1
  • 7
  • Do you want a path that is "long" or one that is difficult to find? You can make a simple circular graph (e.g., each node with one edge pointing to the next, and the last pointing to the first) with paths as long as you like. – BrenBarn Feb 07 '16 at 21:35
  • Perhaps this approach helps: generating the DAG from a random matrix ([link](http://mathematica.stackexchange.com/a/613)). – Norman Feb 07 '16 at 21:37

1 Answers1

1

Let your graph be a union of a path and a "half complete graph". A "half complete graph" (sorry for the silly name) is a graph, where you connect each node to all other nodes with higher id (eg. 1 -> 2, 1 -> 3, 2 -> 3). This guarantees a big number of edges (due to the "half complete graph") and a long shortest path because of the path. You can connect some of the nodes in the path to nodes in the "half complete graph".

Example

Graph with 14 nodes:

1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10
11 - 12
11 - 13
11 - 14
12 - 13
12 - 14
13 - 14
2 - 13
4 - 14
You can continue adding edges from nodes 1-9 to nodes 11-14

Find a path between 1 and 10.

David Frank
  • 5,918
  • 8
  • 28
  • 43
  • I need an idea for algorithm that will generate DAG. If I keep adding edges on my own (but randomly) as you suggested, at the end I could get short route as optimal solution again. – user2683229 Feb 08 '16 at 00:01
  • @user2683229 You should always constrain yourself to the method above. You should not add edges totally randomly, instead you should follow the steps described above (ie. create a path and a the half complete graph). Node 1 and 10 in the above example will not be reachable through any of the other points, only 2-3-4-5-6-7-8-9. This will guarantee the length. – David Frank Feb 08 '16 at 00:26