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