Class DAG

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class DAG
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    DAG = Directed Acyclic Graph
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<Vertex> vertexList
      Conatin list of all vertices
      private java.util.Map<java.lang.String,​Vertex> vertexMap
      Maps vertex's label to vertex
    • Constructor Summary

      Constructors 
      Constructor Description
      DAG()  
    • Field Detail

      • vertexMap

        private java.util.Map<java.lang.String,​Vertex> vertexMap
        Maps vertex's label to vertex
      • vertexList

        private java.util.List<Vertex> vertexList
        Conatin list of all vertices
    • Constructor Detail

      • DAG

        public DAG()
    • Method Detail

      • getVertices

        public java.util.List<Vertex> getVertices()
        Returns:
        the vertices
      • getVerticies

        @Deprecated
        public java.util.List<Vertex> getVerticies()
        Deprecated.
        instead use getVertices()
        Returns:
        the vertices
      • getLabels

        public java.util.Set<java.lang.String> getLabels()
      • addVertex

        public Vertex addVertex​(java.lang.String label)
        Adds vertex to DAG. If vertex of given label already exist in DAG no vertex is added
        Parameters:
        label - The label of the Vertex
        Returns:
        New vertex if vertex of given label was not present in the DAG or existing vertex if vertex of given label was already added to DAG
      • removeEdge

        public void removeEdge​(java.lang.String from,
                               java.lang.String to)
      • removeEdge

        public void removeEdge​(Vertex from,
                               Vertex to)
      • getVertex

        public Vertex getVertex​(java.lang.String label)
      • hasEdge

        public boolean hasEdge​(java.lang.String label1,
                               java.lang.String label2)
      • getChildLabels

        public java.util.List<java.lang.String> getChildLabels​(java.lang.String label)
        Parameters:
        label - see name
        Returns:
        the childs
      • getParentLabels

        public java.util.List<java.lang.String> getParentLabels​(java.lang.String label)
        Parameters:
        label - see name
        Returns:
        the parents
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
        See Also:
        Object.clone()
      • isConnected

        public boolean isConnected​(java.lang.String label)
        Indicates if there is at least one edge leading to or from vertex of given label
        Parameters:
        label - the label
        Returns:
        true if this vertex is connected with other vertex,false otherwise
      • getSuccessorLabels

        public java.util.List<java.lang.String> getSuccessorLabels​(java.lang.String label)
        Return the list of labels of successor in order decided by topological sort
        Parameters:
        label - The label of the vertex whose predecessors are searched
        Returns:
        The list of labels. Returned list contains also the label passed as parameter to this method. This label should always be the last item in the list.