00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "webnode.h"
00023 #include "linkgraph.h"
00024 #include <math.h>
00025
00026 WebLinkGraph :: WebLinkGraph(): WebNodeList() {
00027 for(int k =0; k < TAG_NUMBER_OF_BITS; k++) {
00028 fromsetsize[k] = 0;
00029 }
00030 }
00031
00032
00033 void WebLinkGraph :: PrintWebGraph(ostream& o) {
00034 o << "# node | date | num_dangling | num_fromlinks | num_tolinks | tolinks_list..." << endl;
00035 for(WebNodeList::iterator i = begin(); i != end(); i++ ) {
00036 o << (*i)->ID()
00037 << " " << (*i)->Date()
00038 << " " << (int)(*i)->NumberOfDanglingToLinks()
00039 << " " << (*i)->NumberOfValidFromLinks()
00040 << " " << (*i)->NumberOfValidToLinks();
00041 int n = (*i)->NumberOfValidToLinks();
00042 for(int k = 0; k < n; k++) {
00043 o << " " << (*i)->ValidToLink(k)->ID();
00044 }
00045 for(int k = 0; k < (*i)->NumberOfLeafLinks(); k++) {
00046 o << " " << (*i)->ValidLeafLink(k)->ID();
00047 }
00048 o << endl;
00049 }
00050 }
00051
00052
00053 void WebLinkGraph :: ClearTags() {
00054 for(WebNodeList::iterator i = begin(); i != end(); i++) {
00055 (*i)->ClearTag();
00056 }
00057 }
00058
00059
00060
00061 void WebLinkGraph :: BuildFromSets(int k) {
00062
00063 assert( k <= TAG_NUMBER_OF_BITS );
00064 assert( k >= 0 );
00065 for(int t = 0; t < (TAG_NUMBER_OF_BITS - 1); t++) {
00066 cerr << "info: tagging fromset # " << (t+1) << endl;
00067 for(WebNodeList::iterator i = begin(); i != end(); i++) {
00068 assert(*i);
00069 WebNodePtr w = (*i);
00070 assert(w);
00071 if( w->Tagged(t) ) {
00072 for(int j = 0; j < w->NumberOfValidFromLinks(); j++) {
00073 WebNodePtr v = w->ValidFromLink(j);
00074 assert(v);
00075
00076 v->SetTag(t+1);
00077 assert( v->Tagged(t+1) );
00078 }
00079 }
00080 }
00081 }
00082 }
00083
00084
00085
00086 void WebLinkGraph :: MeasureFromSets() {
00087
00088 for(int j = 0; j < TAG_NUMBER_OF_BITS; j++) {
00089 fromsetsize[j] = 0;
00090 }
00091
00092 for(WebNodeList::iterator i = begin(); i != end(); i++) {
00093 assert(*i);
00094 for(int j = 0; j < TAG_NUMBER_OF_BITS; j++) {
00095 if( (*i)->Tagged(j) ) {
00096 fromsetsize[j]++;
00097 }
00098 }
00099 }
00100 }
00101
00102
00103 void WebLinkGraph :: StatisticsFromSets(ostream& o) {
00104 o << "\nNumber of tagged webnodes: " << fromsetsize[0] << endl;
00105 if( fromsetsize[0] ) {
00106 for(int i = 1; i < TAG_NUMBER_OF_BITS; i++) {
00107 o << "Number of webnodes at distance " << i << " from tagged set: " << fromsetsize[i] << endl;
00108 }
00109 }
00110 }