For example:
Code : Tout sélectionner
G:=random_graph(1000,500000);
H:=isomorphic_copy(G);
is_isomorphic(G,H)
Modérateur : xcasadmin
Code : Tout sélectionner
G:=random_graph(1000,500000);
H:=isomorphic_copy(G);
is_isomorphic(G,H)
Actually, there indeed is a problem. I forgot that the conversion process on large graphs (an overhead) lasts couple of seconds. Therefore, in the above example with G=random_graph(1000,500000) I tried to interrupt the computation a bit before the finish time, when nauty is working. Interruption did not work (command has finished and returned the result) but trying to run another command Xcas just gave the info "Aborted" and then my *entire* system crashed. I managed to reproduce this couple of times in a row. Seems like a serious issue (probably has something to do with memory management in nauty) which has to be fixed before the stable release.frederic han a écrit : ↑dim. sept. 23, 2018 7:51 pmAre you able to interrupt a long computation in nauty?
Code : Tout sélectionner
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,NULL)
Code : Tout sélectionner
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,NULL);
Code : Tout sélectionner
gen randdiscrete(const vecteur &m, GIAC_CONTEXT);
extern const unary_function_ptr * const at_discreted ;
Code : Tout sélectionner
gen randdiscrete(const vecteur &m,GIAC_CONTEXT) {
int n;
if (m.empty() || !m.front().is_integer() || (n=m.front().val)<1)
return gensizeerr(contextptr);
double ran1=giac_rand(contextptr)/(rand_max2+1.0);
double ran2=giac_rand(contextptr)/(rand_max2+1.0);
int i=std::floor(n*ran1);
int index=is_strictly_greater(m[i+1],ran2,contextptr)?i:m[n+i+1].val;
if (int(m.size()-1)==3*n)
return m[2*n+index+1];
return index+array_start(contextptr);
}
gen _discreted(const gen &g,GIAC_CONTEXT) {
if (g.type==_STRNG && g.subtype==-1) return g;
return symbolic(at_discreted,g);
}
static const char _discreted_s []="discreted";
static define_unary_function_eval (__discreted,&_discreted,_discreted_s);
define_unary_function_ptr5( at_discreted,alias_at_discreted,&__discreted,0,true);
Code : Tout sélectionner
static int randvar_count=0;
void find_randvars(gen &g,gen_map &rv,GIAC_CONTEXT) {
stringstream ss;
if (g.type==_IDNT) {
if (rv.find(g)!=rv.end())
g=rv[g];
else {
ss << " var" << randvar_count;
identificateur v(ss.str().c_str());
rv[g]=v;
g=v;
++randvar_count;
}
} else if (g.is_symb_of_sommet(at_discreted) || is_distribution(g)>0) {
ss << " tmp" << randvar_count;
identificateur t(ss.str().c_str());
ss.str("");
ss << " var" << randvar_count;
identificateur v(ss.str().c_str());
_eval(symbolic(at_sto,makesequence(g,t)),contextptr);
rv[t]=v;
g=v;
++randvar_count;
} else if (g.type==_SYMB) {
gen &f=g._SYMBptr->feuille;
if (f.type==_VECT) {
for (iterateur it=f._VECTptr->begin();it!=f._VECTptr->end();++it) {
find_randvars(*it,rv,contextptr);
}
} else find_randvars(f,rv,contextptr);
}
}
Code : Tout sélectionner
if (f.is_symb_of_sommet(at_discreted)) {
const vecteur &args=*f._SYMBptr->feuille._VECTptr;
for (int i=0;i<n;++i) {
res.push_back(randdiscrete(args,contextptr));
}
return;
}
if (f.type==_SYMB) {
gen_map rv;
gen e(f);
randvar_count=0;
find_randvars(e,rv,contextptr);
if (!rv.empty()) {
int nv=rv.size();
vecteur vars;
matrice R;
vars.reserve(nv);
R.reserve(nv);
for (gen_map::const_iterator it=rv.begin();it!=rv.end();++it) {
vars.push_back(it->second);
R.push_back(vranm(n,_eval(it->first,contextptr),contextptr));
}
R=mtran(R);
for (const_iterateur it=R.begin();it!=R.end();++it) {
res.push_back(_subs(makesequence(e,vars,*it),contextptr));
}
return;
}
}
Code : Tout sélectionner
if (args.is_symb_of_sommet(at_discreted))
return vranm(1,args,contextptr)[0];
if (args.type==_VECT && args._VECTptr->front()==at_multinomial) {
vecteur v=*args._VECTptr;
v.insert(v.begin(),1);
return _randvector(v,contextptr)._VECTptr->at(0);
}
Code : Tout sélectionner
gen _sample(const gen & args,GIAC_CONTEXT){
if (args.is_symb_of_sommet(at_discreted) || is_distribution(args)>0)
return _rand(args,contextptr);
if (args.type!=_VECT || args._VECTptr->size()<2)
return gensizeerr(contextptr);
vecteur &argv=*args._VECTptr;
gen a=argv.front(),b=argv.back();
if (a==at_multinomial) {
if (argv.size()==3) {
vecteur v=argv;
v.insert(v.begin(),1);
return _randvector(v,contextptr)._VECTptr->at(0);
} if (argv.size()==4 && b.is_integer()) {
return _randvector(makesequence(b,at_multinomial,argv[1],argv[2]),contextptr);
}
return gensizeerr(contextptr);
}
if (args._VECTptr->size()!=2 || !is_integral(b) || b.type==_ZINT || b.val<0)
return gensizeerr(contextptr);
if (a.is_symb_of_sommet(at_discreted) || is_distribution(a)>0)
return _randvector(makesequence(b,a),contextptr);
if (a.type!=_VECT)
return gensizeerr(contextptr);
return _rand(makesequence(b,a),contextptr);
}
I mean discarding sample data which does not fall into the range before binning, i.e. to bin only the samples s which are between a and b.What do you mean by visualized with histogram only on a certain range?