public static Collection < TypedDependency > getRoots ( Collection < TypedDependency > list ) { Collection < TypedDependency > roots = new ArrayList < TypedDependency > ( ) ; // need to see if more than one governor is not listed somewhere as a dependent // first take all the deps Collection < TreeGraphNode > deps = new HashSet < TreeGraphNode > ( ) ; for ( TypedDependency typedDep : list ) { deps . add ( typedDep . dep ( ) ) ; } // go through the list and add typedDependency for which the gov is not a dep Collection < TreeGraphNode > govs = new HashSet < TreeGraphNode > ( ) ; for ( TypedDependency typedDep : list ) { TreeGraphNode gov = typedDep . gov ( ) ; if ( ! deps . contains ( gov ) && ! govs . contains ( gov ) ) { roots . add ( typedDep ) ; } govs . add ( gov ) ; } return roots ; }
Return a list of TypedDependencies which are not dependent on any node from the list .