Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Degeneralize.java

00001 package gov.nasa.arc.ase.util.graph;
00002 
00003 import java.io.IOException;
00004 
00005 public class Degeneralize {
00006   private static void accept(Graph g) {
00007     g.setBooleanAttribute("nsets", false);
00008 
00009     g.forAllNodes(new EmptyVisitor() {
00010       public void visitNode(Node n) {
00011     if(n.getBooleanAttribute("acc0")) {
00012       n.setBooleanAttribute("accepting", true);
00013       n.setBooleanAttribute("acc0", false);
00014     }
00015       }
00016     });
00017   }  
00018   public static Graph degeneralize(Graph g) {
00019     int nsets = g.getIntAttribute("nsets");
00020     String type = g.getStringAttribute("type");
00021 
00022     if(type.equals("gba")) {
00023       String ac = g.getStringAttribute("ac");
00024 
00025       if(ac.equals("nodes")) {
00026             if(nsets == 1)
00027                 accept(g);
00028             else {
00029                 Label.label(g);
00030                 Graph d = Generate.generate(nsets);
00031       
00032         //      d.save(Graph.FSP_FORMAT);
00033       
00034                 g = degenSynchronousProduct.product(g, d);
00035             }
00036       } else if(ac.equals("edges")) {
00037             Graph d = Generate.generate(nsets);
00038     
00039     //      d.save(Graph.FSP_FORMAT);
00040         
00041             g = degenSynchronousProduct.product(g, d);
00042         }
00043     } else if(!type.equals("ba"))
00044       throw new RuntimeException("invalid graph type: " + type);
00045 
00046     return g;
00047   }  
00048   public static void help() {
00049     System.err.println("usage:");
00050     System.err.println("\tDegenalize [outfile]");
00051     System.exit(1);
00052   }  
00053   public static void main(String[] args) {
00054     if(args.length > 1) {
00055       System.out.println("usage:");
00056       System.out.println("\tjava gov.nasa.arc.ase.util.graph.Degeneralize [<filename>]");
00057       return;
00058     }
00059 
00060     Graph g = null;
00061 
00062     try {
00063       if(args.length == 0)
00064     g = Graph.load();
00065       else
00066     g = Graph.load(args[0]);
00067     } catch(IOException e) {
00068       System.out.println("Can't load the graph.");
00069       return;
00070     }
00071 
00072     g = degeneralize(g);
00073 
00074     g.save();
00075   }  
00076 }

Generated at Thu Feb 7 06:43:37 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001