src/work/peter/hierarchygraph_test.cc
author alpar
Thu, 09 Sep 2004 07:09:11 +0000
changeset 824 157115b5814a
parent 677 af3b5c85a227
child 921 818510fa3d99
permissions -rw-r--r--
Shorter template parameter names to be more readable in Doxygen.
hegyi@677
     1
#include <string>
hegyi@677
     2
#include <iostream>
hegyi@677
     3
#include <stdio.h>
hegyi@677
     4
hegyi@677
     5
#include "hierarchygraph.h"
hegyi@677
     6
#include <hugo/list_graph.h>
hegyi@677
     7
#include <hugo/smart_graph.h>
hegyi@677
     8
#include <path.h>
hegyi@677
     9
hegyi@677
    10
using namespace hugo;
hegyi@677
    11
using namespace std;
hegyi@677
    12
hegyi@677
    13
bool passed = true;
hegyi@677
    14
hegyi@677
    15
void check(bool rc) {
hegyi@677
    16
  passed = passed && rc;
hegyi@677
    17
  if(!rc) {
hegyi@677
    18
    cout << "Test failed!" << endl;
hegyi@677
    19
  }
hegyi@677
    20
}
hegyi@677
    21
hegyi@677
    22
int main()
hegyi@677
    23
{
hegyi@677
    24
  HierarchyGraph<SmartGraph, ListGraph> HGr;
hegyi@690
    25
  ListGraph subnetwork, othernetwork;
hegyi@690
    26
  typedef HierarchyGraph<SmartGraph, ListGraph>::Node Node;
hegyi@690
    27
  typedef HierarchyGraph<SmartGraph, ListGraph>::Edge Edge;
hegyi@690
    28
  typedef HierarchyGraph<SmartGraph, ListGraph>::SubNetwork Sntype;
hegyi@690
    29
hegyi@690
    30
  Node n0, n1, n2;
hegyi@690
    31
  Edge e0, e1, e2, e3, e4, e5;
hegyi@690
    32
hegyi@690
    33
  ListGraph::Node sn0, sn1, on0;
hegyi@690
    34
  ListGraph::Edge se0;
hegyi@690
    35
hegyi@690
    36
  n0=HGr.addNode();
hegyi@690
    37
hegyi@690
    38
  cout << "Az n0 id-je: " << HGr.actuallayer.id(n0) << endl;
hegyi@690
    39
hegyi@690
    40
  n1=HGr.addNode();
hegyi@690
    41
  n2=HGr.addNode();
hegyi@690
    42
  
hegyi@690
    43
  e0=HGr.addEdge(n0,n1);
hegyi@690
    44
  e1=HGr.addEdge(n1,n0);
hegyi@690
    45
  e2=HGr.addEdge(n0,n2);
hegyi@690
    46
  e3=HGr.addEdge(n2,n0);
hegyi@690
    47
  e4=HGr.addEdge(n1,n2);
hegyi@690
    48
  e5=HGr.addEdge(n2,n1);
hegyi@690
    49
hegyi@690
    50
  sn0=subnetwork.addNode();
hegyi@690
    51
  sn1=subnetwork.addNode();
hegyi@690
    52
  se0=subnetwork.addEdge(sn0,sn1);
hegyi@690
    53
hegyi@690
    54
  Sntype sn;
hegyi@690
    55
  sn.setActualLayer(&(HGr.actuallayer));
hegyi@690
    56
  sn.setActualLayerNode(&(n0));
hegyi@690
    57
  sn.addAssignment(e0, sn0);
hegyi@690
    58
  sn.addAssignment(e1, sn1);
hegyi@690
    59
  sn.addAssignment(e2, sn1);
hegyi@690
    60
  sn.addAssignment(e3, sn0);
hegyi@690
    61
  sn.addAssignment(e1, sn0);
hegyi@690
    62
  sn.addAssignment(e5, sn0);
hegyi@690
    63
  
hegyi@690
    64
hegyi@690
    65
hegyi@690
    66
  on0=othernetwork.addNode();
hegyi@690
    67
hegyi@690
    68
  cout << "ID of a node from a different graph: " << subnetwork.id(on0) << endl;
hegyi@690
    69
  cout << "ID of a node in its graph: " << othernetwork.id(on0) << endl;
hegyi@690
    70
  cout << "ID of a node from a  graph: " << subnetwork.id(sn0) << endl;
hegyi@690
    71
hegyi@690
    72
  ListGraph::NodeIt snni;
hegyi@690
    73
  //ListGraph::Node snn;
hegyi@690
    74
hegyi@690
    75
  for(subnetwork.first(snni);subnetwork.valid(snni);subnetwork.next(snni))
hegyi@690
    76
  {
hegyi@690
    77
    if(snni==on0)
hegyi@690
    78
    {
hegyi@690
    79
      cout << "Nem jo, megtalalta az idegen node-ot sajat haloban, pedig azt nem szabad!!!" 
hegyi@690
    80
	   << subnetwork.id(snni) << subnetwork.id(on0) << othernetwork.id(snni) << othernetwork.id(on0) << endl;
hegyi@690
    81
    }
hegyi@690
    82
    else cout << "ID:" << subnetwork.id(snni) << endl;
hegyi@690
    83
      
hegyi@690
    84
  }
hegyi@690
    85
  
hegyi@690
    86
hegyi@690
    87
  HGr.subnetworks[n0]=sn;
hegyi@690
    88
  
hegyi@677
    89
}