Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can use <a href="http://docs.python.org/2/library/functions.html#map" rel="nofollow">map</a></p> <p>to do so, simply change connection to accept a circle as its parameter, and have the <code>r</code> as part of the circle</p> <pre><code>def connection(circle): n, m, r = circle is_connected = ((x[n]-x[m])**2 + (y[n]-y[m])**2)**0.5 if is_connected &lt; 2*r: return n + " " + "connects with" + " " + m else: return "no connection" </code></pre> <p>and have your list be a list of circles AND their radius.</p> <pre><code>circles = array([ [ 0.31730234, 0.73662906, r], [ 0.54488759, 0.09462212, r], [ 0.07500703, 0.36148366, r], [ 0.33200281, 0.04550565, r], [ 0.3420866 , 0.9425797 , r], [ 0.36115391, 0.16670599, r], [ 0.95586938, 0.52599398, r], [ 0.13707665, 0.6574444 , r], [ 0.77766138, 0.56875582, r], [ 0.79618595, 0.7139309 , r]]) </code></pre> <p>then simply do this:</p> <pre><code>map(connection, circles) </code></pre> <p>if the r is external, or a member then you want to use this:</p> <pre><code>def connection(coord): n, m = coord is_connected = ((x[n]-x[m])**2 + (y[n]-y[m])**2)**0.5 if is_connected &lt; 2*r: return n + " " + "connects with" + " " + m else: return "no connection" coords = array([ [ 0.31730234, 0.73662906], [ 0.54488759, 0.09462212], [ 0.07500703, 0.36148366], [ 0.33200281, 0.04550565], [ 0.3420866 , 0.9425797 ], [ 0.36115391, 0.16670599], [ 0.95586938, 0.52599398], [ 0.13707665, 0.6574444 ], [ 0.77766138, 0.56875582], [ 0.79618595, 0.7139309 ]]) map(connection, coords) </code></pre> <p>or you can keep your current format, and do a slightly uglier implementation. and i still dont know where you get the <code>r</code> from.</p> <pre><code>for item in circles: connection(item[0], item[1], r) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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