Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members Related Pages

# DAGNode.h

Go to the documentation of this file.

    00001
    00043 #ifndef __DAGNODE_H__
    00044 #define __DAGNODE_H__
    00045
    00046 #include <LEDA/string.h>
    00047 #include <LEDA/color.h>
    00048 #include "SmartArray.h"
    00049 #include "SmartPtr.h"
    00050 #include "TSV.h"
    00051 #include "String.h"
    00052 #include "Debug.h"
    00053 #include "LEDA_issues.h"
    00054
    00055 typedef String NODE_LABEL;
    00056
    00057 #define NODE_LBL_DEFAULT_VAL "DLV"
    00058
    00080 class DAGNode
    00081 {
    00082         NODE_LABEL                      nodeLbl;
    00083         TSV                                     childrenTSV;
    00084         double                          eigenLbl;
    00085
    00086         // Derived values
    00087         double                          tsvNorm;
    00088         int                                     nMass;
    00089         int                                     nLevel;
    00090         int                                     nDFSIndex;
    00091
    00092         bool                            bVisited;
    00093         double                          dAssignedSimilarity;
    00094
    00095 public:
    00096         typedef int label_type;
    00097
    00098         DAGNode(NODE_LABEL lbl = NODE_LBL_DEFAULT_VAL);
    00099
    00100         DAGNode(const DAGNode& rhs) { DAGNode::operator=(rhs); }
    00101
    00102         // Pure virtual functions
    00103         virtual DAGNode* CreateObject() const = 0;
    00104
    00105         // Virtual functions
    00106         virtual ~DAGNode() { }
    00107         virtual DAGNode& operator=(const DAGNode& rhs);
    00108         virtual void Clear();
    00109         virtual istream& Read(istream& is);
    00110         virtual ostream& Write(ostream& os) const;
    00111         virtual void Print(ostream& os = cout) const;
    00112
    00113         virtual NODE_LABEL GetLblForGraph() const;
    00114         virtual leda_color GetColorForGraph() const;
    00115         virtual int GetShapeForGraph() const;
    00116
    00117         virtual void ComputeDerivedValues();
    00118
    00120         //virtual double operator-(const DAGNode& node) = 0;
    00121
    00122         // Non-virtual functions
    00123
    00124         void Set(NODE_LABEL nl, double el)              { nodeLbl = nl; eigenLbl = el; }
    00125
    00126         void SetNodeLbl(NODE_LABEL lbl)                 { nodeLbl = lbl; }
    00127         NODE_LABEL GetNodeLbl() const                   { return nodeLbl; }
    00128
    00129         void SetEigenLbl(double lbl)                    { eigenLbl = lbl; }
    00130         double GetEigenLbl() const                              { return eigenLbl; }
    00131
    00132         void SetMass(int m)                                             { nMass = m; }
    00133         void SetLevel(int l)                                    { nLevel = l; }
    00134         void SetDFSIndex(int i)                                 { nDFSIndex = i; }
    00135
    00136         void SetVisited(bool bVal = true)               { bVisited = bVal; }
    00137
    00139         void SetChildrenTSV(const TSV& tsv) { childrenTSV = tsv; }
    00140
    00141         TSV GetTSV(int nDim) const;
    00142         const TSV& GetTSV()     const                           { return childrenTSV; }
    00143         TSV& GetTSV()                                                   { return childrenTSV; }
    00144
    00145         double GetTSVNorm()     const                           { ASSERT(tsvNorm >= 0); return tsvNorm; }
    00146         int GetMass() const                                             { return nMass; }
    00147         int GetLevel() const                                    { return nLevel; }
    00148         int GetDFSIndex() const                                 { return nDFSIndex; }
    00149
    00150         bool Visited() const                                    { return bVisited; }
    00151         void SetSimilarity(double s)                    { dAssignedSimilarity = s; }
    00152         double GetSimilarity() const                    { return dAssignedSimilarity; }
    00153
    00154
    00155         friend ostream& operator<<(ostream &os, const DAGNode& node) { return node.Write(os); }
    00156         friend istream& operator>>(istream &is, DAGNode& node)           { return node.Read(is); }
    00157 };
    00158
    00160 typedef SmartPtr<DAGNode> DAGNodePtr;
    00161
    00162 #endif //__DAGNODE_H__