<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">No worries, thanks the for the explanation.  I figured it was a copy constructor issue.  I ended using some smart pointers to deal with the problem.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 30, 2016 at 2:46 PM, Kovács Péter <span dir="ltr"><<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi John,<br>
<br>
The issue is most likely what Balázs wrote: "the FilterNodes is initiated with a local map, which is destroyed when the execution leaves the function scope."<br>
<br>
Note that FilterNodes is a light-weight wrapper class that only stores pointers to the underlying graph and to the node map. You should be aware of the lifetime of the original graph and node map even if you pass the FilterNodes as value. (Because it is a shallow copy.)<br>
<br>
Anyway, the main graph types of LEMON, such as ListDigraph, do not allow the assingment operator and the copy constructor (these functions are private). You should pass such graphs as references or pointers, or if you would really like to make a copy, you can use DigraphCopy. FilterNodes, however, allows these operations as it is a light-weight class.<br>
<br>
I hope this helps. And sorry for the confusion, I sent the first email in a haste.<span class="HOEnZb"><font color="#888888"><br>
<br>
Péter<br>
<br>
<br>
<br>
</font></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
My graphs are quite small, 10 nodes on average.<br>
<br>
On Fri, Dec 30, 2016 at 1:47 PM, Kovács Péter <<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a><br></span><span class="">
<mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>>> wrote:<br>
<br>
    Hi All,<br>
<br>
    Thanks for the corrections. I'm terribly sorry for the stupid<br>
    mistake. So I suggest passing references, but of course, not for<br>
    local variables. :)<br>
<br>
    Péter<br>
<br>
<br>
<br>
            FilterNodes<ListDigraph>& get_subgraph(void)<br>
            {<br>
                FilterNodes<ListDigraph> subgraph;<br>
                ...<br>
                return g;<br>
            }<br>
<br>
        This is a bad idea as it creates a reference to a temporary<br>
        variable. I<br>
        think the real problem is that the FilterNodes is initiated with<br>
        a local<br>
        map, which is destroyed when the execution leaves the function<br>
        scope.<br>
<br>
        Balazs<br>
<br>
        On Fri, Dec 30, 2016 at 9:17 PM, Kovács Péter<br>
        <<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a> <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>><br></span><div><div class="h5">
        <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a> <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>>>> wrote:<br>
<br>
            Hi John,<br>
<br>
            You should avoid passing graphs (and other large data<br>
        structures) as<br>
            values between functions. Use references or pointers<br>
        instead. For<br>
            example:<br>
<br>
            FilterNodes<ListDigraph>& get_subgraph(void)<br>
            {<br>
                FilterNodes<ListDigraph> subgraph;<br>
                ...<br>
                return g;<br>
            }<br>
<br>
            Note the '&' sign in the return type of the function. (If its<br>
            meaning is not clear, read some C++ tutorials about<br>
        references and<br>
            pointers.)<br>
<br>
            Regards,<br>
            Péter<br>
<br>
<br>
<br>
                Péter,<br>
<br>
                It turns out that the issue I am having is related to<br>
        trying to<br>
                return<br>
                a FilterNodes<ListDigraph> issue from a function.  If<br>
                the FilterNodes<ListDigraph> object is local I can iterate<br>
                through the<br>
                nodes as expected.  If the object is returned from a<br>
        function i.e.<br>
<br>
                FilterNodes<ListDigraph> get_subgraph(void)<br>
                {<br>
                }<br>
<br>
                void another_function()<br>
                {<br>
                     auto x = get_subgraph();<br>
<br>
                     for (FilterNodes<ListDigraph>::Nod<wbr>eIt n(x); n !=<br>
        INVALID; ++n)<br>
                     ...<br>
                }<br>
<br>
                I get an exception when trying to iterate through the nodes.<br>
<br>
                John<br>
<br>
<br>
<br>
<br>
                On Thu, Dec 29, 2016 at 5:28 PM, Kovács Péter<br>
                <<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a> <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>><br>
        <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a> <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>>><br>
                <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a> <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>><br>
        <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a> <mailto:<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a>>>>> wrote:<br>
<br>
                    Hi John,<br>
<br>
                    What kind of write method are you looking for? Could you<br>
                send a code<br>
                    snippet that works for the graph, but does not apply<br>
        to the<br>
                subgraph?<br>
<br>
                    Regards,<br>
                    Péter<br>
<br>
<br>
                        I have a subgraph as follows:<br>
<br>
                        FilterNodes<ListDigraph> sub(*graph, filter);<br>
<br>
                        There doesn't appear to be a write method for the<br>
                subgraph as<br>
                        there is<br>
                        for the graph.<br>
<br>
                        Suggestions?<br>
<br>
<br>
                        --<br>
                        John Lagerquist<br>
                        Chief Engineer<br>
                        RallyTronics LLC<br>
                        801-866-5981<br>
<br>
<br>
<br>
<br>
                        ______________________________<wbr>_________________<br>
                        Lemon-user mailing list<br>
                        <a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.elte.hu</a><br>
        <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a>><br>
                <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a><br>
        <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a>>><br>
                <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a><br>
        <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a>><br>
                <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a><br>
        <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a>>>><br>
<br>
        <a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailma<wbr>n/listinfo/lemon-user</a><br>
        <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a>><br>
                <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a><br>
        <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a>>><br>
<br>
        <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a><br>
        <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a>><br>
                <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a><br>
        <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a>>>><br>
<br>
<br>
<br>
<br>
<br>
                --<br>
                John Lagerquist<br>
                Chief Engineer<br>
                RallyTronics LLC<br>
                801-866-5981<br>
<br>
<br>
<br>
            ______________________________<wbr>_________________<br>
            Lemon-user mailing list<br>
            <a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.elte.hu</a><br>
        <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a>><br>
        <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a><br>
        <mailto:<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.el<wbr>te.hu</a>>><br>
            <a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailma<wbr>n/listinfo/lemon-user</a><br>
        <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a>><br>
            <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a><br>
        <<a href="http://lemon.cs.elte.hu/mailman/listinfo/lemon-user" rel="noreferrer" target="_blank">http://lemon.cs.elte.hu/mailm<wbr>an/listinfo/lemon-user</a>>><br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
John Lagerquist<br>
Chief Engineer<br>
RallyTronics LLC<br>
801-866-5981<br>
<br>
<br>
</div></div></blockquote>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">John Lagerquist<div>Chief Engineer<br><div>RallyTronics LLC</div><div>801-866-5981</div><div><br></div><div><br></div></div></div>
</div>