00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <qptrstack.h>
00016 #include "buildpropositions.hpp"
00017 #include "../core/edgelist.hpp"
00018
00019 BuildPropositions::BuildPropositions(Principal * cl , PropositionGraph* G)
00020 {
00021 EdgeList::iterator ix = G->edges->begin();
00022 while ( ix != G->edges->end()) {
00023 (*ix) -> processBends();
00024 (*ix) -> show();
00025 ++ix;
00026 }
00027
00028 QDictIterator<Proposition> it ( *G );
00029 for( ; it.current(); ++it ) {
00030 it.current()->show();
00031 it.current()->setTrust((float)-1);
00032 }
00033
00034 G->operator[]("P1")->setTrust((float)1.0);
00035 calculeTrust(G->operator[]("P1"));
00036 }
00037
00038 BuildPropositions::calculeTrust(Proposition *p)
00039 {
00040 EdgeList::iterator ix = p->outgoing->begin();
00041 QPtrStack <Proposition> stack;
00042 while ( ix != p->outgoing->end()) {
00043 stack.push((Proposition*)(*ix)->target());
00044
00045 if ((p->trust() < 0) || ((*ix)->trust() < 0))
00046 (*ix)->setCombinedTrust((float)-1);
00047 else
00048 (*ix)->setCombinedTrust((float)p->trust() * (*ix)->trust());
00049 if ( (*ix)->combinedTrust() > stack.top()->trust() )
00050 stack.top()->setTrust((*ix)->combinedTrust());
00051 ix++;
00052 }
00053
00054 while (!stack.isEmpty())
00055 {
00056 calculeTrust(stack.top());
00057 stack.pop();
00058 }
00059
00060 }
00061
00062 BuildPropositions::~BuildPropositions()
00063 {
00064
00065 }