alpar@1149: /* -*- mode: C++; indent-tabs-mode: nil; -*- alpar@1149: * alpar@1149: * This file is a part of LEMON, a generic C++ optimization library. alpar@1149: * alpar@1270: * Copyright (C) 2003-2013 alpar@1149: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1149: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@1149: * alpar@1149: * Permission to use, modify and distribute this software is granted alpar@1149: * provided that this copyright notice appears in all copies. For alpar@1149: * precise terms see the accompanying LICENSE file. alpar@1149: * alpar@1149: * This software is provided "AS IS" with no warranty of any kind, alpar@1149: * express or implied, and with no claim as to its suitability for any alpar@1149: * purpose. alpar@1149: * alpar@1149: */ alpar@1149: alpar@1149: #include alpar@1149: #include "lemon/list_graph.h" alpar@1149: #include "lemon/lgf_reader.h" alpar@1149: alpar@1149: #include "test_tools.h" alpar@1149: alpar@1149: using namespace lemon; alpar@1149: alpar@1149: const int lgfn = 4; alpar@1149: const std::string lgf = alpar@1149: "@nodes\n" alpar@1149: "label\n" alpar@1149: "0\n" alpar@1149: "1\n" alpar@1149: "2\n" alpar@1149: "3\n" alpar@1149: "4\n" alpar@1149: "5\n" alpar@1149: "6\n" alpar@1149: "@arcs\n" alpar@1149: "label\n" alpar@1149: "5 6 0\n" alpar@1149: "5 4 1\n" alpar@1149: "4 6 2\n" alpar@1149: "3 4 3\n" alpar@1149: "3 4 4\n" alpar@1149: "3 2 5\n" alpar@1149: "3 5 6\n" alpar@1149: "3 5 7\n" alpar@1149: "3 5 8\n" alpar@1149: "3 5 9\n" alpar@1149: "2 4 10\n" alpar@1149: "2 4 11\n" alpar@1149: "2 4 12\n" alpar@1149: "2 4 13\n" alpar@1149: "1 2 14\n" alpar@1149: "1 2 15\n" alpar@1149: "1 0 16\n" alpar@1149: "1 3 17\n" alpar@1149: "1 3 18\n" alpar@1149: "1 3 19\n" alpar@1149: "1 3 20\n" alpar@1149: "0 2 21\n" alpar@1149: "0 2 22\n" alpar@1149: "0 2 23\n" alpar@1149: "0 2 24\n"; alpar@1149: alpar@1149: alpar@1149: int main() { alpar@1149: ListDigraph graph; alpar@1149: std::istringstream lgfs(lgf); alpar@1149: DigraphReader(graph, lgfs).run(); alpar@1270: alpar@1149: AllArcLookUp lookup(graph); alpar@1270: alpar@1149: int numArcs = countArcs(graph); alpar@1270: alpar@1149: int arcCnt = 0; alpar@1149: for(ListDigraph::NodeIt n1(graph); n1 != INVALID; ++n1) alpar@1149: for(ListDigraph::NodeIt n2(graph); n2 != INVALID; ++n2) alpar@1149: for(ListDigraph::Arc a = lookup(n1, n2); a != INVALID; alpar@1270: a = lookup(n1, n2, a)) alpar@1270: ++arcCnt; alpar@1149: check(arcCnt==numArcs, "Wrong total number of arcs"); alpar@1149: alpar@1149: return 0; alpar@1149: }