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 00060 //Public Function 2104:3104 00061 void BipartiteGraphCore::GetRowVertices(vector<int> &output) const 00062 { 00063 output = (m_vi_LeftVertices); 00064 } 00065 00066 unsigned int BipartiteGraphCore::GetRowVertices(unsigned int** ip2_RowVertex) 00067 { 00068 (*ip2_RowVertex) = new unsigned int[m_vi_LeftVertices.size()]; 00069 for(unsigned int i=0; i < m_vi_LeftVertices.size(); i++) { 00070 (*ip2_RowVertex)[i] = m_vi_LeftVertices[i]; 00071 } 00072 return m_vi_LeftVertices.size(); 00073 } 00074 00075 unsigned int BipartiteGraphCore::GetColumnIndices(unsigned int** ip2_ColumnIndex) 00076 { 00077 unsigned int ui_UpperBound = m_vi_LeftVertices[m_vi_LeftVertices.size() - 1]; 00078 (*ip2_ColumnIndex) = new unsigned int[ui_UpperBound]; 00079 for(unsigned int i=0; i < ui_UpperBound; i++) { 00080 (*ip2_ColumnIndex)[i] = m_vi_Edges[i]; 00081 } 00082 return ui_UpperBound; 00083 } 00084 00085 void BipartiteGraphCore::GetLeftVertices(vector<int> &output) const 00086 { 00087 output = (m_vi_LeftVertices); 00088 } 00089 00090 //Public Function 2105:3105 00091 void BipartiteGraphCore::GetColumnVertices(vector<int> &output) const 00092 { 00093 output = (m_vi_RightVertices); 00094 } 00095 00096 void BipartiteGraphCore::GetRightVertices(vector<int> &output) const 00097 { 00098 output = (m_vi_RightVertices); 00099 } 00100 00101 //Public Function 2106:3106 00102 void BipartiteGraphCore::GetEdges(vector<int> &output) const 00103 { 00104 output = (m_vi_Edges); 00105 } 00106 00107 //Public Function 2107:3107 00108 void BipartiteGraphCore::GetVertexEdgeMap(map< int, map<int, int> > &output) 00109 { 00110 output = (m_mimi2_VertexEdgeMap); 00111 } 00112 00113 00114 //Public Function 2108:3108 00115 int BipartiteGraphCore::GetRowVertexCount() 00116 { 00117 return(STEP_DOWN(m_vi_LeftVertices.size())); 00118 } 00119 00120 int BipartiteGraphCore::GetLeftVertexCount() 00121 { 00122 return(STEP_DOWN(m_vi_LeftVertices.size())); 00123 } 00124 00125 00126 //Public Function 2109:3109 00127 int BipartiteGraphCore::GetColumnVertexCount() 00128 { 00129 return(STEP_DOWN(m_vi_RightVertices.size())); 00130 } 00131 00132 int BipartiteGraphCore::GetRightVertexCount() 00133 { 00134 return(STEP_DOWN(m_vi_RightVertices.size())); 00135 } 00136 00137 00138 //Public Function 2110:3110 00139 int BipartiteGraphCore::GetEdgeCount() 00140 { 00141 return(m_vi_Edges.size()/2); 00142 } 00143 00144 00145 //Public Function 2111:3111 00146 int BipartiteGraphCore::GetMaximumRowVertexDegree() 00147 { 00148 return(m_i_MaximumLeftVertexDegree); 00149 } 00150 00151 00152 //Public Function 2112:3112 00153 int BipartiteGraphCore::GetMaximumColumnVertexDegree() 00154 { 00155 return(m_i_MaximumRightVertexDegree); 00156 } 00157 00158 00159 //Public Function 2113:3113 00160 int BipartiteGraphCore::GetMaximumVertexDegree() 00161 { 00162 return(m_i_MaximumVertexDegree); 00163 } 00164 00165 00166 //Public Function 2114:3114 00167 int BipartiteGraphCore::GetMinimumRowVertexDegree() 00168 { 00169 return(m_i_MinimumLeftVertexDegree); 00170 } 00171 00172 00173 //Public Function 2115:3115 00174 int BipartiteGraphCore::GetMinimumColumnVertexDegree() 00175 { 00176 return(m_i_MinimumRightVertexDegree); 00177 } 00178 00179 00180 //Public Function 2116:3116 00181 int BipartiteGraphCore::GetMinimumVertexDegree() 00182 { 00183 return(m_i_MinimumVertexDegree); 00184 } 00185 00186 00187 //Public Function 2117:3117 00188 double BipartiteGraphCore::GetAverageRowVertexDegree() 00189 { 00190 return(m_d_AverageLeftVertexDegree); 00191 } 00192 00193 //Public Function 2118:3118 00194 double BipartiteGraphCore::GetAverageColumnVertexDegree() 00195 { 00196 return(m_d_AverageRightVertexDegree); 00197 } 00198 00199 //Public Function 2119:3119 00200 double BipartiteGraphCore::GetAverageVertexDegree() 00201 { 00202 return(m_d_AverageVertexDegree); 00203 } 00204 00205 bool BipartiteGraphCore::operator==(const BipartiteGraphCore &other) const { 00206 // Check for self-assignment! 00207 if (this == &other) // Same object? 00208 return true; // Yes, so the 2 objects are equal 00209 00210 //Compare vector<int> m_vi_LeftVertices; vector<int> m_vi_RightVertices; vector<int> m_vi_Edges; 00211 vector<int> other_LeftVertices, other_RightVertices, other_Edges; 00212 00213 other.GetLeftVertices(other_LeftVertices); 00214 other.GetRightVertices(other_RightVertices); 00215 other.GetEdges(other_Edges); 00216 00217 /* 00218 if(m_vi_LeftVertices==other_LeftVertices) cout<<"m_vi_LeftVertices==other_LeftVertices"<<endl; 00219 else cout<<"m_vi_LeftVertices!=other_LeftVertices"<<endl; 00220 00221 if(m_vi_Edges==other_Edges) cout<<"m_vi_Edges==other_Edges"<<endl; 00222 else cout<<"m_vi_Edges!=other_Edges"<<endl; 00223 00224 if( m_vi_RightVertices==other_RightVertices) cout<<" m_vi_RightVertices==other_RightVertices"<<endl; 00225 else cout<<"m_vi_RightVertices!=other_RightVertices"<<endl; 00226 //*/ 00227 00228 if(m_vi_LeftVertices==other_LeftVertices && m_vi_Edges==other_Edges && m_vi_RightVertices==other_RightVertices ) return true; 00229 else return false; 00230 00231 } 00232 }