コード例 #1
0
ファイル: GraphEdge.cs プロジェクト: davidbedok/oeprogvep
 public static GraphEdge parse(Graph graph, String line)
 {
     try
     {
         string[] items = line.Split(DELIMITER);
         return new GraphEdge(
                     graph.getPoint(Convert.ToInt32(items[0])),
                     graph.getPoint(Convert.ToInt32(items[1])),
                     Convert.ToDouble(items[2]));
     }
     catch (System.Exception e)
     {
         throw new GraphParseException("Edge parse error.", line, e);
     }
 }
コード例 #2
0
ファイル: Graph.cs プロジェクト: davidbedok/oeprogvep
        public static Graph load(String fileName)
        {
            Graph graph = new Graph();
            try
            {
                String directory = Path.GetDirectoryName(fileName);
                String baseFileName = Path.GetFileNameWithoutExtension(fileName);
                String pointsFileName = GraphElement.buildPath(directory, baseFileName, GraphPoint.EXTENSION);
                String edgesFileName = GraphElement.buildPath(directory, baseFileName, GraphEdge.EXTENSION);

                GraphElement.load(pointsFileName, graph, GraphPoint.parse);
                GraphElement.load(edgesFileName, graph, GraphEdge.parse);
            }
            catch (System.Exception e)
            {
                throw new BadFileFormatException("Unexpected error while parsing '" + fileName + "'.", e);
            }
            return graph;
        }
コード例 #3
0
ファイル: GraphPoint.cs プロジェクト: davidbedok/oeprogvep
 public static GraphPoint parse(Graph graph, String line)
 {
     try
     {
         string[] items = line.Split(DELIMITER);
         return new GraphPoint(
                         Convert.ToInt32(items[0]),
                         items[1],
                         Convert.ToDouble(items[2]),
                         Convert.ToDouble(items[3]),
                         Convert.ToDouble(items[4]),
                         Convert.ToByte(items[5]),
                         Convert.ToByte(items[6]),
                         Convert.ToByte(items[7]));
     }
     catch (System.Exception e)
     {
         throw new GraphParseException("GraphPoint parse error.", line, e);
     }
 }
コード例 #4
0
ファイル: GraphElement.cs プロジェクト: davidbedok/oeprogvep
 public static void load(string fileName, Graph graph, GraphParser parser)
 {
     StreamReader reader = null;
     try
     {
         reader = new StreamReader(File.Open(fileName, FileMode.Open));
         String line = "";
         while ((line = reader.ReadLine()) != null)
         {
             graph.add(parser(graph, line));
         }
     }
     catch (System.Exception e)
     {
         throw new BadFileFormatException("Unexpected error while parsing '" + fileName + "'.", e);
     }
     finally
     {
         if (reader != null)
         {
             reader.Close();
         }
     }
 }