src/work/alpar/smart_graph_demo.cc
author alpar
Wed, 10 Mar 2004 17:47:54 +0000
changeset 164 970b265696b0
parent 157 ee17030e5f47
child 185 259540358bbf
permissions -rw-r--r--
New graph interface
alpar@157
     1
#include<smart_graph.h>
alpar@164
     2
#include<emptygraph.h>
alpar@157
     3
alpar@157
     4
#include <iostream>
alpar@164
     5
#include <vector>
alpar@157
     6
alpar@157
     7
using namespace hugo;
alpar@157
     8
alpar@164
     9
//typedef SmartGraph Graph;
alpar@164
    10
typedef EmptyGraph Graph;
alpar@164
    11
alpar@164
    12
alpar@164
    13
Graph::OutEdgeIt safeFirstOut(const Graph &G, Graph::Node n)
alpar@157
    14
{
alpar@164
    15
  return G.valid(n) ? Graph::OutEdgeIt(G,n):INVALID;
alpar@157
    16
}
alpar@157
    17
alpar@157
    18
int main()
alpar@157
    19
{
alpar@157
    20
alpar@164
    21
  typedef Graph::Edge Edge;
alpar@164
    22
  typedef Graph::InEdgeIt InEdgeIt;
alpar@164
    23
  typedef Graph::OutEdgeIt OutEdgeIt;
alpar@164
    24
  typedef Graph::EdgeIt EdgeIt;
alpar@164
    25
  typedef Graph::Node Node;
alpar@164
    26
  typedef Graph::NodeIt NodeIt;
alpar@157
    27
  
alpar@164
    28
  Graph G;
alpar@164
    29
  NodeIt n;
alpar@157
    30
alpar@157
    31
alpar@157
    32
  for(int i=0;i<10;i++) G.addNode();
alpar@164
    33
  for(G.first(n);G.valid(n);G.next(n)) 
alpar@164
    34
    for(NodeIt m(G);m!=INVALID;G.next(m)) 
alpar@157
    35
      if(n!=m) G.addEdge(n,m);
alpar@157
    36
alpar@157
    37
  OutEdgeIt e = safeFirstOut(G,n);
alpar@164
    38
  OutEdgeIt f = safeFirstOut(G,NodeIt(G));
alpar@164
    39
  
alpar@164
    40
alpar@164
    41
  InEdgeIt i(INVALID), j;
alpar@164
    42
  InEdgeIt ii(i);
alpar@164
    43
  ii=G.first(i,n);
alpar@164
    44
  ii=G.next(i);
alpar@164
    45
  
alpar@164
    46
  OutEdgeIt o(INVALID), oo;
alpar@164
    47
  OutEdgeIt ooo(oo);
alpar@164
    48
  oo=G.first(o,n);
alpar@164
    49
  oo=G.next(o);
alpar@164
    50
  
alpar@164
    51
  EdgeIt ei(INVALID), eie;
alpar@164
    52
  EdgeIt eiee(ei);
alpar@164
    53
  eie=G.first(ei);
alpar@164
    54
  eie=G.next(ei);
alpar@164
    55
alpar@164
    56
  Edge eee(i);
alpar@164
    57
  eee=o;
alpar@164
    58
  eee=eie;
alpar@164
    59
  
alpar@164
    60
  
alpar@164
    61
  bool tm;
alpar@164
    62
  tm = G.valid(n) && G.valid(i) && G.valid(o) && G.valid(ei);
alpar@164
    63
alpar@164
    64
  std::vector<InEdgeIt> v(10);
alpar@164
    65
  std::vector<InEdgeIt> w(10,INVALID);
alpar@157
    66
  
alpar@157
    67
}