<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">FilterNodes<ListDigraph>& get_subgraph(void)<br>{<br> FilterNodes<ListDigraph> subgraph;<br> ...<br> return g;<br>}</blockquote><div>This is a bad idea as it creates a reference to a temporary variable. I think the real problem is that the FilterNodes is initiated with a local map, which is destroyed when the execution leaves the function scope.</div><div><br></div><div>Balazs</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 30, 2016 at 9:17 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi John,<br>
<br>
You should avoid passing graphs (and other large data structures) as values between functions. Use references or pointers instead. For 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 meaning is not clear, read some C++ tutorials about references and pointers.)<br>
<br>
Regards,<br>
Péter<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
Péter,<br>
<br>
It turns out that the issue I am having is related to trying to return<br>
a FilterNodes<ListDigraph> issue from a function. If<br>
the FilterNodes<ListDigraph> object is local I can iterate through the<br>
nodes as expected. If the object is returned from a 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 != 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 <<a href="mailto:kpeter@inf.elte.hu" target="_blank">kpeter@inf.elte.hu</a><br></span><span class="gmail-">
<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 send a code<br>
snippet that works for the graph, but does not apply to the 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 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></span>
<a href="mailto:Lemon-user@lemon.cs.elte.hu" target="_blank">Lemon-user@lemon.cs.elte.hu</a> <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><span class="gmail-"><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>
</span></blockquote><div class="gmail-HOEnZb"><div class="gmail-h5">
<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>
<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>
</div></div></blockquote></div><br></div></div>