Skip to content

Commit

Permalink
make sure N of graph is set to graph's size
Browse files Browse the repository at this point in the history
  • Loading branch information
adalisan committed Sep 5, 2017
1 parent be28a23 commit b4a97ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
9 changes: 1 addition & 8 deletions src/graphm/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ algorithm::algorithm(std::string fconfig)
bnosymm=false;
df_norm=0;
N=0;
cdesc_matrix='A';
cscore_matrix='A';
bverbose=false;
sverbfile=std::string("");

N=0;
df_norm=0.0;

}
algorithm::algorithm()
: rpc()
Expand All @@ -49,8 +44,6 @@ algorithm::algorithm()
bverbose=false;
sverbfile=std::string("");

N=0;
df_norm=0.0;
}

//common framework for graph matching algorithm
Expand Down Expand Up @@ -125,7 +118,7 @@ double algorithm::graph_dist(graph &g,graph &h,gsl_matrix* gm_P,char cscore_matr
bool print_debug = false;
if ((pdebug.ivalue != -1) && (pdebug.ivalue))
print_debug = true;
long N=g.getN();
N=g.getN();
gsl_matrix* gm_Ag=g.get_descmatrix(cscore_matrix);
gsl_matrix* gm_At=gsl_matrix_alloc(N,N);
gsl_matrix* gm_Ah=gsl_matrix_alloc(N,N);
Expand Down
1 change: 1 addition & 0 deletions src/graphm/algorithm_ca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
match_result algorithm_ca::match(graph &g, graph &h, gsl_matrix *gm_P_i, gsl_matrix *_gm_ldh, double dalpha_ldh)
{
double dhung_max = get_param_d("hungarian_max");
N=g.getN();
//bool bblast_match_end = (get_param_i("blast_match_proj") == 1);
bool bblast_match = (get_param_i("blast_match") == 1);
//double dfw_xeps = get_param_d("algo_fw_xeps");
Expand Down
6 changes: 3 additions & 3 deletions src/graphm/algorithm_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

match_result algorithm_NEW::match(graph& g, graph& h,gsl_matrix* gm_P_i,gsl_matrix* gm_ldh,double dalpha_ldh)
{
if (bverbose) *gout<<"The best matching algorithm"<<std::endl;
if (bverbose) *gout<<"The best matching algorithm"<<std::endl;
match_result mres; //class with results
gsl_matrix* gm_Ag_d=g.get_descmatrix(cdesc_matrix);//get the adjacency matrix of graph g
gsl_matrix* gm_Ah_d=h.get_descmatrix(cdesc_matrix);//get the adjacency matrix of graph h
//the similarity matrix C is defined in the algorithm class memeber gm_ldh
//dalpha_ldh is corresponding is corresponding to the linear combination coefficent alpha

N=g.getN();
gsl_matrix* P=gsl_matrix_alloc(N,N);
//YOUR OPERATIONS WITH MATRICES, RESULT IS A PERMUTATION MATRIX P

Expand All @@ -41,4 +41,4 @@ mres.gm_P_exact=NULL; //you can save here the matrix which was used as an approx

mres.dres=graph_dist(g,h,mres.gm_P,cscore_matrix);// distance between graph adjacency matrices
return mres;
}
}
7 changes: 7 additions & 0 deletions src/graphm/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ graph::graph(const gsl_matrix *_gm_A) : rpc("")
{
gm_A = NULL;
N = 0;
N=_gm_A->size1;
set_adjmatrix(_gm_A);


}

graph::graph(std::string fconfig)
Expand All @@ -46,14 +48,18 @@ graph::graph(graph &gr) : rpc()
gm_A = NULL;
N = 0;
const gsl_matrix *gm_t = gr.get_adjmatrix();
N=gm_t->size1;
set_adjmatrix(gm_t);

}

graph &graph::operator=(graph &gh)
{
if (&gh != this)
{
N=gh.get_adjmatrix()->size1;
set_adjmatrix(gh.get_adjmatrix());

}
return (*this);
}
Expand Down Expand Up @@ -87,6 +93,7 @@ int graph::load_graph(std::string fgraph_name, char ftype, char cformat, std::st
fclose(f);
gsl_set_error_handler(NULL);
set_adjmatrix(gm_A_l);
this->N = gm_A_l->size1;
gsl_matrix_free(gm_A_l);
};
if (ierror != 0)
Expand Down

0 comments on commit b4a97ba

Please sign in to comment.