COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/peter/hierarchygraph_test.cc @ 1288:6cc7b573b7b5

Last change on this file since 1288:6cc7b573b7b5 was 921:818510fa3d99, checked in by Alpar Juttner, 15 years ago

hugo -> lemon

File size: 2.0 KB
Line 
1#include <string>
2#include <iostream>
3#include <stdio.h>
4
5#include "hierarchygraph.h"
6#include <lemon/list_graph.h>
7#include <lemon/smart_graph.h>
8#include <path.h>
9
10using namespace lemon;
11using namespace std;
12
13bool passed = true;
14
15void check(bool rc) {
16  passed = passed && rc;
17  if(!rc) {
18    cout << "Test failed!" << endl;
19  }
20}
21
22int main()
23{
24  HierarchyGraph<SmartGraph, ListGraph> HGr;
25  ListGraph subnetwork, othernetwork;
26  typedef HierarchyGraph<SmartGraph, ListGraph>::Node Node;
27  typedef HierarchyGraph<SmartGraph, ListGraph>::Edge Edge;
28  typedef HierarchyGraph<SmartGraph, ListGraph>::SubNetwork Sntype;
29
30  Node n0, n1, n2;
31  Edge e0, e1, e2, e3, e4, e5;
32
33  ListGraph::Node sn0, sn1, on0;
34  ListGraph::Edge se0;
35
36  n0=HGr.addNode();
37
38  cout << "Az n0 id-je: " << HGr.actuallayer.id(n0) << endl;
39
40  n1=HGr.addNode();
41  n2=HGr.addNode();
42 
43  e0=HGr.addEdge(n0,n1);
44  e1=HGr.addEdge(n1,n0);
45  e2=HGr.addEdge(n0,n2);
46  e3=HGr.addEdge(n2,n0);
47  e4=HGr.addEdge(n1,n2);
48  e5=HGr.addEdge(n2,n1);
49
50  sn0=subnetwork.addNode();
51  sn1=subnetwork.addNode();
52  se0=subnetwork.addEdge(sn0,sn1);
53
54  Sntype sn;
55  sn.setActualLayer(&(HGr.actuallayer));
56  sn.setActualLayerNode(&(n0));
57  sn.addAssignment(e0, sn0);
58  sn.addAssignment(e1, sn1);
59  sn.addAssignment(e2, sn1);
60  sn.addAssignment(e3, sn0);
61  sn.addAssignment(e1, sn0);
62  sn.addAssignment(e5, sn0);
63 
64
65
66  on0=othernetwork.addNode();
67
68  cout << "ID of a node from a different graph: " << subnetwork.id(on0) << endl;
69  cout << "ID of a node in its graph: " << othernetwork.id(on0) << endl;
70  cout << "ID of a node from a  graph: " << subnetwork.id(sn0) << endl;
71
72  ListGraph::NodeIt snni;
73  //ListGraph::Node snn;
74
75  for(subnetwork.first(snni);subnetwork.valid(snni);subnetwork.next(snni))
76  {
77    if(snni==on0)
78    {
79      cout << "Nem jo, megtalalta az idegen node-ot sajat haloban, pedig azt nem szabad!!!"
80           << subnetwork.id(snni) << subnetwork.id(on0) << othernetwork.id(snni) << othernetwork.id(on0) << endl;
81    }
82    else cout << "ID:" << subnetwork.id(snni) << endl;
83     
84  }
85 
86
87  HGr.subnetworks[n0]=sn;
88 
89}
Note: See TracBrowser for help on using the repository browser.