Count number of nodes in a graph (network) in java
<p>I'm writing a program in java to schedule activities from a project, taking into account resource limitations (similar to MS project, but more basic ofcourse). When there are too few resources available, I use a priority rule to arrange the activities in a certain order (such that the most important activities can be scheduled first). </p>

<p>One of the priority rules I'm scheduling is "<strong>most total successors</strong>", which gives priority to an activity that has the most "unscheduled" followers. I included a picture to give you an idea what I'm talking about (it's not the picture of the project I'm using, because it is too large). For activity A, the total number of successors would be 3 (B, E, C).</p>

<p>I have information about the total number of activities and about the immediate successors of all activities (in binary form, if followers[ 2 ][ 1 ]==1 for example, this means that activity 2 is an immedita follower of activity 1), but my main problem is that I don't know how to get info from the followers' followers and the followers of the followers' followers, and... since I don't know how "deep" my graph is. I already searched for solutions on the internet, but most of them seem to apply for binary trees (like binary search), which is not the case for my network (some activities have 3 or more followers, some activities are shared,...).</p>

<p>Does someone maybe has an idea (or a hint) how I could handle this problem?
Thanks a lot in advance! (And sorry for the long post)   </p>

<p><a href="http://i.stack.imgur.com/vknQv.jpg" rel="nofollow">Example of a network</a></p>
