Class Graph

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class Graph
    extends java.lang.Object
    implements java.lang.Cloneable
    Graph is an adjacency list data structure for representing mapping constraints.
    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Liangpeng Guo
    Pt.AcceptedRating:
    Red (glp)
    Pt.ProposedRating:
    Red (glp)
    • Constructor Summary

      Constructors 
      Constructor Description
      Graph()
      Constructs a linked list.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int id1, int id2)
      Adds a mapping constraint (A, B).
      void clear()
      Clears the linked list to the initial state.
      Graph clone()
      Clones the linked list.
      boolean contains​(int id1, int id2)
      Checks if there is a mapping constraint constraining event id1 and event id2.
      int edgeSize()
      Returns the size of edges.
      Pair<java.lang.Integer,​java.lang.Integer> getEdge​(int edgeId)
      Gets the edge with the given edge ID.
      java.lang.Iterable<java.lang.Integer> getEdges​(int nodeId)
      Gets the iterator of the edges associated with nodeId.
      int nodeSize()
      Return the size of nodes.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Graph

        public Graph()
        Constructs a linked list.
    • Method Detail

      • clone

        public Graph clone()
                    throws java.lang.CloneNotSupportedException
        Clones the linked list.
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException - the object's class does not implement the Cloneable interface.
      • clear

        public void clear()
        Clears the linked list to the initial state. Remove all the mapping constraints.
      • contains

        public boolean contains​(int id1,
                                int id2)
        Checks if there is a mapping constraint constraining event id1 and event id2.
        Parameters:
        id1 - ID of the first event.
        id2 - ID of the second event.
        Returns:
        true if there is a mapping constraint.
      • add

        public void add​(int id1,
                        int id2)
        Adds a mapping constraint (A, B). Event A and B are given by id1 and id2.
        Parameters:
        id1 - ID of event A in the constraint
        id2 - ID of event B in the constraint
      • getEdges

        public java.lang.Iterable<java.lang.Integer> getEdges​(int nodeId)
        Gets the iterator of the edges associated with nodeId.
        Parameters:
        nodeId - ID of the node
        Returns:
        An iterator of the edges connected to nodeId.
      • nodeSize

        public int nodeSize()
        Return the size of nodes.
        Returns:
        the size of nodes.
      • edgeSize

        public int edgeSize()
        Returns the size of edges.
        Returns:
        the size of edges.
      • getEdge

        public Pair<java.lang.Integer,​java.lang.Integer> getEdge​(int edgeId)
        Gets the edge with the given edge ID.
        Parameters:
        edgeId - the edge Id.
        Returns:
        the edge.