home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / incl / graph_al.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  5.8 KB  |  191 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  graph_alg.h
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef GRAPHALGH
  16. #define GRAPHALGH
  17.  
  18. #include <LEDA/graph.h>
  19. #include <LEDA/ugraph.h>
  20.  
  21.  
  22. //-----------------------------------------------------------------------------
  23. // Predefined:
  24. //-----------------------------------------------------------------------------
  25.                 
  26. declare(node_array,int)
  27. declare(edge_array,int)
  28. declare(node_array,edge)
  29. declare(edge_array,edge)
  30.  
  31. declare(node_matrix,int)
  32.  
  33. typedef node_array(int)  node_array(bool);
  34. typedef edge_array(int)  edge_array(bool);
  35. typedef node_matrix(int) node_matrix(bool);
  36.  
  37.  
  38.  
  39. //-----------------------------------------------------------------------------
  40. // basic graph algorithms:
  41. //-----------------------------------------------------------------------------
  42.  
  43. bool        compute_correspondence(const graph&, edge_array(edge)&);
  44.  
  45. bool        TOPSORT(const graph& G, node_array(int)& ord);
  46.  
  47. bool        TOPSORT1(graph& G);
  48.  
  49. list(node)  DFS(const graph& G, node s, node_array(bool)& reached) ;
  50.  
  51. list(node)  BFS(const graph& G, node s, node_array(int)& dist);
  52.  
  53. list(edge)  DFS_NUM(const graph& G, node_array(int)& dfsnum, 
  54.                                     node_array(int)& compnum);
  55.  
  56. int         COMPONENTS(const ugraph& G, node_array(int)& compnum);
  57.  
  58. int         COMPONENTS1(const ugraph& G, node_array(int)& compnum);
  59.  
  60. int         STRONG_COMPONENTS(const graph& G, node_array(int)& compnum);
  61.  
  62. int         STRONG_COMPONENTS1(const graph& G, node_array(int)& compnum);
  63.  
  64. int         BICONNECTED_COMPONENTS(const ugraph& G, node_array(int)& compnum);
  65.  
  66. void        acyclic_transitive_closure(graph&);
  67.  
  68. graph       TRANSITIVE_CLOSURE(const graph& G);
  69.  
  70.  
  71.  
  72. //-----------------------------------------------------------------------------
  73. // shortest paths:
  74. //-----------------------------------------------------------------------------
  75.  
  76. void DIJKSTRA(const graph& G, node s, const edge_array(int)& cost, 
  77.                                             node_array(int)& dist, 
  78.                                             node_array(edge)& pred);
  79.  
  80. bool BELLMAN_FORD(const graph& G, node s, const edge_array(int)& cost,
  81.                                                 node_array(int)& dist,
  82.                                                 node_array(edge)& pred);
  83.  
  84. void ALL_PAIRS_SHORTEST_PATHS(graph& G, const edge_array(int)&  cost,
  85.                                               node_matrix(int)& dist);
  86.  
  87.  
  88.  
  89.  
  90. //-----------------------------------------------------------------------------
  91. // maximum flow:
  92. //-----------------------------------------------------------------------------
  93.  
  94.  
  95. int  MAX_FLOW(graph& G, node s, node t, const edge_array(int)& cap,
  96.                                               edge_array(int)& flow);
  97.  
  98.  
  99. //-----------------------------------------------------------------------------
  100. // matchings:
  101. //-----------------------------------------------------------------------------
  102.  
  103. // Edmond's algorithm
  104.  
  105. list(edge) MAX_CARD_MATCHING(graph& G, bool report_blossoms = false);    
  106.  
  107.  
  108. // Hopcroft/Karp
  109.  
  110. list(edge) MAX_CARD_BIPARTITE_MATCHING(graph& G, const list(node)& A, 
  111.                                                  const list(node)& B);
  112.  
  113.  
  114.  
  115. list(edge) MAX_WEIGHT_BIPARTITE_MATCHING(graph& G, const list(node)& A, 
  116.                                                    const list(node)& B,
  117.                                                    const edge_array(int)& weight);
  118.  
  119.  
  120.  
  121.  
  122. //-----------------------------------------------------------------------------
  123. // spanning trees:
  124. //-----------------------------------------------------------------------------
  125.  
  126. list(edge) SPANNING_TREE(const graph& G);
  127.  
  128. list(edge) MIN_SPANNING_TREE(const graph& G, const edge_array(int)& cost);
  129.  
  130.  
  131.  
  132. //-----------------------------------------------------------------------------
  133. // planar graphs
  134. //-----------------------------------------------------------------------------
  135.  
  136. int PLANAR( graph&) ;
  137.  
  138. list(edge) TRIANGULATE_PLANAR_MAP(graph&);
  139.  
  140. int STRAIGHT_LINE_EMBEDDING(graph& G,node_array(int)& xcoord,
  141.                                      node_array(int)& ycoord);
  142.  
  143.  
  144.  
  145. //-----------------------------------------------------------------------------
  146. // "REAL" versions 
  147. //-----------------------------------------------------------------------------
  148.  
  149.  
  150. #ifndef NO_REAL_GRAPH_ALG
  151.  
  152.  
  153. declare(node_array,real)
  154. declare(edge_array,real)
  155. declare(node_matrix,real)
  156.  
  157. void DIJKSTRA(const graph& G, node s, const edge_array(real)& cost, 
  158.                                             node_array(real)& dist, 
  159.                                             node_array(edge)& pred);
  160.  
  161. bool BELLMAN_FORD(const graph& G, node s, const edge_array(real)& cost,
  162.                                                 node_array(real)& dist,
  163.                                                 node_array(edge)& pred);
  164.  
  165.  
  166. void ALL_PAIRS_SHORTEST_PATHS(graph& G, const edge_array(real)&  cost,
  167.                                               node_matrix(real)& dist);
  168.  
  169.  
  170. real MAX_FLOW(graph& G, node s, node t, const edge_array(real)& cap,
  171.                                               edge_array(real)& flow);
  172.  
  173.  
  174. list(edge) MAX_WEIGHT_BIPARTITE_MATCHING(graph& G, const list(node)& A, 
  175.                                                    const list(node)& B,
  176.                                                    const edge_array(real)& weight);
  177.  
  178.  
  179. int STRAIGHT_LINE_EMBEDDING(graph& G,node_array(real)& xcoord,
  180.                                      node_array(real)& ycoord);
  181.  
  182.  
  183. list(edge) MIN_SPANNING_TREE(const graph& G, const edge_array(real)& cost);
  184.  
  185.  
  186. #endif /* ifndef NO_REAL_GRAPH_ALG */
  187.  
  188.  
  189. #endif
  190.