| 364 | |
| 365 | typedef ListDigraph Graph; |
| 366 | DIGRAPH_TYPEDEFS(Graph); |
| 367 | Graph gr; |
| 368 | |
| 369 | Node n0 = gr.addNode(); |
| 370 | Node n1 = gr.addNode(); |
| 371 | Node n2 = gr.addNode(); |
| 372 | Node n3 = gr.addNode(); |
| 373 | |
| 374 | gr.addArc(n3, n0); |
| 375 | gr.addArc(n3, n2); |
| 376 | gr.addArc(n0, n2); |
| 377 | gr.addArc(n2, n1); |
| 378 | gr.addArc(n0, n1); |
| 379 | |
| 380 | { |
| 381 | std::vector<Node> v; |
| 382 | dfs(gr).processedMap(loggerBoolMap(std::back_inserter(v))).run(); |
| 383 | |
| 384 | check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3, |
| 385 | "Something is wrong with LoggerBoolMap"); |
| 386 | } |
| 387 | { |
| 388 | std::vector<Node> v(countNodes(gr)); |
| 389 | dfs(gr).processedMap(loggerBoolMap(v.begin())).run(); |
| 390 | |
| 391 | check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3, |
| 392 | "Something is wrong with LoggerBoolMap"); |
| 393 | } |
| 468 | // SourceMap, TargetMap, ForwardMap, BackwardMap, InDegMap, OutDegMap |
| 469 | { |
| 470 | typedef ListGraph Graph; |
| 471 | GRAPH_TYPEDEFS(Graph); |
| 472 | |
| 473 | checkConcept<ReadMap<Arc, Node>, SourceMap<Graph> >(); |
| 474 | checkConcept<ReadMap<Arc, Node>, TargetMap<Graph> >(); |
| 475 | checkConcept<ReadMap<Edge, Arc>, ForwardMap<Graph> >(); |
| 476 | checkConcept<ReadMap<Edge, Arc>, BackwardMap<Graph> >(); |
| 477 | checkConcept<ReadMap<Node, int>, InDegMap<Graph> >(); |
| 478 | checkConcept<ReadMap<Node, int>, OutDegMap<Graph> >(); |
| 479 | |
| 480 | Graph gr; |
| 481 | Node n0 = gr.addNode(); |
| 482 | Node n1 = gr.addNode(); |
| 483 | Node n2 = gr.addNode(); |
| 484 | |
| 485 | gr.addEdge(n0,n1); |
| 486 | gr.addEdge(n1,n2); |
| 487 | gr.addEdge(n0,n2); |
| 488 | gr.addEdge(n2,n1); |
| 489 | gr.addEdge(n1,n2); |
| 490 | gr.addEdge(n0,n1); |
| 491 | |
| 492 | for (EdgeIt e(gr); e != INVALID; ++e) { |
| 493 | check(forwardMap(gr)[e] == gr.direct(e, true), "Wrong ForwardMap"); |
| 494 | check(backwardMap(gr)[e] == gr.direct(e, false), "Wrong BackwardMap"); |
| 495 | } |
| 496 | |
| 497 | compareMap(sourceMap(orienter(gr, constMap<Edge, bool>(true))), |
| 498 | targetMap(orienter(gr, constMap<Edge, bool>(false))), |
| 499 | EdgeIt(gr)); |
| 500 | |
| 501 | typedef Orienter<Graph, const ConstMap<Edge, bool> > Digraph; |
| 502 | Digraph dgr(gr, constMap<Edge, bool>(true)); |
| 503 | OutDegMap<Digraph> odm(dgr); |
| 504 | InDegMap<Digraph> idm(dgr); |
| 505 | |
| 506 | check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 1, "Wrong OutDegMap"); |
| 507 | check(idm[n0] == 0 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap"); |
| 508 | |
| 509 | gr.addEdge(n2, n0); |
| 510 | |
| 511 | check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 2, "Wrong OutDegMap"); |
| 512 | check(idm[n0] == 1 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap"); |
| 513 | } |
| 514 | |