neta.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /****************************************************************
  2. *
  3. * MODULE: netalib
  4. *
  5. * AUTHOR(S): Daniel Bundala (Google Summer of Code 2009)
  6. *
  7. * PURPOSE: NETwork Analysis Library
  8. *
  9. * COPYRIGHT: (C) 2009-2010 by Daniel Bundala, and the GRASS Development Team
  10. *
  11. * This program is free software under the GNU General
  12. * Public License (>=v2). Read the file COPYING that
  13. * comes with GRASS for details.
  14. *
  15. ****************************************************************/
  16. #ifndef _NETA_H_
  17. #define _NETA_H_
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <grass/gis.h>
  21. #include <grass/vector.h>
  22. #include <grass/dbmi.h>
  23. #include <grass/glocale.h>
  24. #include <grass/dgl/graph.h>
  25. /*bridge.c */
  26. int NetA_compute_bridges(dglGraph_s * graph, struct ilist *bridge_list);
  27. int NetA_articulation_points(dglGraph_s * graph,
  28. struct ilist *articulation_list);
  29. /*components.c */
  30. int NetA_weakly_connected_components(dglGraph_s * graph, int *component);
  31. int NetA_strongly_connected_components(dglGraph_s * graph, int *component);
  32. /*spanningtree.c */
  33. int NetA_spanning_tree(dglGraph_s * graph, struct ilist *tree_list);
  34. /*allpairs.c */
  35. int NetA_allpairs(dglGraph_s * graph, dglInt32_t ** dist);
  36. /*neta_flow.c */
  37. int NetA_flow(dglGraph_s * graph, struct ilist *source_list,
  38. struct ilist *sink_list, int *flow);
  39. int NetA_min_cut(dglGraph_s * graph, struct ilist *source_list,
  40. struct ilist *sink_list, int *flow, struct ilist *cut);
  41. int NetA_split_vertices(dglGraph_s * in, dglGraph_s * out, int *node_costs);
  42. /*utils.c */
  43. void NetA_add_point_on_node(struct Map_info *In, struct Map_info *Out, int node,
  44. struct line_cats *Cats);
  45. void NetA_points_to_nodes(struct Map_info *In, struct ilist *point_list);
  46. int NetA_get_node_costs(struct Map_info *In, int layer, char *column,
  47. int *node_costs);
  48. void NetA_varray_to_nodes(struct Map_info *map, struct varray * varray,
  49. struct ilist *nodes, int *nodes_to_features);
  50. int NetA_initialise_varray(struct Map_info *In, int layer, int mask_type,
  51. char *where, char *cat, struct varray ** varray);
  52. /*centrality.c */
  53. void NetA_degree_centrality(dglGraph_s * graph, double *degree);
  54. int NetA_eigenvector_centrality(dglGraph_s * graph, int iterations,
  55. double error, double *eigenvector);
  56. int NetA_betweenness_closeness(dglGraph_s * graph, double *betweenness,
  57. double *closeness);
  58. /*path.c */
  59. int NetA_distance_from_points(dglGraph_s * graph, struct ilist *from, int *dst,
  60. dglInt32_t ** prev);
  61. int NetA_find_path(dglGraph_s * graph, int from, int to, int *edges,
  62. struct ilist *list);
  63. /*timetables.c */
  64. /*Structure containing all information about a timetable.
  65. * Everything in indexed from 0.
  66. */
  67. typedef struct
  68. {
  69. int routes; /*Number of different routes. Two routes are different even if they differ only in time. */
  70. int *route_length; /*Length of each route, i.e., number of stops */
  71. int **route_stops; /*list of stops on each route in order (time increases) */
  72. int **route_times; /*stop arrival times on overy route. Stops are given in the same order as above */
  73. int stops; /*number of stops */
  74. int *stop_length; /*Number of routes stopping at each stop */
  75. int **stop_routes; /*List of routes for each stop. Routes are in increasing order */
  76. int **stop_times; /*arrival times of routes for each stop. Routes are given in the same order as above */
  77. int *walk_length; /*number of stops with "walking connection" for each stop */
  78. int **walk_stops; /*list of stops within walking distance for each stop */
  79. int **walk_times; /*walking times between stops as given above */
  80. } neta_timetable;
  81. typedef struct
  82. {
  83. int **dst;
  84. int **prev_stop;
  85. int **prev_route;
  86. int **prev_conn;
  87. int rows, routes;
  88. } neta_timetable_result;
  89. int NetA_init_timetable_from_db(struct Map_info *In, int route_layer,
  90. int walk_layer, char *route_id, char *times,
  91. char *to_stop, char *walk_length,
  92. neta_timetable * timetable, int **route_ids,
  93. int **stop_ids);
  94. int NetA_timetable_shortest_path(neta_timetable * timetable, int from_stop,
  95. int to_stop, int start_time, int min_change,
  96. int max_changes, int walking_change,
  97. neta_timetable_result * result);
  98. int NetA_timetable_get_route_time(neta_timetable * timetable, int stop,
  99. int route);
  100. void NetA_timetable_result_release(neta_timetable_result * result);
  101. #endif