Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is because you try to access an array out of its boundary. </p> <p>I will show you how you can debug such errors.</p> <ol> <li>I set <code>options(error=recover)</code></li> <li><p>I run <code>reach_full_in &lt;- reachability(krack_full, 'in')</code> I get :</p> <pre><code>reach_full_in &lt;- reachability(krack_full, 'in') Error in reach_mat[i, alter] = 1 : subscript out of bounds Enter a frame number, or 0 to exit 1: reachability(krack_full, "in") </code></pre></li> <li><p>I enter 1 and I get </p> <pre><code> Called from: top level </code></pre></li> <li><p>I type <code>ls()</code> to see my current variables</p> <pre><code> 1] "*tmp*" "alter" "g" "i" "j" "m" "reach_mat" "this_node_reach" </code></pre></li> </ol> <p>Now, I will see the dimensions of my variables : </p> <pre><code>Browse[1]&gt; i [1] 1 Browse[1]&gt; j [1] 21 Browse[1]&gt; alter [1] 22 Browse[1]&gt; dim(reach_mat) [1] 21 21 </code></pre> <p>You see that alter is out of bounds. 22 > 21 . in the line :</p> <pre><code> reach_mat[i, alter] = 1 </code></pre> <p>To avoid such error, personally I do this :</p> <ul> <li>Try to use <code>applyxx</code> function. They are safer than <code>for</code></li> <li>I use <code>seq_along</code> and not <code>1:n</code> (1:0)</li> <li>Try to think in a vectorized solution if you can to avoid <code>mat[i,j]</code> index access.</li> </ul> <p><strong>EDIT vectorize the solution</strong></p> <p>For example, here I see that you don't use the fact that <code>set.vertex.attribute</code> is vectorized.</p> <p>You can replace:</p> <pre><code># Set vertex attributes for (i in V(krack_full)) { for (j in names(attributes)) { krack_full &lt;- set.vertex.attribute(krack_full, j, index=i, attributes[i+1,j]) } } </code></pre> <p>by this:</p> <pre><code>## set.vertex.attribute is vectorized! ## no need to loop over vertex! for (attr in names(attributes)) krack_full &lt;&lt;- set.vertex.attribute(krack_full, attr, value = attributes[,attr]) </code></pre>
 

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