src/work/peter/hierarchygraph.h
changeset 986 e997802b855c
parent 921 818510fa3d99
child 987 87f7c54892df
equal deleted inserted replaced
5:61243dfa3ba5 6:54bb0e1ba0b9
    58 	if (!(actuallayer->valid (actedge)))
    58 	if (!(actuallayer->valid (actedge)))
    59 	  {
    59 	  {
    60 	    cerr << "The given edge is not in the given network!" << endl;
    60 	    cerr << "The given edge is not in the given network!" << endl;
    61 	    return -1;
    61 	    return -1;
    62 	  }
    62 	  }
    63 	else if ((actuallayer->id (actuallayer->tail (actedge)) !=
    63 	else if ((actuallayer->id (actuallayer->source (actedge)) !=
    64 		  actuallayer->id (*actuallayernode))
    64 		  actuallayer->id (*actuallayernode))
    65 		 && (actuallayer->id (actuallayer->head (actedge)) !=
    65 		 && (actuallayer->id (actuallayer->target (actedge)) !=
    66 		     actuallayer->id (*actuallayernode)))
    66 		     actuallayer->id (*actuallayernode)))
    67 	  {
    67 	  {
    68 	    cerr << "The given edge does not connect to the given node!" <<
    68 	    cerr << "The given edge does not connect to the given node!" <<
    69 	      endl;
    69 	      endl;
    70 	    return -1;
    70 	    return -1;
   130 
   130 
   131 	if (actuallayer)
   131 	if (actuallayer)
   132 	  {
   132 	  {
   133 	    for (iei = actuallayer->first (iei, (*actuallayernode));
   133 	    for (iei = actuallayer->first (iei, (*actuallayernode));
   134 		 ((actuallayer->valid (iei))
   134 		 ((actuallayer->valid (iei))
   135 		  && (actuallayer->head (iei) == (*actuallayernode)));
   135 		  && (actuallayer->target (iei) == (*actuallayernode)));
   136 		 actuallayer->next (iei))
   136 		 actuallayer->next (iei))
   137 	      {
   137 	      {
   138 		cout << actuallayer->id (actuallayer->
   138 		cout << actuallayer->id (actuallayer->
   139 					 tail (iei)) << " " << actuallayer->
   139 					 source (iei)) << " " << actuallayer->
   140 		  id (actuallayer->head (iei)) << endl;
   140 		  id (actuallayer->target (iei)) << endl;
   141 		edgenumber++;
   141 		edgenumber++;
   142 	      }
   142 	      }
   143 	    //cout << "Number of in-edges: " << edgenumber << endl;
   143 	    //cout << "Number of in-edges: " << edgenumber << endl;
   144 	    for (oei = actuallayer->first (oei, (*actuallayernode));
   144 	    for (oei = actuallayer->first (oei, (*actuallayernode));
   145 		 ((actuallayer->valid (oei))
   145 		 ((actuallayer->valid (oei))
   146 		  && (actuallayer->tail (oei) == (*actuallayernode)));
   146 		  && (actuallayer->source (oei) == (*actuallayernode)));
   147 		 actuallayer->next (oei))
   147 		 actuallayer->next (oei))
   148 	      {
   148 	      {
   149 		cout << actuallayer->id (actuallayer->
   149 		cout << actuallayer->id (actuallayer->
   150 					 tail (oei)) << " " << actuallayer->
   150 					 source (oei)) << " " << actuallayer->
   151 		  id (actuallayer->head (oei)) << endl;
   151 		  id (actuallayer->target (oei)) << endl;
   152 		edgenumber++;
   152 		edgenumber++;
   153 	      }
   153 	      }
   154 	    //cout << "Number of in+out-edges: " << edgenumber << endl;
   154 	    //cout << "Number of in+out-edges: " << edgenumber << endl;
   155 	    assignments = new actedgesubnodestruct[edgenumber];
   155 	    assignments = new actedgesubnodestruct[edgenumber];
   156 	    for (int i = 0; i < edgenumber; i++)
   156 	    for (int i = 0; i < edgenumber; i++)
   325     typename Gact::EdgeIt & next (typename Gact::EdgeIt & i) const
   325     typename Gact::EdgeIt & next (typename Gact::EdgeIt & i) const
   326     {
   326     {
   327       return actuallayer.next (i);
   327       return actuallayer.next (i);
   328     }
   328     }
   329 
   329 
   330     ///Gives back the head node of an edge.
   330     ///Gives back the target node of an edge.
   331     typename Gact::Node head (typename Gact::Edge edge) const
   331     typename Gact::Node target (typename Gact::Edge edge) const
   332     {
   332     {
   333       return actuallayer.head (edge);
   333       return actuallayer.target (edge);
   334     }
   334     }
   335     ///Gives back the tail node of an edge.
   335     ///Gives back the source node of an edge.
   336     typename Gact::Node tail (typename Gact::Edge edge) const
   336     typename Gact::Node source (typename Gact::Edge edge) const
   337     {
   337     {
   338       return actuallayer.tail (edge);
   338       return actuallayer.source (edge);
   339     }
   339     }
   340 
   340 
   341     //   Node aNode(InEdgeIt) const {}
   341     //   Node aNode(InEdgeIt) const {}
   342     //   Node aNode(OutEdgeIt) const {}
   342     //   Node aNode(OutEdgeIt) const {}
   343     //   Node aNode(SymEdgeIt) const {}
   343     //   Node aNode(SymEdgeIt) const {}
   391     {
   391     {
   392       return actuallayer.addNode ();
   392       return actuallayer.addNode ();
   393     }
   393     }
   394     ///Add a new edge to the graph.
   394     ///Add a new edge to the graph.
   395 
   395 
   396     ///Add a new edge to the graph with tail node \c tail
   396     ///Add a new edge to the graph with source node \c source
   397     ///and head node \c head.
   397     ///and target node \c target.
   398     ///\return the new edge.
   398     ///\return the new edge.
   399     typename Gact::Edge addEdge (typename Gact::Node node1,
   399     typename Gact::Edge addEdge (typename Gact::Node node1,
   400 				 typename Gact::Node node2)
   400 				 typename Gact::Node node2)
   401     {
   401     {
   402       return actuallayer.addEdge (node1, node2);
   402       return actuallayer.addEdge (node1, node2);