[Lemon-commits] [lemon_svn] hegyi: r941 - hugo/trunk/src/work/peter

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:42:20 CET 2006


Author: hegyi
Date: Mon Jul  5 18:44:18 2004
New Revision: 941

Modified:
   hugo/trunk/src/work/peter/hierarchygraph.h

Log:
t/bin/bash: line 1: q: command not found
-j-This line, and those below, will be ignored--

M    peter/hierarchygraph.h


Modified: hugo/trunk/src/work/peter/hierarchygraph.h
==============================================================================
--- hugo/trunk/src/work/peter/hierarchygraph.h	(original)
+++ hugo/trunk/src/work/peter/hierarchygraph.h	Mon Jul  5 18:44:18 2004
@@ -9,7 +9,8 @@
 #include <hugo/maps.h>
 
 /// The namespace of HugoLib
-namespace hugo {
+namespace hugo
+{
 
   // @defgroup empty_graph The HierarchyGraph class
   // @{
@@ -21,8 +22,7 @@
   /// means that a node in one layer can be a complete network in a nother
   /// layer.
 
-  template <class Gact, class Gsub>
-  class HierarchyGraph
+  template < class Gact, class Gsub > class HierarchyGraph
   {
 
   public:
@@ -39,138 +39,159 @@
 
       struct actedgesubnodestruct
       {
-        typename Gact::Edge actedge;
-        typename Gsub::Node subnode;
+	typename Gact::Edge actedge;
+	typename Gsub::Node subnode;
       };
 
       int edgenumber;
       bool connectable;
-      Gact * actuallayer;
+      Gact *actuallayer;
       typename Gact::Node * actuallayernode;
-      Gsub * subnetwork;
-      actedgesubnodestruct * assignments;
+      Gsub *subnetwork;
+      actedgesubnodestruct *assignments;
 
     public:
 
-      int addAssignment(typename Gact::Edge actedge, typename Gsub::Node subnode)
+      int addAssignment (typename Gact::Edge actedge,
+			 typename Gsub::Node subnode)
       {
-	if(!(actuallayer->valid(actedge)))
-	{
-	  cerr << "The given edge is not in the given network!" << endl;
-	  return -1;
-	}
-	else if(
-	   (actuallayer->id(actuallayer->tail(actedge))!=actuallayer->id(*actuallayernode))
-	   &&
-	   (actuallayer->id(actuallayer->head(actedge))!=actuallayer->id(*actuallayernode))
-	  )
-	{
-	  cerr << "The given edge does not connect to the given node!" << endl;
-	  return -1;
-	}
+	if (!(actuallayer->valid (actedge)))
+	  {
+	    cerr << "The given edge is not in the given network!" << endl;
+	    return -1;
+	  }
+	else if ((actuallayer->id (actuallayer->tail (actedge)) !=
+		  actuallayer->id (*actuallayernode))
+		 && (actuallayer->id (actuallayer->head (actedge)) !=
+		     actuallayer->id (*actuallayernode)))
+	  {
+	    cerr << "The given edge does not connect to the given node!" <<
+	      endl;
+	    return -1;
+	  }
 
-	if(!(subnetwork->valid(subnode)))
-	{
-	  cerr << "The given node is not in the given network!" << endl;
-	  return -1;
-	}
+	if (!(subnetwork->valid (subnode)))
+	  {
+	    cerr << "The given node is not in the given network!" << endl;
+	    return -1;
+	  }
 
-	int i=0;
+	int i = 0;
 	//while in the array there is valid note that is not equvivalent with the one that would be noted increase i
-	while( (i<edgenumber) && (actuallayer->valid(assignments[i].actedge) ) && (assignments[i].actedge!=actedge) ) i++;
-	if(assignments[i].actedge==actedge)
-	{
-	  cout << "Warning: Redefinement of assigment!!!" << endl;
-	}
-	if(i==edgenumber)
-	{
-	  cout << "This case can't be!!! (because there should be the guven edge in the array already and the cycle had to stop)" << endl;
-	}
+	while ((i < edgenumber)
+	       && (actuallayer->valid (assignments[i].actedge))
+	       && (assignments[i].actedge != actedge))
+	  i++;
+	if (assignments[i].actedge == actedge)
+	  {
+	    cout << "Warning: Redefinement of assigment!!!" << endl;
+	  }
+	if (i == edgenumber)
+	  {
+	    cout <<
+	      "This case can't be!!! (because there should be the guven edge in the array already and the cycle had to stop)"
+	      << endl;
+	  }
 	//if(!(actuallayer->valid(assignments[i].actedge)))   //this condition is necessary if we do not obey redefinition
 	{
-	  assignments[i].actedge=actedge;
-	  assignments[i].subnode=subnode;
+	  assignments[i].actedge = actedge;
+	  assignments[i].subnode = subnode;
 	}
 
 	/// If to all of the edges a subnode is assigned then the subnetwork is connectable (attachable?)
 	/// We do not need to check for further attributes, because to notice an assignment we need
 	/// all of them to be correctly initialised before.
-	if(i==edgenumber-1)connectable=1;
+	if (i == edgenumber - 1)
+	  connectable = 1;
 
 	return 0;
       }
 
-      int setSubNetwork(Gsub * sn)
+      int setSubNetwork (Gsub * sn)
       {
-	subnetwork=sn;
+	subnetwork = sn;
 	return 0;
       }
 
-      int setActualLayer(Gact * al)
+      int setActualLayer (Gact * al)
       {
-	actuallayer=al;
+	actuallayer = al;
 	return 0;
       }
 
-      int setActualLayerNode(typename Gact::Node * aln)
+      int setActualLayerNode (typename Gact::Node * aln)
       {
 	typename Gact::InEdgeIt iei;
 	typename Gact::OutEdgeIt oei;
 
-	actuallayernode=aln;
+	actuallayernode = aln;
 
-	edgenumber=0;
+	edgenumber = 0;
 
-	if(actuallayer)
-	{
-	  for(iei=actuallayer->first(iei,(*actuallayernode));((actuallayer->valid(iei))&&(actuallayer->head(iei)==(*actuallayernode)));actuallayer->next(iei))
-	  {
-	    cout << actuallayer->id(actuallayer->tail(iei)) << " " << actuallayer->id(actuallayer->head(iei)) << endl;
-	    edgenumber++;
-	  }
-	  //cout << "Number of in-edges: " << edgenumber << endl;
-	  for(oei=actuallayer->first(oei,(*actuallayernode));((actuallayer->valid(oei))&&(actuallayer->tail(oei)==(*actuallayernode)));actuallayer->next(oei))
+	if (actuallayer)
 	  {
-	    cout << actuallayer->id(actuallayer->tail(oei)) << " " << actuallayer->id(actuallayer->head(oei)) << endl;
-	    edgenumber++;
+	    for (iei = actuallayer->first (iei, (*actuallayernode));
+		 ((actuallayer->valid (iei))
+		  && (actuallayer->head (iei) == (*actuallayernode)));
+		 actuallayer->next (iei))
+	      {
+		cout << actuallayer->id (actuallayer->
+					 tail (iei)) << " " << actuallayer->
+		  id (actuallayer->head (iei)) << endl;
+		edgenumber++;
+	      }
+	    //cout << "Number of in-edges: " << edgenumber << endl;
+	    for (oei = actuallayer->first (oei, (*actuallayernode));
+		 ((actuallayer->valid (oei))
+		  && (actuallayer->tail (oei) == (*actuallayernode)));
+		 actuallayer->next (oei))
+	      {
+		cout << actuallayer->id (actuallayer->
+					 tail (oei)) << " " << actuallayer->
+		  id (actuallayer->head (oei)) << endl;
+		edgenumber++;
+	      }
+	    //cout << "Number of in+out-edges: " << edgenumber << endl;
+	    assignments = new actedgesubnodestruct[edgenumber];
+	    for (int i = 0; i < edgenumber; i++)
+	      {
+		assignments[i].actedge = INVALID;
+		assignments[i].subnode = INVALID;
+	      }
 	  }
-	  //cout << "Number of in+out-edges: " << edgenumber << endl;
-	  assignments=new actedgesubnodestruct[edgenumber];
-	  for(int i=0;i<edgenumber;i++)
+	else
 	  {
-	    assignments[i].actedge=INVALID;
-	    assignments[i].subnode=INVALID;
+	    cerr << "There is no actual layer defined yet!" << endl;
+	    return -1;
 	  }
-	}
-	else
-	{
-	  cerr << "There is no actual layer defined yet!" << endl;
-	  return -1;
-	}
 
 	return 0;
       }
 
-      SubNetwork(): edgenumber(0), connectable(false), actuallayer(NULL), actuallayernode(NULL), subnetwork(NULL), assignments(NULL)
+    SubNetwork ():edgenumber (0), connectable (false), actuallayer (NULL),
+	actuallayernode (NULL), subnetwork (NULL),
+	assignments (NULL)
       {
       }
 
     };
 
-    typename Gact::template NodeMap< SubNetwork > subnetworks;
+    typename Gact::template NodeMap < SubNetwork > subnetworks;
 
 
     /// Defalult constructor.
     /// We don't need any extra lines, because the actuallayer
     /// variable has run its constructor, when we have created this class
     /// So only the two maps has to be initialised here.
-    HierarchyGraph() : subnetworks(actuallayer)
+  HierarchyGraph ():subnetworks (actuallayer)
     {
     }
 
 
     ///Copy consructor.
-    HierarchyGraph(const HierarchyGraph<Gact, Gsub> & HG ) : actuallayer(HG.actuallayer), subnetworks(actuallayer)
+  HierarchyGraph (const HierarchyGraph < Gact, Gsub > &HG):actuallayer (HG.actuallayer),
+      subnetworks
+      (actuallayer)
     {
     }
 
@@ -197,7 +218,7 @@
 
     /// The base type of the edge iterators.
     /// The Edge type of the HierarchyGraph is the Edge type of the actual layer.
-    typedef typename  Gact::Edge Edge;
+    typedef typename Gact::Edge Edge;
 
 
     /// This iterator goes trough the outgoing edges of a node.
@@ -247,20 +268,34 @@
 
     /// \retval i the first node.
     /// \return the first node.
-    typename Gact::NodeIt &first(typename Gact::NodeIt &i) const { return actuallayer.first(i);}
+    typename Gact::NodeIt & first (typename Gact::NodeIt & i) const
+    {
+      return actuallayer.first (i);
+    }
 
 
     /// The first incoming edge.
-    typename Gact::InEdgeIt &first(typename Gact::InEdgeIt &i, typename Gact::Node) const { return actuallayer.first(i);}
+    typename Gact::InEdgeIt & first (typename Gact::InEdgeIt & i,
+				     typename Gact::Node) const
+    {
+      return actuallayer.first (i);
+    }
 
 
     /// The first outgoing edge.
-    typename Gact::OutEdgeIt &first(typename Gact::OutEdgeIt &i, typename Gact::Node) const { return actuallayer.first(i);}
+    typename Gact::OutEdgeIt & first (typename Gact::OutEdgeIt & i,
+				      typename Gact::Node) const
+    {
+      return actuallayer.first (i);
+    }
 
 
     //  SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
     /// The first edge of the Graph.
-    typename Gact::EdgeIt &first(typename Gact::EdgeIt &i) const { return actuallayer.first(i);}
+    typename Gact::EdgeIt & first (typename Gact::EdgeIt & i) const
+    {
+      return actuallayer.first (i);
+    }
 
 
 //     Node getNext(Node) const {}
@@ -271,19 +306,37 @@
 
 
     /// Go to the next node.
-    typename Gact::NodeIt &next(typename Gact::NodeIt &i) const { return actuallayer.next(i);}
+    typename Gact::NodeIt & next (typename Gact::NodeIt & i) const
+    {
+      return actuallayer.next (i);
+    }
     /// Go to the next incoming edge.
-    typename Gact::InEdgeIt &next(typename Gact::InEdgeIt &i) const { return actuallayer.next(i);}
+    typename Gact::InEdgeIt & next (typename Gact::InEdgeIt & i) const
+    {
+      return actuallayer.next (i);
+    }
     /// Go to the next outgoing edge.
-    typename Gact::OutEdgeIt &next(typename Gact::OutEdgeIt &i) const { return actuallayer.next(i);}
+    typename Gact::OutEdgeIt & next (typename Gact::OutEdgeIt & i) const
+    {
+      return actuallayer.next (i);
+    }
     //SymEdgeIt &next(SymEdgeIt &) const {}
     /// Go to the next edge.
-    typename Gact::EdgeIt &next(typename Gact::EdgeIt &i) const { return actuallayer.next(i);}
+    typename Gact::EdgeIt & next (typename Gact::EdgeIt & i) const
+    {
+      return actuallayer.next (i);
+    }
 
     ///Gives back the head node of an edge.
-    typename Gact::Node head(typename Gact::Edge edge) const { return actuallayer.head(edge); }
+    typename Gact::Node head (typename Gact::Edge edge) const
+    {
+      return actuallayer.head (edge);
+    }
     ///Gives back the tail node of an edge.
-    typename Gact::Node tail(typename Gact::Edge edge) const { return actuallayer.tail(edge); }
+    typename Gact::Node tail (typename Gact::Edge edge) const
+    {
+      return actuallayer.tail (edge);
+    }
 
     //   Node aNode(InEdgeIt) const {}
     //   Node aNode(OutEdgeIt) const {}
@@ -297,23 +350,35 @@
 
     ///\todo Maybe, it would be better if iterator converted to
     ///bool directly, as Jacint prefers.
-    bool valid(const typename Gact::Node& node) const { return actuallayer.valid(node);}
+    bool valid (const typename Gact::Node & node) const
+    {
+      return actuallayer.valid (node);
+    }
     /// Checks if an edge iterator is valid
 
     ///\todo Maybe, it would be better if iterator converted to
     ///bool directly, as Jacint prefers.
-    bool valid(const typename Gact::Edge& edge) const { return actuallayer.valid(edge);}
+    bool valid (const typename Gact::Edge & edge) const
+    {
+      return actuallayer.valid (edge);
+    }
 
     ///Gives back the \e id of a node.
 
     ///\warning Not all graph structures provide this feature.
     ///
-    int id(const typename Gact::Node & node) const { return actuallayer.id(node);}
+    int id (const typename Gact::Node & node) const
+    {
+      return actuallayer.id (node);
+    }
     ///Gives back the \e id of an edge.
 
     ///\warning Not all graph structures provide this feature.
     ///
-    int id(const typename Gact::Edge & edge) const { return actuallayer.id(edge);}
+    int id (const typename Gact::Edge & edge) const
+    {
+      return actuallayer.id (edge);
+    }
 
     //void setInvalid(Node &) const {};
     //void setInvalid(Edge &) const {};
@@ -322,22 +387,38 @@
 
     /// \return the new node.
     ///
-    typename Gact::Node addNode() { return actuallayer.addNode();}
+    typename Gact::Node addNode ()
+    {
+      return actuallayer.addNode ();
+    }
     ///Add a new edge to the graph.
 
     ///Add a new edge to the graph with tail node \c tail
     ///and head node \c head.
     ///\return the new edge.
-    typename Gact::Edge addEdge(typename Gact::Node node1, typename Gact::Node node2) { return actuallayer.addEdge(node1, node2);}
+    typename Gact::Edge addEdge (typename Gact::Node node1,
+				 typename Gact::Node node2)
+    {
+      return actuallayer.addEdge (node1, node2);
+    }
 
     /// Resets the graph.
 
     /// This function deletes all edges and nodes of the graph.
     /// It also frees the memory allocated to store them.
-    void clear() {actuallayer.clear();}
+    void clear ()
+    {
+      actuallayer.clear ();
+    }
 
-    int nodeNum() const { return actuallayer.nodeNum();}
-    int edgeNum() const { return actuallayer.edgeNum();}
+    int nodeNum () const
+    {
+      return actuallayer.nodeNum ();
+    }
+    int edgeNum () const
+    {
+      return actuallayer.edgeNum ();
+    }
 
     ///Read/write/reference map of the nodes to type \c T.
 
@@ -349,33 +430,51 @@
     /// \warning Making maps that can handle bool type (NodeMap<bool>)
     /// needs extra attention!
 
-    template<class T> class NodeMap
+    template < class T > class NodeMap
     {
     public:
       typedef T ValueType;
       typedef Node KeyType;
 
-      NodeMap(const HierarchyGraph &) {}
-      NodeMap(const HierarchyGraph &, T) {}
+      NodeMap (const HierarchyGraph &)
+      {
+      }
+      NodeMap (const HierarchyGraph &, T)
+      {
+      }
 
-      template<typename TT> NodeMap(const NodeMap<TT> &) {}
+      template < typename TT > NodeMap (const NodeMap < TT > &)
+      {
+      }
 
       /// Sets the value of a node.
 
       /// Sets the value associated with node \c i to the value \c t.
       ///
-      void set(Node, T) {}
+      void set (Node, T)
+      {
+      }
       // Gets the value of a node.
       //T get(Node i) const {return *(T*)0;}  //FIXME: Is it necessary?
-      T &operator[](Node) {return *(T*)0;}
-      const T &operator[](Node) const {return *(T*)0;}
+      T & operator[](Node)
+      {
+	return *(T *) 0;
+      }
+      const T & operator[] (Node) const
+      {
+	return *(T *) 0;
+      }
 
       /// Updates the map if the graph has been changed
 
       /// \todo Do we need this?
       ///
-      void update() {}
-      void update(T a) {}   //FIXME: Is it necessary
+      void update ()
+      {
+      }
+      void update (T a)
+      {
+      }				//FIXME: Is it necessary
     };
 
     ///Read/write/reference map of the edges to type \c T.
@@ -387,26 +486,44 @@
     /// \todo We may need copy constructor
     /// \todo We may need conversion from other edgetype
     /// \todo We may need operator=
-    template<class T> class EdgeMap
+    template < class T > class EdgeMap
     {
     public:
       typedef T ValueType;
       typedef Edge KeyType;
 
-      EdgeMap(const HierarchyGraph &) {}
-      EdgeMap(const HierarchyGraph &, T ) {}
+      EdgeMap (const HierarchyGraph &)
+      {
+      }
+      EdgeMap (const HierarchyGraph &, T)
+      {
+      }
 
       ///\todo It can copy between different types.
       ///
-      template<typename TT> EdgeMap(const EdgeMap<TT> &) {}
+      template < typename TT > EdgeMap (const EdgeMap < TT > &)
+      {
+      }
 
-      void set(Edge, T) {}
+      void set (Edge, T)
+      {
+      }
       //T get(Edge) const {return *(T*)0;}
-      T &operator[](Edge) {return *(T*)0;}
-      const T &operator[](Edge) const {return *(T*)0;}
+      T & operator[](Edge)
+      {
+	return *(T *) 0;
+      }
+      const T & operator[] (Edge) const
+      {
+	return *(T *) 0;
+      }
 
-      void update() {}
-      void update(T a) {}   //FIXME: Is it necessary
+      void update ()
+      {
+      }
+      void update (T a)
+      {
+      }				//FIXME: Is it necessary
     };
   };
 
@@ -429,25 +546,36 @@
   /// feature, the documentation of a real graph imlementation
   /// like @ref ListGraph or
   /// @ref SmartGraph will just refer to this structure.
-  template <typename Gact, typename Gsub>
-  class EraseableHierarchyGraph : public HierarchyGraph<Gact, Gsub>
+template < typename Gact, typename Gsub > class EraseableHierarchyGraph:public HierarchyGraph < Gact,
+    Gsub
+    >
   {
   public:
     /// Deletes a node.
-    void erase(typename Gact::Node n) {actuallayer.erase(n);}
+    void erase (typename Gact::Node n)
+    {
+      actuallayer.erase (n);
+    }
     /// Deletes an edge.
-    void erase(typename Gact::Edge e) {actuallayer.erase(e);}
+    void erase (typename Gact::Edge e)
+    {
+      actuallayer.erase (e);
+    }
 
     /// Defalult constructor.
-    EraseableHierarchyGraph() {}
+    EraseableHierarchyGraph ()
+    {
+    }
     ///Copy consructor.
-    EraseableHierarchyGraph(const HierarchyGraph<Gact, Gsub> &EPG) {}
+    EraseableHierarchyGraph (const HierarchyGraph < Gact, Gsub > &EPG)
+    {
+    }
   };
 
 
   // @}
 
-} //namespace hugo
+}				//namespace hugo
 
 
 #endif // HUGO_SKELETON_GRAPH_H



More information about the Lemon-commits mailing list