src/work/klao/minlengthpaths.cc
author marci
Fri, 16 Apr 2004 08:26:00 +0000
changeset 335 999eb3cd7b49
parent 308 379e1d50089d
permissions -rw-r--r--
jflsjfljskf
klao@308
     1
// -*- c++ -*-
klao@308
     2
//#include <iostream>
klao@308
     3
//#include <vector>
klao@308
     4
//#include <string>
klao@308
     5
klao@308
     6
#include <list_graph.h>
klao@308
     7
#include <minlengthpaths.h>
klao@308
     8
klao@308
     9
using namespace hugo;
klao@308
    10
klao@308
    11
klao@308
    12
int main()
klao@308
    13
{
klao@308
    14
klao@308
    15
  
klao@308
    16
  typedef ListGraph::Node Node;
klao@308
    17
  typedef ListGraph::Edge Edge;
klao@308
    18
klao@308
    19
  ListGraph graph;
klao@308
    20
klao@308
    21
  /*
klao@308
    22
  //Marci példája
klao@308
    23
klao@308
    24
klao@308
    25
  NodeIt s=graph.addNode();
klao@308
    26
  NodeIt v1=graph.addNode();
klao@308
    27
  NodeIt v2=graph.addNode();
klao@308
    28
  NodeIt v3=graph.addNode();
klao@308
    29
  NodeIt v4=graph.addNode();
klao@308
    30
  NodeIt t=graph.addNode();
klao@308
    31
  
klao@308
    32
klao@308
    33
  EdgeIt s_v1=graph.addEdge(s, v1);
klao@308
    34
  EdgeIt s_v2=graph.addEdge(s, v2);
klao@308
    35
  EdgeIt v1_v2=graph.addEdge(v1, v2);
klao@308
    36
  EdgeIt v2_v1=graph.addEdge(v2, v1);
klao@308
    37
  EdgeIt v1_v3=graph.addEdge(v1, v3);
klao@308
    38
  EdgeIt v3_v2=graph.addEdge(v3, v2);
klao@308
    39
  EdgeIt v2_v4=graph.addEdge(v2, v4);
klao@308
    40
  EdgeIt v4_v3=graph.addEdge(v4, v3);
klao@308
    41
  EdgeIt v3_t=graph.addEdge(v3, t);
klao@308
    42
  EdgeIt v4_t=graph.addEdge(v4, t);
klao@308
    43
klao@308
    44
  ListGraph::EdgeMap<int> length(graph);
klao@308
    45
klao@308
    46
  length.set(s_v1, 16);
klao@308
    47
  length.set(s_v2, 13);
klao@308
    48
  length.set(v1_v2, 10);
klao@308
    49
  length.set(v2_v1, 4);
klao@308
    50
  length.set(v1_v3, 12);
klao@308
    51
  length.set(v3_v2, 9);
klao@308
    52
  length.set(v2_v4, 14);
klao@308
    53
  length.set(v4_v3, 7);
klao@308
    54
  length.set(v3_t, 20);
klao@308
    55
  length.set(v4_t, 4);
klao@308
    56
  */
klao@308
    57
klao@308
    58
klao@308
    59
  //Ahuja könyv példája
klao@308
    60
klao@308
    61
  Node s=graph.addNode();
klao@308
    62
  Node v2=graph.addNode();
klao@308
    63
  Node v3=graph.addNode();
klao@308
    64
  Node v4=graph.addNode();
klao@308
    65
  Node v5=graph.addNode();
klao@308
    66
  Node t=graph.addNode();
klao@308
    67
klao@308
    68
  Edge s_v2=graph.addEdge(s, v2);
klao@308
    69
  Edge s_v3=graph.addEdge(s, v3);
klao@308
    70
  Edge v2_v4=graph.addEdge(v2, v4);
klao@308
    71
  Edge v2_v5=graph.addEdge(v2, v5);
klao@308
    72
  Edge v3_v5=graph.addEdge(v3, v5);
klao@308
    73
  Edge v4_t=graph.addEdge(v4, t);
klao@308
    74
  Edge v5_t=graph.addEdge(v5, t);
klao@308
    75
  
klao@308
    76
  //Kis modositas
klao@308
    77
  //edge_iterator v2_s=graph.add_edge(v2, s);
klao@308
    78
klao@308
    79
  ListGraph::EdgeMap<int> length(graph);
klao@308
    80
klao@308
    81
  length.set(s_v2, 10);
klao@308
    82
  length.set(s_v3, 10);
klao@308
    83
  length.set(v2_v4, 5);
klao@308
    84
  length.set(v2_v5, 8);
klao@308
    85
  length.set(v3_v5, 5);
klao@308
    86
  length.set(v4_t, 8);
klao@308
    87
  length.set(v5_t, 8);
klao@308
    88
klao@308
    89
  //Kis modositas
klao@308
    90
  //length.put(v2_s, 100);
klao@308
    91
 
klao@308
    92
klao@308
    93
klao@308
    94
klao@308
    95
  /*Egyszerű példa
klao@308
    96
  NodeIt s=flow_test.add_node();
klao@308
    97
  NodeIt v1=flow_test.add_node();
klao@308
    98
  NodeIt v2=flow_test.add_node();
klao@308
    99
  NodeIt t=flow_test.add_node();
klao@308
   100
  
klao@308
   101
  node_property_vector<list_graph, std::string> node_name(flow_test);
klao@308
   102
  node_name.put(s, "s");
klao@308
   103
  node_name.put(v1, "v1");
klao@308
   104
  node_name.put(v2, "v2");
klao@308
   105
  node_name.put(t, "t");
klao@308
   106
klao@308
   107
  edge_iterator s_v1=flow_test.add_edge(s, v1);
klao@308
   108
  edge_iterator v1_v2=flow_test.add_edge(v1, v2);
klao@308
   109
  edge_iterator v2_t=flow_test.add_edge(v2, t);
klao@308
   110
klao@308
   111
  edge_property_vector<list_graph, int> length(flow_test); 
klao@308
   112
    
klao@308
   113
  length.put(s_v1, 16);
klao@308
   114
  length.put(v1_v2, 10);
klao@308
   115
  length.put(v2_t, 4);
klao@308
   116
  */
klao@308
   117
klao@308
   118
  std::cout << "Suurballe algorithm test..." << std::endl;
klao@308
   119
klao@308
   120
  
klao@308
   121
  int k=3;
klao@310
   122
  MinLengthPaths<ListGraph, ListGraph::EdgeMap<int> >
klao@310
   123
    surb_test(graph, length);
klao@310
   124
  std::cout << surb_test.run(s,t,k) << std::endl;
klao@308
   125
klao@308
   126
  return 0;
klao@308
   127
}