Class GraphML2Luke

java.lang.Object
it.univr.di.cstnu.util.GraphML2Luke

public class GraphML2Luke extends Object
Utility class for converting STNU file in GraphML format to Luke format.
Version:
$Rev: 732 $
Author:
posenato
  • Field Details

  • Constructor Details

    • GraphML2Luke

      public GraphML2Luke()
  • Method Details

    • convert

      public static File convert(File inputFile) throws IOException, ParserConfigurationException, SAXException
      Converts the given GraphML STNU file to Luke's plain STNU format, using the default output name.
      Parameters:
      inputFile - the GraphML STNU file to convert
      Returns:
      the generated plain STNU file
      Throws:
      IOException - if the input or output file cannot be read or written
      ParserConfigurationException - if the XML parser cannot be configured
      SAXException - if the input file does not contain valid GraphML
    • convert

      public static void convert(File inputFile, File outputFile) throws IOException, ParserConfigurationException, SAXException
      Converts the given GraphML STNU file to Luke's plain STNU format.
      Parameters:
      inputFile - the GraphML STNU file to convert
      outputFile - the output plain STNU file
      Throws:
      IOException - if the input or output file cannot be read or written
      ParserConfigurationException - if the XML parser cannot be configured
      SAXException - if the input file does not contain valid GraphML
    • main

      public static void main(String[] args) throws IOException
      Parameters:
      args - a CSTN file in Luke's format.
      Throws:
      IOException - if any file cannot be read or written
    • stnuAsLukeString

      public static String stnuAsLukeString(@Nonnull DenseTCGraph<STNUEdge> graph)
      Renders the given STNU in Luke's plain format (the same written by stnuPlainWriter(DenseTCGraph, File)).
      Parameters:
      graph - the input graph
      Returns:
      the graph in Luke's plain format.
    • stnuPlainWriter

      static void stnuPlainWriter(@Nonnull DenseTCGraph<STNUEdge> graph, @Nonnull File outputFile)
      Saves the given stnu in file filename in the Hunsberger format.
      Hunsberger format example:
      # KIND OF NETWORK
      STNU
      # Num Time-Points
      5
      # Num Ordinary Edges
      4
      # Num Contingent Links
      2
      # Time-Point Names
      A0 C0 A1 C1 X
      # Ordinary Edges
      X 12 C0
      C1 11 C0
      C0 -7 X
      C0 -1 C1
      # Contingent Links
      A0 1 3 C0
      A1 1 10 C1
      ...
      
      Parameters:
      graph - the input graph
      outputFile - the output file