File indexing completed on 2025-08-03 08:19:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <iostream>
0010
0011 #include <GTL/graph.h>
0012 #include <GTL/bellman_ford.h>
0013 #include <GTL/edge_map.h>
0014 #include <GTL/node_map.h>
0015
0016 #ifdef __GTL_MSVCC
0017 # ifdef _DEBUG
0018 # define new DEBUG_NEW
0019 # undef THIS_FILE
0020 static char THIS_FILE[] = __FILE__;
0021 # endif
0022 #endif
0023
0024 class my_graph : public graph {
0025
0026 public:
0027
0028 my_graph() : graph () {}
0029
0030 node new_vertex(int x) {node n=graph::new_node();X[n]=x; return n;}
0031 void new_parton(node s, node t, int p) {edge e=graph::new_edge(s,t) ;P[e]=p;}
0032
0033 void save_node_info_handler (ostream *o, node n) const { *o<<"Value = "<<X[n]<<endl;}
0034 void save_edge_info_handler (ostream *o, edge n) const { *o<<"Value = "<<P[n]<<endl;}
0035
0036 int GetNodeValue(node n) const {return X[n];}
0037 int GetEdgeValue(edge n) const {return P[n];}
0038
0039 private:
0040
0041 node_map<int> X;
0042 edge_map<int> P;
0043
0044 };
0045
0046
0047 class parton {
0048
0049 public:
0050
0051 parton() {};
0052 parton (double mpt, double meta, double mphi, double me, bool mfinal) {pt=mpt;eta=meta;phi=mphi;e=me;final=mfinal;}
0053
0054 bool isFinal() {return final;}
0055
0056 double pt, eta, phi, e;
0057 bool final;
0058 };
0059
0060 class shower : public graph {
0061
0062 public:
0063
0064 shower() : graph() {}
0065
0066 node new_vertex(int x) {node n=graph::new_node();XX[n]=x; return n;}
0067 void new_parton(node s, node t, parton p) {edge e=graph::new_edge(s,t) ;PP[e]=p;}
0068 int GetNodeValue(node n) const {return XX[n];}
0069 void save_edge_info_handler (ostream *o, edge n) const { *o<<"Value = "<<PP[n].pt<<endl;}
0070 double GetEdgeValue(edge n) const {return PP[n].pt;}
0071
0072 private:
0073
0074 node_map<int> XX;
0075 edge_map<parton> PP;
0076
0077 };
0078
0079 int main (int argc, char* argv[])
0080 {
0081 graph G;
0082 G.make_directed();
0083 node n1 = G.new_node();
0084 node n2 = G.new_node();
0085
0086 edge e1 = G.new_edge(n1,n2);
0087
0088
0089 node_map<int> n(G,1);
0090 edge_map<int> e(G,10);
0091
0092
0093
0094
0095
0096 my_graph S;
0097
0098 node n11=S.new_vertex(0);
0099 node n22=S.new_vertex(1);
0100 node n33=S.new_vertex(2);
0101 node n44=S.new_vertex(3);
0102 node n55=S.new_vertex(5);
0103
0104
0105 S.new_parton(n11,n22,10);
0106 S.new_parton(n11,n33,11);
0107 S.new_parton(n33,n44,20);
0108 S.new_parton(n33,n55,21);
0109
0110
0111
0112 graph::node_iterator it, end;
0113
0114 for (it = S.nodes_begin(), end = S.nodes_end(); it != end; ++it)
0115 {
0116 cout<<*it<<" "<<S.GetNodeValue((node) *it)<<endl;
0117 }
0118
0119 graph::edge_iterator it2, end2;
0120
0121 for (it2 = S.edges_begin(), end2 = S.edges_end(); it2 != end2; ++it2)
0122 {
0123 cout<<*it2<<" "<<S.GetEdgeValue((edge) *it2)<<endl;
0124 }
0125
0126 cout<<endl;
0127
0128 shower gS;
0129
0130 node nn11=gS.new_vertex(0);
0131 node nn22=gS.new_vertex(1);
0132 node nn33=gS.new_vertex(1);
0133 node nn44=gS.new_vertex(2);
0134 node nn55=gS.new_vertex(2);
0135
0136 parton p(100,0,0,100,false);
0137
0138 gS.new_parton(nn11,nn22,p);
0139 gS.new_parton(nn11,nn33,parton(200,0,0,200,false));
0140 gS.new_parton(nn33,nn44,parton(50,0,0,50,true));
0141 gS.new_parton(nn33,nn55,parton(150,0,0,150,true));
0142
0143 shower::node_iterator git, gend;
0144
0145 for (git = gS.nodes_begin(), gend = gS.nodes_end(); git != gend; ++git)
0146 {
0147 cout<<*git<<" "<<gS.GetNodeValue(*git)<<endl;
0148 }
0149
0150 shower::edge_iterator git2, gend2;
0151
0152 for (git2 = gS.edges_begin(), gend2 = gS.edges_end(); git2 != gend2; ++git2)
0153 {
0154 cout<<*git2<<" "<<gS.GetEdgeValue(*git2)<<endl;
0155 }
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264 }