Note that there are some explanatory texts on larger screens.

plurals
  1. POc++ std::vector Orphan Range error
    text
    copied!<p>A program dealing with graphs(from graph theory) representation and transformation.The adjacency list and matrix are implemented like dynamic arrays of vectors(don't ask why not vector of vector) for the following function program exits with memory error and compiler pointing to the orphan vector definition.</p> <pre><code>int vertex,edges; vector&lt;int&gt; *adjacencyList,*adjacencyMatrix; void listToAdMatrix(int vertexNumber, vector&lt;int&gt; *List, vector&lt;int&gt; *Matrix){ int in=0,cont=0; for(int i=0;i&lt;vertexNumber;i++){ in=i; for(auto j=List[in].begin();j!=List[in].end();j++){ for(int k=0;k&lt;vertexNumber;++k){ if(k==*j) Matrix[cont].push_back(1); else Matrix[cont].push_back(0); } cont++; } } } //function call //vertex(number) and ajacencyList are initialized adjacencyMatrix=new vector&lt;int&gt;[vertex]; listToAdMatrix(vertex,adjacencyList,adjacencyMatrix); </code></pre> <p>The "source of error" in STL where compiler points:</p> <p><a href="http://i51.tinypic.com/2dt0t9e.jpg" rel="nofollow">http://i51.tinypic.com/2dt0t9e.jpg</a></p> <hr> <p>The error message:</p> <p><strong>Unhandled exception at 0x001a543b in graph.exe: 0xC0000005: Access violation reading location 0xfdfdfe01.</strong></p> <hr> <p>the fillList function used to fill the adjacency list :</p> <pre><code>void fillList(int vertexNumber, vector&lt;int&gt; *List){ int input=0; for (int i=0;i&lt;vertexNumber;i++){ int in=i; cout&lt;&lt;"Introduce adjacent vertexes for the vertex -"&lt;&lt;i+1&lt;&lt;"-:"&lt;&lt;endl; for(int j=0;j&lt;vertexNumber;j++){ std::cout&lt;&lt;i+1&lt;&lt;"-"; std::cin&gt;&gt;input; if(input==0) break; List[i].push_back(input-1); } } } </code></pre> <p>Any clue is welcome.</p> <hr>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload