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