software/test/performance/src/org/LexGrid/LexBIG/example/ProfileScheme.java
/**
	 * Recursive traversal method gauges maximum depth, average depth
	 * 
	 * @param lbs - service context
	 * @param lbscm - convenience methods
	 * @param schemeName - coding scheme name
	 * @param csVorT - coding scheme version or tag (version in this case)
	 * @param hID - hierarchy ID
	 * @param root - concept to navigate from
	 * @param level - current level of recursion
	 * @return references representing deepest path in branch (root first)
	 * @throws LBException
	 */
Recursive traversal method gauges maximum depth, average depth


Recursive traversal method gauges maximum depth average depth
protected List<ResolvedConceptReference> profileHierarchy(LexBIGService lbs, LexBIGServiceConvenienceMethods lbscm, String schemeName, CodingSchemeVersionOrTag csVorT,
			String hID, ResolvedConceptReference root, int level)
			throws LBException
	{
	    List<ResolvedConceptReference> deepestPath = new ArrayList<ResolvedConceptReference>();
	    deepestPath.add(root);
		AssociationList assocList = lbscm.getHierarchyLevelNext(schemeName, csVorT, hID, root.getConceptCode(), false, null);
		if (assocList.getAssociationCount() > 0) {
		    List<ResolvedConceptReference> deepestSubpath = new ArrayList<ResolvedConceptReference>();
			for (Association assoc: assocList.getAssociation()) {
				AssociatedConceptList conceptList = assoc.getAssociatedConcepts();
                if (conceptList.getAssociatedConceptCount() > 1) {
                    numBranchPoints++;
                    if (numBranchPoints % 10 == 0) System.out.print('.');
                    if (numBranchPoints % 780 == 0) System.out.println();
                }
                for (Iterator<AssociatedConcept> subsumed = conceptList.iterateAssociatedConcept(); subsumed.hasNext(); ) {
					AssociatedConcept childConcept = subsumed.next();
					List<ResolvedConceptReference> tempPath = profileHierarchy(lbs, lbscm, schemeName, csVorT, hID, childConcept, level+1);
                    if (tempPath.size() > deepestSubpath.size()) {
                        deepestSubpath = tempPath;
                    }
				}
			}
            deepestPath.addAll(deepestSubpath);
		} else {
            numBranches++;
            combinedDepth += (level + 1);
        }     
		return deepestPath;
	}
protected List < ResolvedConceptReference > profileHierarchy ( LexBIGService lbs , LexBIGServiceConvenienceMethods lbscm , String schemeName , CodingSchemeVersionOrTag csVorT , String hID , ResolvedConceptReference root , int level ) throws LBException { List < ResolvedConceptReference > deepestPath = new ArrayList < ResolvedConceptReference > ( ) ; deepestPath . add ( root ) ; AssociationList assocList = lbscm . getHierarchyLevelNext ( schemeName , csVorT , hID , root . getConceptCode ( ) , false , null ) ; if ( assocList . getAssociationCount ( ) > 0 ) { List < ResolvedConceptReference > deepestSubpath = new ArrayList < ResolvedConceptReference > ( ) ; for ( Association assoc : assocList . getAssociation ( ) ) { AssociatedConceptList conceptList = assoc . getAssociatedConcepts ( ) ; if ( conceptList . getAssociatedConceptCount ( ) > 1 ) { numBranchPoints ++ ; if ( numBranchPoints % 10 == 0 ) System . out . print ( '.' ) ; if ( numBranchPoints % 780 == 0 ) System . out . println ( ) ; } for ( Iterator < AssociatedConcept > subsumed = conceptList . iterateAssociatedConcept ( ) ; subsumed . hasNext ( ) ; ) { AssociatedConcept childConcept = subsumed . next ( ) ; List < ResolvedConceptReference > tempPath = profileHierarchy ( lbs , lbscm , schemeName , csVorT , hID , childConcept , level + 1 ) ; if ( tempPath . size ( ) > deepestSubpath . size ( ) ) { deepestSubpath = tempPath ; } } } deepestPath . addAll ( deepestSubpath ) ; } else { numBranches ++ ; combinedDepth += ( level + 1 ) ; } return deepestPath ; }
Recursive traversal method gauges maximum depth, average depth
Recursive traversal method gauges maximum depth average depth
// Traverse registered associations ...
 // If tree splits here, mark it as starting point of new sub-branches.
 // Bump cumulative statistics, and since this recursion can be
 // extensive provide periodic feedback to the user to indicate the
 // process is still active ...
 // Recurse through all child nodes.
 // Recurse to determine depth of sub-branch for this child.
 // Sub-branch starting at this child is deepest so far?
 // Add the deepest subpath to root for return as deepest path at this level.
 // Branch ends here, mark a complete branch and add depth to cumulative stats.
 // Contains only the root if it is a leaf; otherwise follows with
 // an example path traversing from root to deepest level.
