| Polaris: SimGraph.h Source File | ||
|
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
SimGraph.hGo to the documentation of this file.00001 #ifndef _SIMGRAPH_H 00002 #define _SIMGRAPH_H 00003 /// 00004 /// \class SimGraph 00005 /// \brief a class for a Similarity graph 00006 /// \defgroup Base 00007 /// \ingroup Base 00008 /// General utility routines 00009 /// \see SimGraph.h 00010 /// \see SimGraph.cc 00011 /// \see SimGraph.h 00012 /// 00013 /// \endcode 00014 /// \section Description Description 00015 /// This module contains the structures needed to represent 00016 /// a Similarity graph. This is a complete graph (in the sense 00017 /// that there are edges between all possible pairs of nodes) 00018 /// in which the nodes represent access descriptors and the edges 00019 /// contain information about the similarity between the descriptors. 00020 /// 00021 /// The similarity information consists of a similarity type 00022 /// (equivalent, dimension-equivalent, stride-equivalent, not-similar), 00023 /// and for those that are not not-similar, a matching is given 00024 /// showing which dimensions match between the two descriptors. 00025 /// 00026 /// This is different from the SimBiGraph because in the SimBiGraph, there are 00027 /// two sets of descriptors. In the SimGraph, the _graph can be 00028 /// viewed as an complete "adjacency" matrix for a single set of nodes. 00029 /// All nodes are "adjacent" to all others. In other words, each node 00030 /// of one set has a connection to all nodes of the other set. The _graph 00031 /// is indexed in a two-dimensional way, e.g. ((*_graph)[i])[j], in both the 00032 /// SimGraph and the SimBiGraph, but in the SimBiGraph that means the 00033 /// relationship between node i of the first set and node j of the second set. 00034 /// 00035 /// So, in the SimBiGraph, ((*_graph)[i])[j] and ((*_graph)[j])[i], 00036 /// the first represents the relationship between node i of the first set 00037 /// and node j of the second set. The second represents the relationship 00038 /// between node j of the first set and node i of the second set, which 00039 /// are two completely different pairs of nodes. 00040 /// 00041 /// In the SimGraph, ((*_graph)[i])[j] and ((*_graph)[j])[i] 00042 /// really represent the relationship between the same two nodes, but 00043 /// viewed from opposite ends of the single edge. 00044 /// 00045 /// 00046 /// 00047 /// \endcode 00048 /// \section KNOWN KNOWN/POSSIBLE BUGS/LIMITATIONS 00049 /// 00050 #ifdef POLARIS_GNU_PRAGMAS 00051 #pragma interface 00052 #endif 00053 /// 00054 #include "ClassNames.h" 00055 #include "Listable.h" 00056 #include "SimEdgeKernel.h" 00057 #include "SimEdge.h" 00058 #include "Array.h" 00059 #include "AbstractAccess.h" 00060 #include "Collection/RefElement.h" 00061 #include "Range/RangeAccessor.h" 00062 /// 00063 enum SimTypeOfChange { SIM_NOCHANGE, 00064 SIM_EQUIVALENCE, 00065 SIM_SUBREG_NODE1, 00066 SIM_SUBREG_NODE2, 00067 SIM_COALESCE_NODE1, 00068 SIM_COALESCE_NODE2, 00069 SIM_CONTIG_NODE1, 00070 SIM_CONTIG_NODE2 }; 00071 /// 00072 class SimGraphIterator; 00073 00074 class SimGraph : public Listable { 00075 00076 friend class SimGraphIterator; 00077 00078 protected: 00079 Array< bool > * _descr_exists; ///< Whether the given descriptor exists 00080 Array< RefElement< AbstractAccess > > * _ptrs;///< pointers to the descriptors for the nodes 00081 Array< Array< SimEdgeKernel > > * _graph; ///< adjacency matrix 00082 short _nodes; ///< Number of access descriptors, list 1 00083 RangeAccessor * _range_acc; ///< RangeAccessor for doing comparisons among the descriptors 00084 00085 public: 00086 SimGraph( ); 00087 SimGraph( const SimGraph & ); 00088 SimGraph( List<AbstractAccess> & list ); ///< make a complete graph with given number of nodes 00089 ~SimGraph( ); 00090 00091 int nodes( ); ///< return the number of nodes in the graph 00092 00093 ///< add edges determined by transitivity (a = b && b = c ==> a = c) 00094 void _add_corresp_edge_forward(SimilarityType type, int index_new, int index_mid, int index_old, 00095 Array<int> * stride_match, Array<bool> * span_match); 00096 void _add_corresp_edge_backward(SimilarityType type, int index_old, int index_mid, int index_new, 00097 Array<int> * stride_match, Array<bool> * span_match); 00098 00099 SimEdgeKernel & kernel(int i, int j); 00100 ///< Return the SimEdgeKernel corresponding to edge (i,j) in the graph. 00101 00102 RangeAccessor * range_acc( ); ///< return the RangeAccessor 00103 void calc_similarity( int node1, int node2 ); 00104 ///< Calculate the similarity relationship between two nodes in graph 00105 00106 void set_ptr(int i, AbstractAccess & aa); 00107 ///< Set a given ptr element 00108 00109 void print_similarities( ) const; 00110 00111 void redo_spanmatch( SimEdge & edge, int which_node, int which_dim ); 00112 00113 void set_unknown( SimEdge & edge, int which_node); 00114 00115 virtual SimGraph *clone() const; 00116 00117 ///< This one is to satisfy Listable 00118 virtual void print(ostream & o) const; 00119 virtual Listable *listable_clone() const; 00120 00121 friend ostream & operator << (ostream & o, const SimGraph & ad); 00122 }; 00123 00124 #endif |
||
|