[Lemon-user] question about write data to lgf file
Alpár Jüttner
alpar at cs.elte.hu
Wed Jun 1 07:16:32 CEST 2011
Hi,
> digraphWriter(g, "out.lgf")
> .nodeMap("Name", name)
> .run();
>
> The map "name" can be written to file in this way, but how to write the
> " vessel_property" map? I want to output and read it's "Vol", "Temp" etc.
One way is that you write a function (or functor) vessel_to_str() that
takes a vessel as input and returns a string representation. Then you
can add this as the third argument to nodemap():
digraphWriter(g, "out.lgf")
.nodeMap("vessel_pr", vessel_property, vessel_to_str)
.run();
The reading is node similarly.
If you want to save a single member to the lgf, you can write also map
adaptor:
class VesselVol
{
public:
typedef ListDigraph::Node Key;
typedef double Value;
ListDigraph::NodeMap<vessel> &vessel_property;
VesselVol(ListDigraph::NodeMap<vessel> &v) :vessel_property(v) {};
double &operator[](Key n) { return vessel_property[n].Vol; }
void set(Key n,double v) { vessel_property[n].Vol=v; }
}
VesselVol vv(vessel_property);
digraphWriter(g, "out.lgf")
.nodeMap("vessel_vol", vv)
.run();
digraphReader(g, "out.lgf")
.nodeMap("vessel_vol", vv)
.run();
Regards:
Alpar
More information about the Lemon-user
mailing list