src/work/peter/hierarchygraph_test.cc
changeset 743 efab34f23b30
parent 677 af3b5c85a227
child 921 818510fa3d99
equal deleted inserted replaced
0:6af1157d8fcb 1:e8a42d3bcc1a
    20 }
    20 }
    21 
    21 
    22 int main()
    22 int main()
    23 {
    23 {
    24   HierarchyGraph<SmartGraph, ListGraph> HGr;
    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   
    25 }
    89 }