Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you represent your graph as an adjacency list (rather than an adjacency matrix), you can make use of the fact that your graph has only 600,000 edges to hopefully reduce the computation time.</p> <p>Let's take a node <code>V[j]</code> with neighbors <code>V[i]</code> and <code>V[k]</code>:</p> <pre><code>V[i] ---- V[j] ---- V[k] </code></pre> <p>To find all such pairs of neighbors you can take the list of nodes adjacent to <code>V[j]</code> and find all combinations of those nodes. To avoid duplicates you will have to generate the combinations rather than the permutations of the end nodes <code>V[i]</code> and <code>V[k]</code> by requiring that <code>i &lt; k</code>.</p> <p>Alternatively, you can start with node <code>V[i]</code> and find all of the nodes that have a distance of 2 from <code>V[i]</code>. Let <code>S</code> be the set of all the nodes adjacent to <code>V[i]</code>. For each node <code>V[j]</code> in <code>S</code>, create a path <code>V[i]-V[j]-V[k]</code> where:</p> <ol> <li><code>V[k]</code> is adjacent to <code>V[j]</code></li> <li><code>V[k]</code> is not an element of <code>S</code> (to avoid directly connected nodes)</li> <li><code>k != i</code> (to avoid cycles)</li> <li><code>k &gt; i</code> (to avoid duplications)</li> </ol> <p>I personally like this approach better because it completes the adjacency list for one node before moving on to the next.</p> <p>Given that you have ~600,000 edges in a graph with ~100,000 nodes, assuming an even distribution of edges across all of the nodes each node would have an average degree of 12. The number of possible paths for each node is then on the order of 10<sup>2</sup>. Over 10<sup>5</sup> nodes that gives on the order of 10<sup>7</sup> total paths rather than the theoretical limit of 10<sup>10</sup> for a complete graph. Still a large number, but a thousand times faster than before.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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