How to find number of nodes connected to two nodes in a graph?
<p>I have a direct graph with the following adjacency matrix</p>

<pre><code>as.matrix(read.table(header=T, text=
" A B C D E F
A 0 1 0 0 0 1
B 0 0 0 0 0 1
C 0 1 0 0 1 0
D 0 1 0 0 1 1
E 0 0 0 0 0 1
F 0 0 0 0 0 0"))
</code></pre>

<p>I want to do some matrix manipulation that can give me the number of unique nodes that follow two nodes. For example in the previous matrix the result should be</p>

<pre><code>  A B C D E F
A|0 3 0 0 2 4|
B|3 3 3 3 3 5|
C|0 3 0 0 2 4|
D|0 3 0 0 2 4|
E|2 3 2 2 2 5|
F|4 5 4 4 5 4|
</code></pre>

<p>I'm using R for my coding. That would be great if somebody can help on that</p>