README 5.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * FLAT DIRECTED GRAPH (FDG) MEMORY REPRESENTATION * VERSION 1: (obsolete)
  3. *
  4. * FDG is represented by two arrays of 32bit words: the node-buffer and the link-buffer
  5. *
  6. * Each node has a entry in the node-buffer.
  7. * Links (arcs connecting couples of nodes) are grouped in the link-buffer into link-areas, that is: all
  8. * links departing from a given node are kept continuos in a link-area.
  9. *
  10. * A node-entry has the fields:
  11. * nodeid: a unique id for the node in the graph
  12. * status: flags indicating the role of the node (from/to/both)
  13. * offset: the byte offset to the link-area in the link-buffer
  14. * [attr]: optionally an arbitrary length area for user supplied node attributes.
  15. *
  16. * A link-area has the fields:
  17. * tocnt : the number of departing links
  18. * toarr : the array of departing links
  19. *
  20. * Each link in the link-area array has the fields:
  21. * offset: the byte offset in the node buffer of the destination node for this link
  22. * cost : the effort needed to 'travel' from origin node *to* the destination node (not bidirectional)
  23. * user : a value passed by the user for this link - it's usually a unique user supplied link-id.
  24. * [attr]: optionally an arbitrary length area for user supplied link attributes.
  25. *
  26. * Nodes in the node buffer are kept sorted by ascending nodeid. Thus, given that a node entry has fixed size,
  27. * a node can be found using a binary search in the node buffer.
  28. *
  29. * Node attributes are optionally stored by enlarging the node entry by a fixed amount of bytes (attr), as well as link
  30. * attributes, which are stored in the respective link entry extension (attr).
  31. * Sizes for node and link attributes are given at graph creation time and cannot be modified later on.
  32. *
  33. * +-------------------------------------------------------------------------------------------------------> ...
  34. * | +---------------------------------------------------------------------+
  35. * | | +-----------------------------------+ |
  36. * | | | V V
  37. * Node Buffer (nodeid|status|offset|attr)... (nodeid|status|offset|attr)... (nodeid|status|offset|attr)...
  38. * | | | | |
  39. * | | | +---------------+ +------------------------+
  40. * | | | V V
  41. * Link Buffer (tocnt|toarr) ... (tocnt|toarr)
  42. * | | | (offset|cost|user|attr)[0]... ()[tocnt-1]... (offset|cost|user|attr)[0]... ()[tocnt-1]...
  43. * | | | | | | ...
  44. * | | +-----------+ | |
  45. * | +-----------------------------------------+ |
  46. * +---------------------------------------------------------------------+
  47. *
  48. */
  49. /* FLAT DIRECTED GRAPH (FDG) FILE REPRESENTATION * VERSION 1 (obsolete)
  50. *
  51. * FDGs can be stored into files as they are, or in other words, they are serializable.
  52. * Graphs are versioned: a pool exists of pointers to methods which implement a given graph version, for each graph version.
  53. * Actually only version 1 has been defined.
  54. * The version number is stored as the first byte of the graph file and must be supplied as an argument when we want to
  55. * initialize a new graph. When reading a graph from a stream, the library understands by the first byte what version
  56. * is it, and initializes it appropriately.
  57. *
  58. * Version 1 graph file format:
  59. *
  60. * Field Size/Type Value range Description
  61. * [VERSION...................] 1 byte 1 Version 1 graphs always keep value 1
  62. * [ENDIANESS.................] 1 byte 1 | 2 Integer words byte order 1=big 2=little
  63. * [NODE ATTRIBUTES BYTE SIZE.] 4 bytes integer >= 0 Byte size of attributes area for each node
  64. * [LINK ATTRIBUTES BYTE SIZE.] 4 bytes integer >= 0 Byte size of attributes area for each link
  65. * [OPAQUE SET................] 16 words of 4 bytes - Free user's storage
  66. * [NODE COUNT................] 4 bytes integer > 0 How many nodes in graph
  67. * [FROM NODE COUNT...........] 4 bytes integer > 0 How many nodes with from role
  68. * [TO NODE COUNT.............] 4 bytes integer > 0 How many nodes with to role
  69. * [ALONE NODE COUNT..........] 4 bytes integer > 0 How many nodes with alone role
  70. * [ARC (LINK) COUNT..........] 4 bytes integer > 0 Home many links in graph
  71. * [NODE BUFFER BYTE SIZE.....] 4 bytes integer >= 0 Byte size of the node buffer
  72. * [LINK BUFFER BYTE SIZE.....] 4 bytes integer >= 0 Byte size of the link buffer
  73. * [NODE BUFFER...............] variable len array of bytes V1 FDG NODE BUFFER Node buffer
  74. * [LINK BUFFER...............] variable len array of bytes V1 FDG LINK BUFFER Link buffer
  75. *
  76. */