Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:36

0001 /* This software is distributed under the GNU Lesser General Public License */
0002 //==========================================================================
0003 //
0004 //   edge.h
0005 //
0006 //==========================================================================
0007 // $Id: edge.h,v 1.15 2001/04/17 14:35:25 raitner Exp $
0008 
0009 #ifndef GTL_EDGE_H
0010 #define GTL_EDGE_H
0011 
0012 #include <GTL/GTL.h>
0013 
0014 #include <list>
0015 #include <ostream>
0016 
0017 __GTL_BEGIN_NAMESPACE
0018  
0019 //--------------------------------------------------------------------------
0020 //   For MSVC 5.0 edge.h has to be included before node.h and
0021 //   {node,edge}_data.h. So we only declare needed classnames here
0022 //--------------------------------------------------------------------------
0023 
0024 class node;
0025 class edge_data;
0026 
0027 //--------------------------------------------------------------------------
0028 //   edge
0029 //--------------------------------------------------------------------------
0030 
0031 /**
0032  * @short An edge in a graph
0033  */
0034 class GTL_EXTERN edge
0035 {
0036 public:
0037     /**
0038      * Default constructor. Creates an invalid edge. 
0039      * The only way to obtain a valid edge is through @ref
0040      * graph#new_edge. Example:
0041      * <pre>
0042      *   graph g;
0043      *   node n1, n2;
0044      *   edge e;
0045      *
0046      *   n1 = g.new_node();
0047      *   n2 = g.new_node();
0048      *   e = g.new_edge(n1, n2);
0049      * </pre>
0050      *
0051      * @see graph#new_edge
0052      */
0053     edge();
0054 
0055     /**
0056      * Returns the source node of the edge.
0057      * 
0058      * @return source
0059      */
0060     node source() const;
0061 
0062     /**
0063      * Returns the target node of the edge.
0064      * 
0065      * @return target
0066      */
0067     node target() const;
0068 
0069     /**
0070      * Changes the direction of this edge. 
0071      */
0072     void reverse ();
0073 
0074     /**
0075      * Makes <code>n</code> the source of this edge. Takes O(1) time. 
0076      * 
0077      * @param <code>n</code> new source 
0078      */
0079     void change_source (node n);
0080 
0081     /**
0082      * Makes <code>n</code> the target of this edge. Takes O(1) time. 
0083      * 
0084      * @param <code>n</code> new target 
0085      */
0086     void change_target (node n);
0087 
0088     /**
0089      * Returns the node opposite to <code>n</code> referring to
0090      * this edge.
0091      * 
0092      * @param <code>n</code> a node incident to this edge
0093      */
0094     const node& opposite(node n) const;
0095 
0096     /**
0097      * @internal
0098      */
0099     list<node> sources() const;
0100 
0101     /**
0102      * @internal
0103      */
0104     list<node> targets() const;
0105 
0106     /**
0107      * @internal
0108      */
0109     int id() const;
0110 
0111     
0112     /**
0113      * Returns true iff node is hidden. 
0114      * 
0115      * @return true iff node is hidden.
0116      * @see graph#hide_edge
0117      * @see graph#restore_edge
0118      */
0119     bool is_hidden () const;
0120 
0121 
0122     //================================================== Implementation
0123     
0124 private:
0125     edge_data *data;
0126     
0127     void remove_from(int where) const; // 0 = sources, 1 == targets
0128 
0129     friend class graph;
0130     friend class node;
0131     
0132     GTL_EXTERN friend bool operator==(edge, edge);
0133     GTL_EXTERN friend bool operator!=(edge, edge);
0134     GTL_EXTERN friend bool operator<(edge, edge);
0135     GTL_EXTERN friend ostream& operator<< (ostream& os, const edge& e);
0136 };
0137 
0138 __GTL_END_NAMESPACE
0139 
0140 #endif // GTL_EDGE_H
0141 
0142 //--------------------------------------------------------------------------
0143 //   end of file
0144 //--------------------------------------------------------------------------