package se.chalmers.cs.gf.graph; import se.gu.ling.trindikit.oaa.common.*; import se.chalmers.cs.gf.util.FileUtil; import se.chalmers.cs.gf.tramdemo.DotToGraph; import java.io.IOException; import java.util.Properties; public class GraphAgent extends OAAAgent { /** The name of this agent. */ static final String name = "GraphAgent"; /** The only state of this agent. */ static final int RUNNING = 0; public GraphAgent(Graph graph, String[] args) throws IOException { super(RUNNING,1); addSolver(RUNNING, new ShortestPathSolver(graph)); if (!register(name,args)) System.err.println(name + ": register() failed"); } public static void main(String[] args) throws IOException { if (args.length < 1 || !args[0].endsWith(".properties")) { System.err.println("Usage: java se.chalmers.cs.gf.graph.GraphAgent [-oaa_connect tcp('$HOST',$FAC_PORT)]"); System.exit(1); } Properties cityProps = FileUtil.readPropertiesResource(args[0]); String graphResource = cityProps.getProperty("graph"); Graph graph = DotToGraph.fromDotResource(graphResource); new GraphAgent(graph, args); } }