Polaris: SimBiGraph.h Source File

SimBiGraph.h

Go to the documentation of this file.
00001 ///
00002 #ifndef _SIMBIGRAPH_H
00003 #define _SIMBIGRAPH_H
00004 ///
00005 /// \class SimBiGraph 
00006 /// \brief a class for a bipartite Similarity graph
00007 /// \defgroup Base
00008 /// \ingroup Base
00009 ///  General utility routines
00010 /// \see SimBiGraph.h
00011 /// \see SimBiGraph.cc
00012 /// \see SimBiGraph.h
00013 ///
00014 /// \endcode
00015 /// \section Description Description
00016 /// This module contains the structures needed to represent
00017 /// a Similarity graph for two sets of access descriptors.  
00018 /// This is a complete graph (in the sense
00019 /// that there are edges between all possible pairs of nodes)
00020 /// in which the nodes represent access descriptors and the edges
00021 /// contain information about the similarity between the descriptors.
00022 /// 
00023 /// The similarity information consists of a similarity type
00024 /// (equivalent, dimension-equivalent, stride-equivalent, not-similar, etc),
00025 /// and for those that are not not-similar, a matching is given 
00026 /// showing which dimensions match between the two descriptors.
00027 ///
00028 /// This is different from the SimGraph because in the SimGraph, there is
00029 /// only one set of descriptors.  In the SimBiGraph, the _graph can be
00030 /// viewed as an complete "adjacency" matrix.  All nodes are "adjacent"
00031 /// to all others.  In other words, each node of one set has a connection
00032 /// to all nodes of the other set.  The _graph is indexed in a two-dimensional
00033 /// way, e.g. ((*_graph)[i])[j], in both the SimGraph and the SimBiGraph,
00034 /// but in the SimGraph that means the relationship between node i and node j.
00035 /// 
00036 /// So, in the SimGraph, ((*_graph)[i])[j] and ((*_graph)[j])[i] 
00037 /// are really between the same two nodes, but representing the 
00038 /// relationship viewed from opposite ends of the single edge.
00039 ///
00040 /// In the SimBiGraph, ((*_graph)[i])[j] and ((*_graph)[j])[i] 
00041 /// the first represents the relationship between node i of the first set
00042 /// and node j of the second set.  The second represents the relationship
00043 /// between node j of the first set and node i of the second set, which
00044 /// are two completely different pairs of nodes.
00045 ///
00046 /// \endcode
00047 /// \section KNOWN KNOWN/POSSIBLE BUGS/LIMITATIONS
00048 ///
00049 #ifdef POLARIS_GNU_PRAGMAS
00050 #pragma interface
00051 #endif
00052 ///
00053 #include "ClassNames.h"
00054 #include "Listable.h"
00055 #include "SimEdgeKernel.h"
00056 #include "SimBiGraph.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 class SimBiGraphIterator;
00064 
00065 class SimBiGraph : public Listable {
00066 
00067     friend class SimBiGraphIterator;
00068 
00069 protected:
00070     Array< RefElement< AbstractAccess > > * _ptrs1;///< pointers to the descriptors for the nodes from list 1
00071     Array< RefElement< AbstractAccess > > * _ptrs2;///< pointers to the descriptors for the nodes from list 2
00072     Array< Array< SimEdgeKernel > > * _graph; ///< adjacency matrix
00073     short _nodes1;                 ///< Number of access descriptors, list 1
00074     short _nodes2;                ///< Number of access descriptors, list 2
00075     RangeAccessor * _range_acc;  ///< RangeAccessor for doing comparisons among the descriptors
00076 
00077  public:
00078     SimBiGraph( );
00079     SimBiGraph( const SimBiGraph & );
00080     SimBiGraph(List<AbstractAccess> & list1,
00081            List<AbstractAccess> & list2); ///< make a Similarity graph between two lists
00082 
00083     ~SimBiGraph( );
00084 
00085     int nodes1( );         ///< return the number of nodes in list 1 of the graph
00086     int nodes2( );         ///< return the number of nodes in list 2 of the graph
00087     
00088     SimEdgeKernel & kernel(int i, int j);
00089     ///< Return the SimEdgeKernel corresponding to edge (i,j) in the graph.
00090 
00091     ///< add edges determined by transitivity (a = b && b = c ==> a = c)
00092     void _add_corresp_edge_forward(SimilarityType type, int index_new, int index_mid, int index_old,
00093                      Array<int> * stride_match, Array<bool> * span_match);
00094     void _add_corresp_edge_backward(SimilarityType type, int index_old, 
00095                     int index_mid, int index_new,
00096                     Array<int> * stride_match, Array<bool> * span_match);
00097 
00098     RangeAccessor * range_acc( );  ///< return the RangeAccessor
00099     void calc_similarity( int node1, int node2 ); 
00100     ///< Calculate the similarity relationship between two nodes in graph
00101     ///< node1 from list 1 and node2 from list 2
00102 
00103     void print_similarities( ) const;
00104 
00105     void redo_spanmatch( SimEdge & edge, int which_node, int which_dim );
00106 
00107     virtual SimBiGraph *clone() const;
00108 
00109     ///< This one is to satisfy Listable
00110     virtual void    print(ostream & o) const;
00111     virtual Listable *listable_clone() const;
00112 
00113     friend ostream & operator << (ostream & o, const SimBiGraph & ad);
00114 };
00115 
00116 #endif
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:06:07 2005