Package libai.ants

Class Graph


  • public class Graph
    extends java.lang.Object
    This class belong to the core classes of the Ant Framework.

    It represent the problem being solved. It is composed of a Matrix containing the relation between nodes in the graph.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String fileSource
      If the graph is loaded from a file, this will be a holder for the file's source location
    • Constructor Summary

      Constructors 
      Constructor Description
      Graph​(int r, int c, double[] d)
      Constructor.
      Graph​(java.lang.String fileSource)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getFileSource()  
      Matrix getM()  
      void save​(java.lang.String path)  
      void setFileSource​(java.lang.String fileSource)
      Sets the file source of the matrix to be loaded
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • fileSource

        protected java.lang.String fileSource
        If the graph is loaded from a file, this will be a holder for the file's source location
    • Constructor Detail

      • Graph

        public Graph​(java.lang.String fileSource)
              throws java.lang.Exception
        Constructor. Creates a matrix from file fileSource
        Parameters:
        fileSource - location of file
        Throws:
        java.lang.Exception - if an error ocurred loading file.
      • Graph

        public Graph​(int r,
                     int c,
                     double[] d)
        Constructor. Creates a grpah (matrix) and initialize with the data on data
        Parameters:
        r - number of rows
        c - number of cols
        d - values to initialize the matrix.
    • Method Detail

      • getM

        public Matrix getM()
        Returns:
        The matrix M
      • getFileSource

        public java.lang.String getFileSource()
        Returns:
        The file source
      • setFileSource

        public void setFileSource​(java.lang.String fileSource)
        Sets the file source of the matrix to be loaded
        Parameters:
        fileSource - contains the location of the file
      • save

        public void save​(java.lang.String path)
                  throws java.io.IOException
        Throws:
        java.io.IOException