How to count the number of elements of different combination at a network and form a matrix based upon their position in Matlab?

I have a network with order number assigned for each link. I want to count the number of the link such that i get the values for the number of 1s joining 2, 1s joining 3, 1s joining 4 separately. Similarly i want to calculate the count for 2s joining 3, 4. only condition is that the value direction can't be decreasing i.e. 2s to 1, 3s to 2. Finally, i want to create a matrix based upon the count. Each line in the network starts from From_node and ends at TO_NODE.I am also attaching the pics to clarify what i am trying to do. Thanks a lot. enter image description here

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum