| 1 |
GRAPH.TXT : text description of a graph |
| 2 |
|
| 3 |
$ cr_from_a --file=GRAPH.TXT --graph=graph.dgl |
| 4 |
|
| 5 |
read GRAPH.TXT and create graph.dgl |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
$ view --graph=graph.dgl |
| 11 |
|
| 12 |
View the graph.dgl content (node attributes are not printed) |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
$ shortest_path --graph=graph.dgl --from=1 --to=80 |
| 18 |
|
| 19 |
Figure out shortest path from node 1 to node 5 |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
How to store X/Y/Z node coordinates: |
| 24 |
|
| 25 |
Node coordinates can be assigned as node attributes. In the GRAPH.TXT file |
| 26 |
lines beginning with 'A' are arcs, lines beginning with 'N' are node attributes. |
| 27 |
Each coordinate is stored as 32 bit integer. Thus when creating the graph |
| 28 |
(cr_from_a.c) I reserved 12 bytes for xyz values. |
| 29 |
See the GngSetNodeAttr() usage in cr_from_a.c |
| 30 |
The node attributes are passed back to the clip_node() callback during Dijkstra |
| 31 |
so that the user can check if the node is still into an arbitrary bounding box |
| 32 |
(see shortest_path.c). |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
Clipping demo: |
| 37 |
|
| 38 |
Try to go from node 1 to node 80: |
| 39 |
|
| 40 |
$ ./shortest_path --graph=graph.dgl --from=1 --to=80 |
| 41 |
|
| 42 |
See the result and then try to clip out node 3: |
| 43 |
|
| 44 |
$ ./shortest_path --graph=graph.dgl --from=1 --to=80 --discard=3 |
| 45 |
|
| 46 |
The path will now use intermediate 2 instead of 3, resulting in a |
| 47 |
longer path. |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
The test program cr_large_graph aims at figuring out performances, creating a graph of |
| 55 |
357202/60000 arc/node. |
| 56 |
Given that lot of insertion slowness depends on the node ids sorting, cr_large_graph can |
| 57 |
run in two ways: sorted or interlaced. |
| 58 |
|
| 59 |
These are my time results (700Mhz intel): |
| 60 |
|
| 61 |
time ./cr_large_graph --graph=graphfile |
| 62 |
real 0m42.537s |
| 63 |
user 0m40.250s |
| 64 |
sys 0m1.060s |
| 65 |
|
| 66 |
time ./cr_large_graph --graph=graphfile --interlaced |
| 67 |
real 0m11.012s |
| 68 |
user 0m9.200s |
| 69 |
sys 0m1.020s |
| 70 |
|
| 71 |
|
| 72 |
When compiled with the -DGNGRP_STATS, cr_large_graph prints a line like this at (almost) |
| 73 |
each arc insertion: |
| 74 |
add arc 0238592 - from 0000203 - to 0000103 - cost 0010000 . Clock: tot 000000029 nt 000000015 nh 000000000 o 000000003 |
| 75 |
|
| 76 |
The meaning of clocks are: |
| 77 |
tot = average number of clocks consumed by calls to gnGrpAddLink() |
| 78 |
nt = component of 'tot' spent in the node binary tree |
| 79 |
nh = component of 'tot' spent in the node heap |
| 80 |
o = component of 'tot' spent for all other operations |
| 81 |
|
| 82 |
Warn: the libdgl must also have been compiled with -DGNGRP_STATS. |
| 83 |
|
| 84 |
|
| 85 |
The next is the time spent to load 'graphfile' into memory and performing |
| 86 |
a shortest-path search from the node 0 to 59999 (that is from |
| 87 |
the upper-left to the lower-right of the network): |
| 88 |
|
| 89 |
time ./shortest_path --graph=graphfile --from=0 --to=59999 |
| 90 |
real 0m4.579s |
| 91 |
user 0m3.940s |
| 92 |
sys 0m0.130s |