Note that there are some explanatory texts on larger screens.

plurals
  1. POAdvanced graph SQL question
    text
    copied!<p>I have a directed graph described by <code>A -&gt; B</code> meaning that there exists a connection, always weight 1, FROM A TO B. The problem I want to solve (This is not an academic project) is how can I tell how many common connections there are between two nodes. </p> <p>To say that in terms of A and B.<br> There are 2 things that need to get done,<br> * To look at all of my, B, links coming in (All A's to some B)<br> * Count how many common A's out of all My, Original B, A's. </p> <p>I do not know if that makes sense but I'll show you how far I have come.<br> * First point. </p> <pre><code>SELECT A FROM graph WHERE B='myid'; </code></pre> <p>As most can tell, part 1 is a very simple question. Part 2 is where things get tricky.<br> I have been able to get all the A's with at least 1 connection or more similar. </p> <p>Second point. </p> <pre><code>SELECT G.A, count( G2.A ) AS common FROM graph AS G2 JOIN ( SELECT A, B FROM graph WHERE B = 'myid' ) AS G ON G.A = G2.B </code></pre> <p>So the second point is close because it will return all common links, <strong>but</strong> it will not return all links which have no common links. Is there a way to get that too? </p> <hr> <p>There is still confusion: Ill try to draw a picture... with words.<br> Here is the table. </p> <pre><code>A, B ----- 2, 1 3, 1 2, 3 </code></pre> <p>If I wanted to see how many common links from all incoming links into NODE 1 I <strong>should</strong> see </p> <pre><code>A, count --------- 2, 1 // This is for 2's connection to 3. 3, 0 </code></pre> <p>With the current SQL statement I have I see this.</p> <pre><code>A, count --------- 2, 1 // This is for 2's connection to 3. </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