public void nondeterministicPreCanonicalization(NamedGraph g) throws Exception{
		//Get triples
		ArrayList<Triple> triples=g.getTriples();
		
		//Get C14N Predicate
		String c14n=Ontology.getC14NPredicate();
		
		//Count and substitute blank nodes
		substituteBlankNodes(triples);
		
		//Perform a one-step deterministic labeling (Step A)
		lookupTable = new HashMap<String,Integer>();
		counter=new GenSymCounter(bnCount);
		oneStepDeterministicLabelling(g);
		canonicalizeGraphNames(g);
		canonicalizeReifications(g);
		
		//Stop if there are no hard to label nodes (Step B)
		if ( bnCount==0 ){
			return;
		}
		
		//Delete triples with predicate "c14n:true" (Step C)
		for(Triple t:triples) {
			if (t.getPredicate().equals(c14n)){
				triples.remove(t);
			}
		}
		
		//Perform another one-step deterministic labeling (Step D)
		substituteBlankNodes(triples);		
		oneStepDeterministicLabelling(g);
		canonicalizeGraphNames(g);
		canonicalizeReifications(g);
		
		//Handle remaining hard to label nodes by adding new nodes (Step E)
		lookupTable.clear();
		counter.reset();
		ArrayList<Triple> newTriples = new ArrayList<Triple>();
		for(Triple t:triples) {
			//Object and subject replacement - two iterations in while loop:
			// 1) pos = Triple.object
			// 2) pos = Triple.subject
			int pos = Triple.object;
			while (true){
				if (t.getByIndex(pos).equals("~")){
					//Get original blank node identifier from annotation
					String bnName = t.getAnnotation();
					//Is blank node in lookup table?
					Integer lookupName = lookupTable.get(bnName);
					if (lookupName == null){
						//No, generate a new triple
						newTriples.add( new Triple(bnName, c14n, "\""+counter.getNewSym()+"\"") );
						lookupTable.put("x",counter.getCurrentValue());
					}
				}
				//Replace subject after object or end loop if subject has been replaced already
				if (pos == Triple.object){
					pos = Triple.subject;
				}else{
					break;
				}
			}
		}
		for (Triple addNew:newTriples){
			triples.add(addNew);
		}
		canonicalizeGraphNames(g);
		canonicalizeReifications(g);
		
		//Perform another one-step deterministic labeling (Step F)
		lookupTable.clear();
		counter.reset();
		substituteBlankNodes(triples);
		oneStepDeterministicLabelling(g);
		canonicalizeGraphNames(g);
		canonicalizeReifications(g);
		
		//Sort sub graphs
		Collections.sort(g.getChildren());
	}