test/graph_utils_test.cc
changeset 655 c706534d4740
parent 440 88ed40ad0d4f
equal deleted inserted replaced
5:b400eecb0e44 6:d6226279f6e0
    36   {
    36   {
    37     Digraph digraph;
    37     Digraph digraph;
    38     for (int i = 0; i < 10; ++i) {
    38     for (int i = 0; i < 10; ++i) {
    39       digraph.addNode();
    39       digraph.addNode();
    40     }
    40     }
    41     DescriptorMap<Digraph, Node> nodes(digraph);
    41     RangeIdMap<Digraph, Node> nodes(digraph);
    42     typename DescriptorMap<Digraph, Node>::InverseMap invNodes(nodes);
    42     typename RangeIdMap<Digraph, Node>::InverseMap invNodes(nodes);
    43     for (int i = 0; i < 100; ++i) {
    43     for (int i = 0; i < 100; ++i) {
    44       int src = rnd[invNodes.size()];
    44       int src = rnd[invNodes.size()];
    45       int trg = rnd[invNodes.size()];
    45       int trg = rnd[invNodes.size()];
    46       digraph.addArc(invNodes[src], invNodes[trg]);
    46       digraph.addArc(invNodes[src], invNodes[trg]);
    47     }
    47     }
    48     typename Digraph::template ArcMap<bool> found(digraph, false);
    48     typename Digraph::template ArcMap<bool> found(digraph, false);
    49     DescriptorMap<Digraph, Arc> arcs(digraph);
    49     RangeIdMap<Digraph, Arc> arcs(digraph);
    50     for (NodeIt src(digraph); src != INVALID; ++src) {
    50     for (NodeIt src(digraph); src != INVALID; ++src) {
    51       for (NodeIt trg(digraph); trg != INVALID; ++trg) {
    51       for (NodeIt trg(digraph); trg != INVALID; ++trg) {
    52         for (ConArcIt<Digraph> con(digraph, src, trg); con != INVALID; ++con) {
    52         for (ConArcIt<Digraph> con(digraph, src, trg); con != INVALID; ++con) {
    53           check(digraph.source(con) == src, "Wrong source.");
    53           check(digraph.source(con) == src, "Wrong source.");
    54           check(digraph.target(con) == trg, "Wrong target.");
    54           check(digraph.target(con) == trg, "Wrong target.");
   111   TEMPLATE_GRAPH_TYPEDEFS(Graph);
   111   TEMPLATE_GRAPH_TYPEDEFS(Graph);
   112   Graph graph;
   112   Graph graph;
   113   for (int i = 0; i < 10; ++i) {
   113   for (int i = 0; i < 10; ++i) {
   114     graph.addNode();
   114     graph.addNode();
   115   }
   115   }
   116   DescriptorMap<Graph, Node> nodes(graph);
   116   RangeIdMap<Graph, Node> nodes(graph);
   117   typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes);
   117   typename RangeIdMap<Graph, Node>::InverseMap invNodes(nodes);
   118   for (int i = 0; i < 100; ++i) {
   118   for (int i = 0; i < 100; ++i) {
   119     int src = rnd[invNodes.size()];
   119     int src = rnd[invNodes.size()];
   120     int trg = rnd[invNodes.size()];
   120     int trg = rnd[invNodes.size()];
   121     graph.addEdge(invNodes[src], invNodes[trg]);
   121     graph.addEdge(invNodes[src], invNodes[trg]);
   122   }
   122   }
   123   typename Graph::template EdgeMap<int> found(graph, 0);
   123   typename Graph::template EdgeMap<int> found(graph, 0);
   124   DescriptorMap<Graph, Edge> edges(graph);
   124   RangeIdMap<Graph, Edge> edges(graph);
   125   for (NodeIt src(graph); src != INVALID; ++src) {
   125   for (NodeIt src(graph); src != INVALID; ++src) {
   126     for (NodeIt trg(graph); trg != INVALID; ++trg) {
   126     for (NodeIt trg(graph); trg != INVALID; ++trg) {
   127       for (ConEdgeIt<Graph> con(graph, src, trg); con != INVALID; ++con) {
   127       for (ConEdgeIt<Graph> con(graph, src, trg); con != INVALID; ++con) {
   128         check( (graph.u(con) == src && graph.v(con) == trg) ||
   128         check( (graph.u(con) == src && graph.v(con) == trg) ||
   129                (graph.v(con) == src && graph.u(con) == trg),
   129                (graph.v(con) == src && graph.u(con) == trg),