sparqlGraphLibrary/src/main/java/com/ge/research/semtk/ontologyTools/PathExplorer.java
public Node addClassFirstPath(NodeGroup ng, String classUri, String instanceUri) throws Exception {
		ArrayList<Node> nodeList = ng.getNodeList();
		HashSet<String> classSet = new HashSet<String>();
		
		// get unique list of node URI's in ng
		for (Node n : nodeList) {
			classSet.add(n.getFullUriName());
		}
		
		// get list of all oInfo model paths from classUri to the ng nodes.
		HashSet<String> classList = new HashSet<String>();
		classList.addAll(classSet);
		ArrayList<OntologyPath> pathList = oInfo.findAllPaths(classUri, classList);
		
		// for each possible path
		for (OntologyPath path : pathList) {
			
			// for each possible connection point
			for (Node connectPoint : ng.getNodesByURI(path.getAnchorClassName())) {
				
				if (this.pathHasInstance(ng, connectPoint, path, instanceUri)) {
					// first success: modify ng and return true
					return ng.addPath(path, ng.getNodeBySparqlID(connectPoint.getSparqlID()), this.oInfo);
				} 
			}
		}
		
		// couldn't find any legal path
		return null;
	}
/**
	 * Starting with all legal paths from oInfo
	 * Find the first one that would actually have some data in it.
	 * @param ng - starting nodegroup (which must have some data)
	 * @param classUri - class to add
	 * @return - boolean : was ng modified
	 * @throws Exception
	 */
Starting with all legal paths from oInfo
Find the first one that would actually have some data in it.
@param ng - starting nodegroup (which must have some data)
@param classUri - class to add
@return - boolean : was ng modified
@throws Exception
Starting with all legal paths from oInfo Find the first one that would actually have some data in it . @param ng - starting nodegroup ( which must have some data ) @param classUri - class to add @return - boolean : was ng modified @throws Exception
public Node addClassFirstPath(NodeGroup ng, String classUri, String instanceUri) throws Exception {
		ArrayList<Node> nodeList = ng.getNodeList();
		HashSet<String> classSet = new HashSet<String>();
		for (Node n : nodeList) {
			classSet.add(n.getFullUriName());
		}
		HashSet<String> classList = new HashSet<String>();
		classList.addAll(classSet);
		ArrayList<OntologyPath> pathList = oInfo.findAllPaths(classUri, classList);
		for (OntologyPath path : pathList) {
			for (Node connectPoint : ng.getNodesByURI(path.getAnchorClassName())) {
				if (this.pathHasInstance(ng, connectPoint, path, instanceUri)) {
					return ng.addPath(path, ng.getNodeBySparqlID(connectPoint.getSparqlID()), this.oInfo);
				} 
			}
		}
		return null;
	}
public Node addClassFirstPath ( NodeGroup ng , String classUri , String instanceUri ) throws Exception { ArrayList < Node > nodeList = ng . getNodeList ( ) ; HashSet < String > classSet = new HashSet < String > ( ) ; for ( Node n : nodeList ) { classSet . add ( n . getFullUriName ( ) ) ; } HashSet < String > classList = new HashSet < String > ( ) ; classList . addAll ( classSet ) ; ArrayList < OntologyPath > pathList = oInfo . findAllPaths ( classUri , classList ) ; for ( OntologyPath path : pathList ) { for ( Node connectPoint : ng . getNodesByURI ( path . getAnchorClassName ( ) ) ) { if ( this . pathHasInstance ( ng , connectPoint , path , instanceUri ) ) { return ng . addPath ( path , ng . getNodeBySparqlID ( connectPoint . getSparqlID ( ) ) , this . oInfo ) ; } } } return null ; }
Starting with all legal paths from oInfo
 Find the first one that would actually have some data in it.
Starting with all legal paths from oInfo Find the first one that would actually have some data in it .
// get unique list of node URI's in ng // get list of all oInfo model paths from classUri to the ng nodes. // for each possible path // for each possible connection point // first success: modify ng and return true // couldn't find any legal path