1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
|
/************************************************************************************
Copyright (C) 2005-2008 Assefaw H. Gebremedhin, Arijit Tarafdar, Duc Nguyen,
Alex Pothen
This file is part of ColPack.
ColPack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ColPack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ColPack. If not, see <http://www.gnu.org/licenses/>.
************************************************************************************/
#include "ColPackHeaders.h"
using namespace std;
namespace ColPack
{
//Virtual Function 2102:3102
void BipartiteGraphCore::Clear()
{
m_i_MaximumLeftVertexDegree = _UNKNOWN;
m_i_MaximumRightVertexDegree = _UNKNOWN;
m_i_MaximumVertexDegree = _UNKNOWN;
m_i_MinimumLeftVertexDegree = _UNKNOWN;
m_i_MinimumRightVertexDegree = _UNKNOWN;
m_i_MinimumVertexDegree = _UNKNOWN;
m_d_AverageLeftVertexDegree = _UNKNOWN;
m_d_AverageRightVertexDegree = _UNKNOWN;
m_d_AverageVertexDegree = _UNKNOWN;
m_s_InputFile.clear();
m_vi_LeftVertices.clear();
m_vi_RightVertices.clear();
m_vi_Edges.clear();
m_mimi2_VertexEdgeMap.clear();
}
//Public Function 2103:3103
string BipartiteGraphCore::GetInputFile()
{
return(m_s_InputFile);
}
vector<int>* BipartiteGraphCore::GetLeftVerticesPtr()
{
return &m_vi_LeftVertices;
}
vector<int>* BipartiteGraphCore::GetRightVerticesPtr()
{
return &m_vi_RightVertices;
}
//Public Function 2104:3104
void BipartiteGraphCore::GetRowVertices(vector<int> &output) const
{
output = (m_vi_LeftVertices);
}
unsigned int BipartiteGraphCore::GetRowVertices(unsigned int** ip2_RowVertex)
{
(*ip2_RowVertex) = (unsigned int*) malloc(m_vi_LeftVertices.size() * sizeof(unsigned int));
for(unsigned int i=0; i < m_vi_LeftVertices.size(); i++) {
(*ip2_RowVertex)[i] = m_vi_LeftVertices[i];
}
return m_vi_LeftVertices.size();
}
unsigned int BipartiteGraphCore::GetColumnIndices(unsigned int** ip2_ColumnIndex)
{
unsigned int ui_UpperBound = m_vi_LeftVertices[m_vi_LeftVertices.size() - 1];
(*ip2_ColumnIndex) = (unsigned int*) malloc(ui_UpperBound * sizeof(unsigned int));
for(unsigned int i=0; i < ui_UpperBound; i++) {
(*ip2_ColumnIndex)[i] = m_vi_Edges[i];
}
return ui_UpperBound;
}
void BipartiteGraphCore::GetLeftVertices(vector<int> &output) const
{
output = (m_vi_LeftVertices);
}
//Public Function 2105:3105
void BipartiteGraphCore::GetColumnVertices(vector<int> &output) const
{
output = (m_vi_RightVertices);
}
void BipartiteGraphCore::GetRightVertices(vector<int> &output) const
{
output = (m_vi_RightVertices);
}
//Public Function 2106:3106
void BipartiteGraphCore::GetEdges(vector<int> &output) const
{
output = (m_vi_Edges);
}
//Public Function 2107:3107
void BipartiteGraphCore::GetVertexEdgeMap(map< int, map<int, int> > &output)
{
output = (m_mimi2_VertexEdgeMap);
}
//Public Function 2108:3108
int BipartiteGraphCore::GetRowVertexCount()
{
return(STEP_DOWN(m_vi_LeftVertices.size()));
}
int BipartiteGraphCore::GetLeftVertexCount()
{
return(STEP_DOWN(m_vi_LeftVertices.size()));
}
//Public Function 2109:3109
int BipartiteGraphCore::GetColumnVertexCount()
{
return(STEP_DOWN(m_vi_RightVertices.size()));
}
int BipartiteGraphCore::GetRightVertexCount()
{
return(STEP_DOWN(m_vi_RightVertices.size()));
}
//Public Function 2110:3110
int BipartiteGraphCore::GetEdgeCount()
{
return(m_vi_Edges.size()/2);
}
//Public Function 2111:3111
int BipartiteGraphCore::GetMaximumRowVertexDegree()
{
return(m_i_MaximumLeftVertexDegree);
}
//Public Function 2112:3112
int BipartiteGraphCore::GetMaximumColumnVertexDegree()
{
return(m_i_MaximumRightVertexDegree);
}
//Public Function 2113:3113
int BipartiteGraphCore::GetMaximumVertexDegree()
{
return(m_i_MaximumVertexDegree);
}
//Public Function 2114:3114
int BipartiteGraphCore::GetMinimumRowVertexDegree()
{
return(m_i_MinimumLeftVertexDegree);
}
//Public Function 2115:3115
int BipartiteGraphCore::GetMinimumColumnVertexDegree()
{
return(m_i_MinimumRightVertexDegree);
}
//Public Function 2116:3116
int BipartiteGraphCore::GetMinimumVertexDegree()
{
return(m_i_MinimumVertexDegree);
}
//Public Function 2117:3117
double BipartiteGraphCore::GetAverageRowVertexDegree()
{
return(m_d_AverageLeftVertexDegree);
}
//Public Function 2118:3118
double BipartiteGraphCore::GetAverageColumnVertexDegree()
{
return(m_d_AverageRightVertexDegree);
}
//Public Function 2119:3119
double BipartiteGraphCore::GetAverageVertexDegree()
{
return(m_d_AverageVertexDegree);
}
bool BipartiteGraphCore::operator==(const BipartiteGraphCore &other) const {
// Check for self-assignment!
if (this == &other) // Same object?
return true; // Yes, so the 2 objects are equal
//Compare vector<int> m_vi_LeftVertices; vector<int> m_vi_RightVertices; vector<int> m_vi_Edges;
vector<int> other_LeftVertices, other_RightVertices, other_Edges;
other.GetLeftVertices(other_LeftVertices);
other.GetRightVertices(other_RightVertices);
other.GetEdges(other_Edges);
/*
if(m_vi_LeftVertices==other_LeftVertices) cout<<"m_vi_LeftVertices==other_LeftVertices"<<endl;
else cout<<"m_vi_LeftVertices!=other_LeftVertices"<<endl;
if(m_vi_Edges==other_Edges) cout<<"m_vi_Edges==other_Edges"<<endl;
else cout<<"m_vi_Edges!=other_Edges"<<endl;
if( m_vi_RightVertices==other_RightVertices) cout<<" m_vi_RightVertices==other_RightVertices"<<endl;
else cout<<"m_vi_RightVertices!=other_RightVertices"<<endl;
//*/
if(m_vi_LeftVertices==other_LeftVertices && m_vi_Edges==other_Edges && m_vi_RightVertices==other_RightVertices ) return true;
else return false;
}
}
|