ColPack
BipartiteGraphBicoloring/BipartiteGraphCore.cpp
Go to the documentation of this file.
00001 /************************************************************************************
00002     Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
00003     Alex Pothen
00004 
00005     This file is part of ColPack.
00006 
00007     ColPack is free software: you can redistribute it and/or modify
00008     it under the terms of the GNU Lesser General Public License as published
00009     by the Free Software Foundation, either version 3 of the License, or
00010     (at your option) any later version.
00011 
00012     ColPack is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public License
00018     along with ColPack.  If not, see <http://www.gnu.org/licenses/>.
00019 ************************************************************************************/
00020 
00021 #include "ColPackHeaders.h"
00022 
00023 using namespace std;
00024 
00025 namespace ColPack
00026 {
00027         //Virtual Function 2102:3102
00028         void BipartiteGraphCore::Clear()
00029         {
00030                 m_i_MaximumLeftVertexDegree = _UNKNOWN;
00031                 m_i_MaximumRightVertexDegree = _UNKNOWN;
00032                 m_i_MaximumVertexDegree = _UNKNOWN;
00033 
00034                 m_i_MinimumLeftVertexDegree = _UNKNOWN;
00035                 m_i_MinimumRightVertexDegree = _UNKNOWN;
00036                 m_i_MinimumVertexDegree = _UNKNOWN;
00037 
00038                 m_d_AverageLeftVertexDegree = _UNKNOWN;
00039                 m_d_AverageRightVertexDegree = _UNKNOWN;
00040                 m_d_AverageVertexDegree = _UNKNOWN;
00041 
00042                 m_s_InputFile.clear();
00043 
00044                 m_vi_LeftVertices.clear();
00045                 m_vi_RightVertices.clear();
00046 
00047                 m_vi_Edges.clear();
00048 
00049                 m_mimi2_VertexEdgeMap.clear();
00050 
00051         }
00052 
00053         //Public Function 2103:3103
00054         string BipartiteGraphCore::GetInputFile()
00055         {
00056                 return(m_s_InputFile);
00057         }
00058         
00059         vector<int>* BipartiteGraphCore::GetLeftVerticesPtr()
00060         {
00061                 return &m_vi_LeftVertices;
00062         }
00063 
00064         vector<int>* BipartiteGraphCore::GetRightVerticesPtr()
00065         {
00066                 return &m_vi_RightVertices;
00067         }
00068 
00069 
00070         //Public Function 2104:3104
00071         void BipartiteGraphCore::GetRowVertices(vector<int> &output)  const
00072         {
00073                 output = (m_vi_LeftVertices);
00074         }
00075 
00076         unsigned int BipartiteGraphCore::GetRowVertices(unsigned int** ip2_RowVertex)
00077         {
00078                 (*ip2_RowVertex) = (unsigned int*) malloc(m_vi_LeftVertices.size() * sizeof(unsigned int));
00079                 for(unsigned int i=0; i < m_vi_LeftVertices.size(); i++) {
00080                         (*ip2_RowVertex)[i] = m_vi_LeftVertices[i];
00081                 }
00082                 return m_vi_LeftVertices.size();
00083         }
00084 
00085         unsigned int BipartiteGraphCore::GetColumnIndices(unsigned int** ip2_ColumnIndex)
00086         {
00087                 unsigned int ui_UpperBound = m_vi_LeftVertices[m_vi_LeftVertices.size() - 1];
00088                 (*ip2_ColumnIndex) = (unsigned int*) malloc(ui_UpperBound * sizeof(unsigned int));
00089                 for(unsigned int i=0; i < ui_UpperBound; i++) {
00090                         (*ip2_ColumnIndex)[i] = m_vi_Edges[i];
00091                 }
00092                 return ui_UpperBound;
00093         }
00094 
00095         void BipartiteGraphCore::GetLeftVertices(vector<int> &output)  const
00096         {
00097                 output = (m_vi_LeftVertices);
00098         }
00099 
00100         //Public Function 2105:3105
00101         void BipartiteGraphCore::GetColumnVertices(vector<int> &output)  const
00102         {
00103                 output = (m_vi_RightVertices);
00104         }
00105 
00106         void BipartiteGraphCore::GetRightVertices(vector<int> &output)  const
00107         {
00108                 output = (m_vi_RightVertices);
00109         }
00110 
00111         //Public Function 2106:3106
00112         void BipartiteGraphCore::GetEdges(vector<int> &output)  const
00113         {
00114                 output = (m_vi_Edges);
00115         }
00116 
00117         //Public Function 2107:3107
00118         void BipartiteGraphCore::GetVertexEdgeMap(map< int, map<int, int> > &output)
00119         {
00120                 output = (m_mimi2_VertexEdgeMap);
00121         }
00122 
00123 
00124         //Public Function 2108:3108
00125         int BipartiteGraphCore::GetRowVertexCount()
00126         {
00127                 return(STEP_DOWN(m_vi_LeftVertices.size()));
00128         }
00129 
00130         int BipartiteGraphCore::GetLeftVertexCount()
00131         {
00132                 return(STEP_DOWN(m_vi_LeftVertices.size()));
00133         }
00134 
00135 
00136         //Public Function 2109:3109
00137         int BipartiteGraphCore::GetColumnVertexCount()
00138         {
00139                 return(STEP_DOWN(m_vi_RightVertices.size()));
00140         }
00141 
00142         int BipartiteGraphCore::GetRightVertexCount()
00143         {
00144                 return(STEP_DOWN(m_vi_RightVertices.size()));
00145         }
00146 
00147 
00148         //Public Function 2110:3110
00149         int BipartiteGraphCore::GetEdgeCount()
00150         {
00151                 return(m_vi_Edges.size()/2);
00152         }
00153 
00154 
00155         //Public Function 2111:3111
00156         int BipartiteGraphCore::GetMaximumRowVertexDegree()
00157         {
00158                 return(m_i_MaximumLeftVertexDegree);
00159         }
00160 
00161 
00162         //Public Function 2112:3112
00163         int BipartiteGraphCore::GetMaximumColumnVertexDegree()
00164         {
00165                 return(m_i_MaximumRightVertexDegree);
00166         }
00167 
00168 
00169         //Public Function 2113:3113
00170         int BipartiteGraphCore::GetMaximumVertexDegree()
00171         {
00172                 return(m_i_MaximumVertexDegree);
00173         }
00174 
00175 
00176         //Public Function 2114:3114
00177         int BipartiteGraphCore::GetMinimumRowVertexDegree()
00178         {
00179                 return(m_i_MinimumLeftVertexDegree);
00180         }
00181 
00182 
00183         //Public Function 2115:3115
00184         int BipartiteGraphCore::GetMinimumColumnVertexDegree()
00185         {
00186                 return(m_i_MinimumRightVertexDegree);
00187         }
00188 
00189 
00190         //Public Function 2116:3116
00191         int BipartiteGraphCore::GetMinimumVertexDegree()
00192         {
00193                 return(m_i_MinimumVertexDegree);
00194         }
00195 
00196 
00197         //Public Function 2117:3117
00198         double BipartiteGraphCore::GetAverageRowVertexDegree()
00199         {
00200                 return(m_d_AverageLeftVertexDegree);
00201         }
00202 
00203         //Public Function 2118:3118
00204         double BipartiteGraphCore::GetAverageColumnVertexDegree()
00205         {
00206                 return(m_d_AverageRightVertexDegree);
00207         }
00208 
00209         //Public Function 2119:3119
00210         double BipartiteGraphCore::GetAverageVertexDegree()
00211         {
00212                 return(m_d_AverageVertexDegree);
00213         }
00214         
00215         bool BipartiteGraphCore::operator==(const BipartiteGraphCore &other) const {
00216                 // Check for self-assignment!
00217                 if (this == &other)      // Same object?
00218                   return true;        // Yes, so the 2 objects are equal
00219                   
00220                 //Compare vector<int> m_vi_LeftVertices; vector<int> m_vi_RightVertices; vector<int> m_vi_Edges;
00221                 vector<int> other_LeftVertices, other_RightVertices, other_Edges;
00222                 
00223                 other.GetLeftVertices(other_LeftVertices);
00224                 other.GetRightVertices(other_RightVertices);
00225                 other.GetEdges(other_Edges);
00226                 
00227                 /*
00228                 if(m_vi_LeftVertices==other_LeftVertices) cout<<"m_vi_LeftVertices==other_LeftVertices"<<endl;
00229                 else  cout<<"m_vi_LeftVertices!=other_LeftVertices"<<endl;
00230                 
00231                 if(m_vi_Edges==other_Edges) cout<<"m_vi_Edges==other_Edges"<<endl;
00232                 else  cout<<"m_vi_Edges!=other_Edges"<<endl;
00233                 
00234                 if( m_vi_RightVertices==other_RightVertices) cout<<" m_vi_RightVertices==other_RightVertices"<<endl;
00235                 else  cout<<"m_vi_RightVertices!=other_RightVertices"<<endl;
00236                 //*/
00237                 
00238                 if(m_vi_LeftVertices==other_LeftVertices && m_vi_Edges==other_Edges && m_vi_RightVertices==other_RightVertices ) return true;
00239                 else return false;
00240 
00241         }
00242 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines