deba@1030: /* -*- mode: C++; indent-tabs-mode: nil; -*- deba@1030: * deba@1030: * This file is a part of LEMON, a generic C++ optimization library. deba@1030: * deba@1030: * Copyright (C) 2003-2010 deba@1030: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport deba@1030: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@1030: * deba@1030: * Permission to use, modify and distribute this software is granted deba@1030: * provided that this copyright notice appears in all copies. For deba@1030: * precise terms see the accompanying LICENSE file. deba@1030: * deba@1030: * This software is provided "AS IS" with no warranty of any kind, deba@1030: * express or implied, and with no claim as to its suitability for any deba@1030: * purpose. deba@1030: * deba@1030: */ deba@1030: deba@1030: #include deba@1030: deba@1030: #include deba@1030: #include deba@1030: #include deba@1030: deba@1030: #include deba@1030: #include deba@1030: #include deba@1030: deba@1030: #include "test_tools.h" deba@1030: deba@1030: struct ReaderConverter { deba@1030: int operator()(const std::string& str) const { deba@1030: return str.length(); deba@1030: } deba@1030: }; deba@1030: deba@1030: struct WriterConverter { deba@1030: std::string operator()(int value) const { deba@1030: return std::string(value, '*'); deba@1030: } deba@1030: }; deba@1030: deba@1030: void checkDigraphReaderCompile() { deba@1030: typedef lemon::concepts::ExtendableDigraphComponent< deba@1030: lemon::concepts::Digraph> Digraph; deba@1030: Digraph digraph; deba@1030: Digraph::NodeMap node_map(digraph); deba@1030: Digraph::ArcMap arc_map(digraph); deba@1030: Digraph::Node node; deba@1030: Digraph::Arc arc; deba@1030: int attr; deba@1030: deba@1030: lemon::DigraphReader reader(digraph, "filename"); deba@1030: reader.nodeMap("node_map", node_map); deba@1030: reader.nodeMap("node_map", node_map, ReaderConverter()); deba@1030: reader.arcMap("arc_map", arc_map); deba@1030: reader.arcMap("arc_map", arc_map, ReaderConverter()); deba@1030: reader.attribute("attr", attr); deba@1030: reader.attribute("attr", attr, ReaderConverter()); deba@1030: reader.node("node", node); deba@1030: reader.arc("arc", arc); deba@1030: deba@1030: reader.nodes("alt_nodes_caption"); deba@1030: reader.arcs("alt_arcs_caption"); deba@1030: reader.attributes("alt_attrs_caption"); deba@1030: deba@1030: reader.useNodes(node_map); deba@1030: reader.useNodes(node_map, WriterConverter()); deba@1030: reader.useArcs(arc_map); deba@1030: reader.useArcs(arc_map, WriterConverter()); deba@1030: deba@1030: reader.skipNodes(); deba@1030: reader.skipArcs(); deba@1030: deba@1030: reader.run(); deba@1030: deba@1030: lemon::DigraphReader reader2(digraph, std::cin); deba@1030: } deba@1030: deba@1030: void checkDigraphWriterCompile() { deba@1030: typedef lemon::concepts::Digraph Digraph; deba@1030: Digraph digraph; deba@1030: Digraph::NodeMap node_map(digraph); deba@1030: Digraph::ArcMap arc_map(digraph); deba@1030: Digraph::Node node; deba@1030: Digraph::Arc arc; deba@1030: int attr; deba@1030: deba@1030: lemon::DigraphWriter writer(digraph, "filename"); deba@1030: writer.nodeMap("node_map", node_map); deba@1030: writer.nodeMap("node_map", node_map, WriterConverter()); deba@1030: writer.arcMap("arc_map", arc_map); deba@1030: writer.arcMap("arc_map", arc_map, WriterConverter()); deba@1030: writer.attribute("attr", attr); deba@1030: writer.attribute("attr", attr, WriterConverter()); deba@1030: writer.node("node", node); deba@1030: writer.arc("arc", arc); deba@1030: deba@1030: writer.nodes("alt_nodes_caption"); deba@1030: writer.arcs("alt_arcs_caption"); deba@1030: writer.attributes("alt_attrs_caption"); deba@1030: deba@1030: writer.skipNodes(); deba@1030: writer.skipArcs(); deba@1030: deba@1030: writer.run(); deba@1030: } deba@1030: deba@1030: void checkGraphReaderCompile() { deba@1030: typedef lemon::concepts::ExtendableGraphComponent< deba@1030: lemon::concepts::Graph> Graph; deba@1030: Graph graph; deba@1030: Graph::NodeMap node_map(graph); deba@1030: Graph::ArcMap arc_map(graph); deba@1030: Graph::EdgeMap edge_map(graph); deba@1030: Graph::Node node; deba@1030: Graph::Arc arc; deba@1030: Graph::Edge edge; deba@1030: int attr; deba@1030: deba@1030: lemon::GraphReader reader(graph, "filename"); deba@1030: reader.nodeMap("node_map", node_map); deba@1030: reader.nodeMap("node_map", node_map, ReaderConverter()); deba@1030: reader.arcMap("arc_map", arc_map); deba@1030: reader.arcMap("arc_map", arc_map, ReaderConverter()); deba@1030: reader.edgeMap("edge_map", edge_map); deba@1030: reader.edgeMap("edge_map", edge_map, ReaderConverter()); deba@1030: reader.attribute("attr", attr); deba@1030: reader.attribute("attr", attr, ReaderConverter()); deba@1030: reader.node("node", node); deba@1030: reader.arc("arc", arc); deba@1030: deba@1030: reader.nodes("alt_nodes_caption"); deba@1030: reader.edges("alt_edges_caption"); deba@1030: reader.attributes("alt_attrs_caption"); deba@1030: deba@1030: reader.useNodes(node_map); deba@1030: reader.useNodes(node_map, WriterConverter()); deba@1030: reader.useEdges(edge_map); deba@1030: reader.useEdges(edge_map, WriterConverter()); deba@1030: deba@1030: reader.skipNodes(); deba@1030: reader.skipEdges(); deba@1030: deba@1030: reader.run(); deba@1030: deba@1030: lemon::GraphReader reader2(graph, std::cin); deba@1030: } deba@1030: deba@1030: void checkGraphWriterCompile() { deba@1030: typedef lemon::concepts::Graph Graph; deba@1030: Graph graph; deba@1030: Graph::NodeMap node_map(graph); deba@1030: Graph::ArcMap arc_map(graph); deba@1030: Graph::EdgeMap edge_map(graph); deba@1030: Graph::Node node; deba@1030: Graph::Arc arc; deba@1030: Graph::Edge edge; deba@1030: int attr; deba@1030: deba@1030: lemon::GraphWriter writer(graph, "filename"); deba@1030: writer.nodeMap("node_map", node_map); deba@1030: writer.nodeMap("node_map", node_map, WriterConverter()); deba@1030: writer.arcMap("arc_map", arc_map); deba@1030: writer.arcMap("arc_map", arc_map, WriterConverter()); deba@1030: writer.edgeMap("edge_map", edge_map); deba@1030: writer.edgeMap("edge_map", edge_map, WriterConverter()); deba@1030: writer.attribute("attr", attr); deba@1030: writer.attribute("attr", attr, WriterConverter()); deba@1030: writer.node("node", node); deba@1030: writer.arc("arc", arc); deba@1030: writer.edge("edge", edge); deba@1030: deba@1030: writer.nodes("alt_nodes_caption"); deba@1030: writer.edges("alt_edges_caption"); deba@1030: writer.attributes("alt_attrs_caption"); deba@1030: deba@1030: writer.skipNodes(); deba@1030: writer.skipEdges(); deba@1030: deba@1030: writer.run(); deba@1030: deba@1030: lemon::GraphWriter writer2(graph, std::cout); deba@1030: } deba@1030: deba@1030: void checkBpGraphReaderCompile() { deba@1030: typedef lemon::concepts::ExtendableBpGraphComponent< deba@1030: lemon::concepts::BpGraph> BpGraph; deba@1030: BpGraph graph; deba@1030: BpGraph::NodeMap node_map(graph); deba@1030: BpGraph::RedNodeMap red_node_map(graph); deba@1030: BpGraph::BlueNodeMap blue_node_map(graph); deba@1030: BpGraph::ArcMap arc_map(graph); deba@1030: BpGraph::EdgeMap edge_map(graph); deba@1030: BpGraph::Node node; deba@1030: BpGraph::RedNode red_node; deba@1030: BpGraph::BlueNode blue_node; deba@1030: BpGraph::Arc arc; deba@1030: BpGraph::Edge edge; deba@1030: int attr; deba@1030: deba@1030: lemon::BpGraphReader reader(graph, "filename"); deba@1030: reader.nodeMap("node_map", node_map); deba@1030: reader.nodeMap("node_map", node_map, ReaderConverter()); deba@1030: reader.redNodeMap("red_node_map", red_node_map); deba@1030: reader.redNodeMap("red_node_map", red_node_map, ReaderConverter()); deba@1030: reader.blueNodeMap("blue_node_map", blue_node_map); deba@1030: reader.blueNodeMap("blue_node_map", blue_node_map, ReaderConverter()); deba@1030: reader.arcMap("arc_map", arc_map); deba@1030: reader.arcMap("arc_map", arc_map, ReaderConverter()); deba@1030: reader.edgeMap("edge_map", edge_map); deba@1030: reader.edgeMap("edge_map", edge_map, ReaderConverter()); deba@1030: reader.attribute("attr", attr); deba@1030: reader.attribute("attr", attr, ReaderConverter()); deba@1030: reader.node("node", node); deba@1030: reader.redNode("red_node", red_node); deba@1030: reader.blueNode("blue_node", blue_node); deba@1030: reader.arc("arc", arc); deba@1030: deba@1030: reader.nodes("alt_nodes_caption"); deba@1030: reader.edges("alt_edges_caption"); deba@1030: reader.attributes("alt_attrs_caption"); deba@1030: deba@1030: reader.useNodes(node_map); deba@1030: reader.useNodes(node_map, WriterConverter()); deba@1030: reader.useEdges(edge_map); deba@1030: reader.useEdges(edge_map, WriterConverter()); deba@1030: deba@1030: reader.skipNodes(); deba@1030: reader.skipEdges(); deba@1030: deba@1030: reader.run(); deba@1030: deba@1030: lemon::BpGraphReader reader2(graph, std::cin); deba@1030: } deba@1030: deba@1030: void checkBpGraphWriterCompile() { deba@1030: typedef lemon::concepts::BpGraph BpGraph; deba@1030: BpGraph graph; deba@1030: BpGraph::NodeMap node_map(graph); deba@1030: BpGraph::RedNodeMap red_node_map(graph); deba@1030: BpGraph::BlueNodeMap blue_node_map(graph); deba@1030: BpGraph::ArcMap arc_map(graph); deba@1030: BpGraph::EdgeMap edge_map(graph); deba@1030: BpGraph::Node node; deba@1030: BpGraph::RedNode red_node; deba@1030: BpGraph::BlueNode blue_node; deba@1030: BpGraph::Arc arc; deba@1030: BpGraph::Edge edge; deba@1030: int attr; deba@1030: deba@1030: lemon::BpGraphWriter writer(graph, "filename"); deba@1030: writer.nodeMap("node_map", node_map); deba@1030: writer.nodeMap("node_map", node_map, WriterConverter()); deba@1030: writer.redNodeMap("red_node_map", red_node_map); deba@1030: writer.redNodeMap("red_node_map", red_node_map, WriterConverter()); deba@1030: writer.blueNodeMap("blue_node_map", blue_node_map); deba@1030: writer.blueNodeMap("blue_node_map", blue_node_map, WriterConverter()); deba@1030: writer.arcMap("arc_map", arc_map); deba@1030: writer.arcMap("arc_map", arc_map, WriterConverter()); deba@1030: writer.edgeMap("edge_map", edge_map); deba@1030: writer.edgeMap("edge_map", edge_map, WriterConverter()); deba@1030: writer.attribute("attr", attr); deba@1030: writer.attribute("attr", attr, WriterConverter()); deba@1030: writer.node("node", node); deba@1030: writer.redNode("red_node", red_node); deba@1030: writer.blueNode("blue_node", blue_node); deba@1030: writer.arc("arc", arc); deba@1030: deba@1030: writer.nodes("alt_nodes_caption"); deba@1030: writer.edges("alt_edges_caption"); deba@1030: writer.attributes("alt_attrs_caption"); deba@1030: deba@1030: writer.skipNodes(); deba@1030: writer.skipEdges(); deba@1030: deba@1030: writer.run(); deba@1030: deba@1030: lemon::BpGraphWriter writer2(graph, std::cout); deba@1030: } deba@1030: deba@1030: void checkDigraphReaderWriter() { deba@1030: typedef lemon::SmartDigraph Digraph; deba@1030: Digraph digraph; deba@1030: Digraph::Node n1 = digraph.addNode(); deba@1030: Digraph::Node n2 = digraph.addNode(); deba@1030: Digraph::Node n3 = digraph.addNode(); deba@1030: deba@1030: Digraph::Arc a1 = digraph.addArc(n1, n2); deba@1030: Digraph::Arc a2 = digraph.addArc(n2, n3); deba@1030: deba@1030: Digraph::NodeMap node_map(digraph); deba@1030: node_map[n1] = 11; deba@1030: node_map[n2] = 12; deba@1030: node_map[n3] = 13; deba@1030: deba@1030: Digraph::ArcMap arc_map(digraph); deba@1030: arc_map[a1] = 21; deba@1030: arc_map[a2] = 22; deba@1030: deba@1030: int attr = 100; deba@1030: deba@1030: std::ostringstream os; deba@1030: lemon::DigraphWriter writer(digraph, os); deba@1030: deba@1030: writer.nodeMap("node_map1", node_map); deba@1030: writer.nodeMap("node_map2", node_map, WriterConverter()); deba@1030: writer.arcMap("arc_map1", arc_map); deba@1030: writer.arcMap("arc_map2", arc_map, WriterConverter()); deba@1030: writer.node("node", n2); deba@1030: writer.arc("arc", a1); deba@1030: writer.attribute("attr1", attr); deba@1030: writer.attribute("attr2", attr, WriterConverter()); deba@1030: deba@1030: writer.run(); deba@1030: deba@1030: typedef lemon::ListDigraph ExpDigraph; deba@1030: ExpDigraph exp_digraph; deba@1030: ExpDigraph::NodeMap exp_node_map1(exp_digraph); deba@1030: ExpDigraph::NodeMap exp_node_map2(exp_digraph); deba@1030: ExpDigraph::ArcMap exp_arc_map1(exp_digraph); deba@1030: ExpDigraph::ArcMap exp_arc_map2(exp_digraph); deba@1030: ExpDigraph::Node exp_n2; deba@1030: ExpDigraph::Arc exp_a1; deba@1030: int exp_attr1; deba@1030: int exp_attr2; deba@1030: deba@1030: std::istringstream is(os.str()); deba@1030: lemon::DigraphReader reader(exp_digraph, is); deba@1030: deba@1030: reader.nodeMap("node_map1", exp_node_map1); deba@1030: reader.nodeMap("node_map2", exp_node_map2, ReaderConverter()); deba@1030: reader.arcMap("arc_map1", exp_arc_map1); deba@1030: reader.arcMap("arc_map2", exp_arc_map2, ReaderConverter()); deba@1030: reader.node("node", exp_n2); deba@1030: reader.arc("arc", exp_a1); deba@1030: reader.attribute("attr1", exp_attr1); deba@1030: reader.attribute("attr2", exp_attr2, ReaderConverter()); deba@1030: deba@1030: reader.run(); deba@1030: deba@1030: check(lemon::countNodes(exp_digraph) == 3, "Wrong number of nodes"); deba@1030: check(lemon::countArcs(exp_digraph) == 2, "Wrong number of arcs"); deba@1030: check(exp_node_map1[exp_n2] == 12, "Wrong map value"); deba@1030: check(exp_node_map2[exp_n2] == 12, "Wrong map value"); deba@1030: check(exp_arc_map1[exp_a1] == 21, "Wrong map value"); deba@1030: check(exp_arc_map2[exp_a1] == 21, "Wrong map value"); deba@1030: check(exp_attr1 == 100, "Wrong attr value"); deba@1030: check(exp_attr2 == 100, "Wrong attr value"); deba@1030: } deba@1030: deba@1030: void checkGraphReaderWriter() { deba@1030: typedef lemon::SmartGraph Graph; deba@1030: Graph graph; deba@1030: Graph::Node n1 = graph.addNode(); deba@1030: Graph::Node n2 = graph.addNode(); deba@1030: Graph::Node n3 = graph.addNode(); deba@1030: deba@1030: Graph::Edge e1 = graph.addEdge(n1, n2); deba@1030: Graph::Edge e2 = graph.addEdge(n2, n3); deba@1030: deba@1030: Graph::NodeMap node_map(graph); deba@1030: node_map[n1] = 11; deba@1030: node_map[n2] = 12; deba@1030: node_map[n3] = 13; deba@1030: deba@1030: Graph::EdgeMap edge_map(graph); deba@1030: edge_map[e1] = 21; deba@1030: edge_map[e2] = 22; deba@1030: deba@1030: Graph::ArcMap arc_map(graph); deba@1030: arc_map[graph.direct(e1, true)] = 211; deba@1030: arc_map[graph.direct(e1, false)] = 212; deba@1030: arc_map[graph.direct(e2, true)] = 221; deba@1030: arc_map[graph.direct(e2, false)] = 222; deba@1030: deba@1030: int attr = 100; deba@1030: deba@1030: std::ostringstream os; deba@1030: lemon::GraphWriter writer(graph, os); deba@1030: deba@1030: writer.nodeMap("node_map1", node_map); deba@1030: writer.nodeMap("node_map2", node_map, WriterConverter()); deba@1030: writer.edgeMap("edge_map1", edge_map); deba@1030: writer.edgeMap("edge_map2", edge_map, WriterConverter()); deba@1030: writer.arcMap("arc_map1", arc_map); deba@1030: writer.arcMap("arc_map2", arc_map, WriterConverter()); deba@1030: writer.node("node", n2); deba@1030: writer.edge("edge", e1); deba@1030: writer.arc("arc", graph.direct(e1, false)); deba@1030: writer.attribute("attr1", attr); deba@1030: writer.attribute("attr2", attr, WriterConverter()); deba@1030: deba@1030: writer.run(); deba@1030: deba@1030: typedef lemon::ListGraph ExpGraph; deba@1030: ExpGraph exp_graph; deba@1030: ExpGraph::NodeMap exp_node_map1(exp_graph); deba@1030: ExpGraph::NodeMap exp_node_map2(exp_graph); deba@1030: ExpGraph::EdgeMap exp_edge_map1(exp_graph); deba@1030: ExpGraph::EdgeMap exp_edge_map2(exp_graph); deba@1030: ExpGraph::ArcMap exp_arc_map1(exp_graph); deba@1030: ExpGraph::ArcMap exp_arc_map2(exp_graph); deba@1030: ExpGraph::Node exp_n2; deba@1030: ExpGraph::Edge exp_e1; deba@1030: ExpGraph::Arc exp_a1; deba@1030: int exp_attr1; deba@1030: int exp_attr2; deba@1030: deba@1030: std::istringstream is(os.str()); deba@1030: lemon::GraphReader reader(exp_graph, is); deba@1030: deba@1030: reader.nodeMap("node_map1", exp_node_map1); deba@1030: reader.nodeMap("node_map2", exp_node_map2, ReaderConverter()); deba@1030: reader.edgeMap("edge_map1", exp_edge_map1); deba@1030: reader.edgeMap("edge_map2", exp_edge_map2, ReaderConverter()); deba@1030: reader.arcMap("arc_map1", exp_arc_map1); deba@1030: reader.arcMap("arc_map2", exp_arc_map2, ReaderConverter()); deba@1030: reader.node("node", exp_n2); deba@1030: reader.edge("edge", exp_e1); deba@1030: reader.arc("arc", exp_a1); deba@1030: reader.attribute("attr1", exp_attr1); deba@1030: reader.attribute("attr2", exp_attr2, ReaderConverter()); deba@1030: deba@1030: reader.run(); deba@1030: deba@1030: check(lemon::countNodes(exp_graph) == 3, "Wrong number of nodes"); deba@1030: check(lemon::countEdges(exp_graph) == 2, "Wrong number of edges"); deba@1030: check(lemon::countArcs(exp_graph) == 4, "Wrong number of arcs"); deba@1030: check(exp_node_map1[exp_n2] == 12, "Wrong map value"); deba@1030: check(exp_node_map2[exp_n2] == 12, "Wrong map value"); deba@1030: check(exp_edge_map1[exp_e1] == 21, "Wrong map value"); deba@1030: check(exp_edge_map2[exp_e1] == 21, "Wrong map value"); deba@1030: check(exp_arc_map1[exp_a1] == 212, "Wrong map value"); deba@1030: check(exp_arc_map2[exp_a1] == 212, "Wrong map value"); deba@1030: check(exp_attr1 == 100, "Wrong attr value"); deba@1030: check(exp_attr2 == 100, "Wrong attr value"); deba@1030: } deba@1030: deba@1030: void checkBpGraphReaderWriter() { deba@1030: typedef lemon::SmartBpGraph Graph; deba@1030: Graph graph; deba@1030: Graph::RedNode rn1 = graph.addRedNode(); deba@1030: Graph::RedNode rn2 = graph.addRedNode(); deba@1030: Graph::RedNode rn3 = graph.addRedNode(); deba@1030: Graph::BlueNode bn1 = graph.addBlueNode(); deba@1030: Graph::BlueNode bn2 = graph.addBlueNode(); deba@1030: Graph::Node n = bn1; deba@1030: deba@1030: Graph::Edge e1 = graph.addEdge(rn1, bn1); deba@1030: Graph::Edge e2 = graph.addEdge(rn2, bn1); deba@1030: deba@1030: Graph::NodeMap node_map(graph); deba@1030: node_map[rn1] = 11; deba@1030: node_map[rn2] = 12; deba@1030: node_map[rn3] = 13; deba@1030: node_map[bn1] = 14; deba@1030: node_map[bn2] = 15; deba@1030: deba@1030: Graph::NodeMap red_node_map(graph); deba@1030: red_node_map[rn1] = 411; deba@1030: red_node_map[rn2] = 412; deba@1030: red_node_map[rn3] = 413; deba@1030: deba@1030: Graph::NodeMap blue_node_map(graph); deba@1030: blue_node_map[bn1] = 414; deba@1030: blue_node_map[bn2] = 415; deba@1030: deba@1030: Graph::EdgeMap edge_map(graph); deba@1030: edge_map[e1] = 21; deba@1030: edge_map[e2] = 22; deba@1030: deba@1030: Graph::ArcMap arc_map(graph); deba@1030: arc_map[graph.direct(e1, true)] = 211; deba@1030: arc_map[graph.direct(e1, false)] = 212; deba@1030: arc_map[graph.direct(e2, true)] = 221; deba@1030: arc_map[graph.direct(e2, false)] = 222; deba@1030: deba@1030: int attr = 100; deba@1030: deba@1030: std::ostringstream os; deba@1030: lemon::BpGraphWriter writer(graph, os); deba@1030: deba@1030: writer.nodeMap("node_map1", node_map); deba@1030: writer.nodeMap("node_map2", node_map, WriterConverter()); deba@1030: writer.nodeMap("red_node_map1", red_node_map); deba@1030: writer.nodeMap("red_node_map2", red_node_map, WriterConverter()); deba@1030: writer.nodeMap("blue_node_map1", blue_node_map); deba@1030: writer.nodeMap("blue_node_map2", blue_node_map, WriterConverter()); deba@1030: writer.edgeMap("edge_map1", edge_map); deba@1030: writer.edgeMap("edge_map2", edge_map, WriterConverter()); deba@1030: writer.arcMap("arc_map1", arc_map); deba@1030: writer.arcMap("arc_map2", arc_map, WriterConverter()); deba@1030: writer.node("node", n); deba@1030: writer.redNode("red_node", rn1); deba@1030: writer.blueNode("blue_node", bn2); deba@1030: writer.edge("edge", e1); deba@1030: writer.arc("arc", graph.direct(e1, false)); deba@1030: writer.attribute("attr1", attr); deba@1030: writer.attribute("attr2", attr, WriterConverter()); deba@1030: deba@1030: writer.run(); deba@1030: deba@1030: typedef lemon::ListBpGraph ExpGraph; deba@1030: ExpGraph exp_graph; deba@1030: ExpGraph::NodeMap exp_node_map1(exp_graph); deba@1030: ExpGraph::NodeMap exp_node_map2(exp_graph); deba@1030: ExpGraph::RedNodeMap exp_red_node_map1(exp_graph); deba@1030: ExpGraph::RedNodeMap exp_red_node_map2(exp_graph); deba@1030: ExpGraph::BlueNodeMap exp_blue_node_map1(exp_graph); deba@1030: ExpGraph::BlueNodeMap exp_blue_node_map2(exp_graph); deba@1030: ExpGraph::EdgeMap exp_edge_map1(exp_graph); deba@1030: ExpGraph::EdgeMap exp_edge_map2(exp_graph); deba@1030: ExpGraph::ArcMap exp_arc_map1(exp_graph); deba@1030: ExpGraph::ArcMap exp_arc_map2(exp_graph); deba@1030: ExpGraph::Node exp_n; deba@1030: ExpGraph::RedNode exp_rn1; deba@1030: ExpGraph::BlueNode exp_bn2; deba@1030: ExpGraph::Edge exp_e1; deba@1030: ExpGraph::Arc exp_a1; deba@1030: int exp_attr1; deba@1030: int exp_attr2; deba@1030: deba@1030: std::istringstream is(os.str()); deba@1030: lemon::BpGraphReader reader(exp_graph, is); deba@1030: deba@1030: reader.nodeMap("node_map1", exp_node_map1); deba@1030: reader.nodeMap("node_map2", exp_node_map2, ReaderConverter()); deba@1030: reader.redNodeMap("red_node_map1", exp_red_node_map1); deba@1030: reader.redNodeMap("red_node_map2", exp_red_node_map2, ReaderConverter()); deba@1030: reader.blueNodeMap("blue_node_map1", exp_blue_node_map1); deba@1030: reader.blueNodeMap("blue_node_map2", exp_blue_node_map2, ReaderConverter()); deba@1030: reader.edgeMap("edge_map1", exp_edge_map1); deba@1030: reader.edgeMap("edge_map2", exp_edge_map2, ReaderConverter()); deba@1030: reader.arcMap("arc_map1", exp_arc_map1); deba@1030: reader.arcMap("arc_map2", exp_arc_map2, ReaderConverter()); deba@1030: reader.node("node", exp_n); deba@1030: reader.redNode("red_node", exp_rn1); deba@1030: reader.blueNode("blue_node", exp_bn2); deba@1030: reader.edge("edge", exp_e1); deba@1030: reader.arc("arc", exp_a1); deba@1030: reader.attribute("attr1", exp_attr1); deba@1030: reader.attribute("attr2", exp_attr2, ReaderConverter()); deba@1030: deba@1030: reader.run(); deba@1030: deba@1030: check(lemon::countNodes(exp_graph) == 5, "Wrong number of nodes"); deba@1030: check(lemon::countRedNodes(exp_graph) == 3, "Wrong number of red nodes"); deba@1030: check(lemon::countBlueNodes(exp_graph) == 2, "Wrong number of blue nodes"); deba@1030: check(lemon::countEdges(exp_graph) == 2, "Wrong number of edges"); deba@1030: check(lemon::countArcs(exp_graph) == 4, "Wrong number of arcs"); deba@1030: check(exp_node_map1[exp_n] == 14, "Wrong map value"); deba@1030: check(exp_node_map2[exp_n] == 14, "Wrong map value"); deba@1030: check(exp_red_node_map1[exp_rn1] == 411, "Wrong map value"); deba@1030: check(exp_red_node_map2[exp_rn1] == 411, "Wrong map value"); deba@1030: check(exp_blue_node_map1[exp_bn2] == 415, "Wrong map value"); deba@1030: check(exp_blue_node_map2[exp_bn2] == 415, "Wrong map value"); deba@1030: check(exp_edge_map1[exp_e1] == 21, "Wrong map value"); deba@1030: check(exp_edge_map2[exp_e1] == 21, "Wrong map value"); deba@1030: check(exp_arc_map1[exp_a1] == 212, "Wrong map value"); deba@1030: check(exp_arc_map2[exp_a1] == 212, "Wrong map value"); deba@1030: check(exp_attr1 == 100, "Wrong attr value"); deba@1030: check(exp_attr2 == 100, "Wrong attr value"); deba@1030: } deba@1030: deba@1030: deba@1030: int main() { deba@1030: { // Check digrpah deba@1030: checkDigraphReaderWriter(); deba@1030: } deba@1030: { // Check graph deba@1030: checkGraphReaderWriter(); deba@1030: } deba@1030: { // Check bipartite graph deba@1030: checkBpGraphReaderWriter(); deba@1030: } deba@1030: return 0; deba@1030: }