Package org.geotools.graph.build.basic

Examples of org.geotools.graph.build.basic.BasicDirectedGraphGenerator


     *  </p>
     */

  public List<AttributeType> sort() {
    //build a directed graph representing dependencies among types
    GraphGenerator gg = new BasicDirectedGraphGenerator();
   
    for (Iterator itr = types.values().iterator(); itr.hasNext();) {
      AttributeType type = (AttributeType) itr.next();
      AttributeType superType =  type.getSuper();
     
      if (superType != null) {
        //add edge type -> parent
        gg.add(new Object[]{type,superType});
      }
     
      if (type instanceof ComplexType) {
        ComplexType cType = (ComplexType) type;
       
        //add an edge for each descriptor
        Collection atts = cType.getDescriptors();
        for (Iterator aitr = atts.iterator(); aitr.hasNext();) {
          PropertyDescriptor ad = (PropertyDescriptor) aitr.next();
          gg.add(new Object[]{type,ad.getType()});
        }
      }
    }
   
    Graph graph = gg.getGraph();
   
    //test the graph for cycles
    CycleDetector cycleDetector = new DirectedCycleDetector(graph);
    if (cycleDetector.containsCycle()) {
      logger.info("Cycle found");
View Full Code Here

TOP

Related Classes of org.geotools.graph.build.basic.BasicDirectedGraphGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.